armhf QCOW image contains partition bigger than the image

Bug #980456 reported by Michael Hope
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released

Bug Description

Seen on

The QCOW2 image fails to mount inside QEMU or using qemu-nbd due to the partition being bigger than the device. To reproduce:

 * Download the image
 * Run sudo qemu-nbd -c /dev/nbd0 $PWD/precise-server-cloudimg-armhf-disk1.img
 * Have a look a dmesg
 * See 'nbd0: p1 size 1638630 extends beyond EOD, truncated'
 * Run sudo partprobe /dev/nbd0
 * See Error: Can't have a partition outside the disk!

On QEMU you'll see things like EXT4-fs (mmcblk0p1): bad geometry: block count 204800 exceeds size of device (204775 blocks)

The on-disk image is ~200 M. The virtual size is 808 M. When QEMU sees it it reports as 807 M.

The raw image in $foo-armhf.tar.gz is fine.

Revision history for this message
Ben Howard (darkmuggle-deactivatedaccount) wrote :

Thank you for giving the the ARMHF images a look. I was unable to replicate using the latest daily. Can you tell me what daily you were using?

[29788514.597447] nbd: registered device at major 43
[29788521.545571] nbd0: p1
[29789553.013362] EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null)
[29789584.151973] EXT4-fs (nbd0p1): mounted filesystem with ordered data mode. Opts: (null)

Changed in ubuntu-on-ec2:
status: New → Incomplete
importance: Undecided → Medium
Revision history for this message
Michael Hope (michaelh1) wrote :

Sure. I see the problem with today's build at:

Running the qemu-nbd command gives:

[24141.298818] nbd0: p1
[24141.298848] nbd0: p1 size 1638630 extends beyond EOD, truncated

but it does mount OK:

sudo mount /dev/nbd0p1 /mnt
[24312.910516] EXT4-fs (nbd0p1): mounted filesystem with ordered data mode. Opts: (null)

That may be due to luck :)

And some versions:

michaelh@crucis:~/Downloads$ qemu-nbd --version
qemu-nbd version 0.0.1
Written by Anthony Liguori.

Copyright (C) 2006 Anthony Liguori <email address hidden>.
This is free software; see the source for copying conditions. There is NO

michaelh@crucis:~/Downloads$ dpkg -l qemu-utils
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
ii qemu-utils 1.0+noroms-0ubuntu13 qemu utilities

This is on Precise x86_64.

Revision history for this message
dann frazier (dannf) wrote :

This appears to be an off-by-one error in the image creation process.

## I grabbed this image:
$ md5sum precise-server-cloudimg-armhf-disk1.img
8b5374717525b0122f1f2f158efcc0a2 precise-server-cloudimg-armhf-disk1.img
## Converted it to raw format
$ qemu-img convert -O raw precise-server-cloudimg-armhf-disk1.img precise-server-cloudimg-armhf-disk1.raw
## Then dumped the disk/filesystem sizes using a sector unit
$ parted precise-server-cloudimg-armhf-disk1.raw -- unit s print
WARNING: You are not superuser. Watch out for permissions.
Model: (file)
Disk /home/ubuntu/precise-server-cloudimg-armhf-disk1.raw: 1654695s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
 1 16065s 1654694s 1638630s primary ext4 boot

## The disk is 1654695 sectors, which means it contains sectors 0->1654694
## But you can see that partition 1's last sector is 16065 + 1638630 = 1654695
## i.e., 1 sector past the end of the disk.
## By adding one more sector to the image, the kernel no longer complains:
$ sudo dmesg -c > /dev/null
$ sudo qemu-nbd -r -c /dev/nbd5 $(pwd)/precise-server-cloudimg-armhf-disk1.img+1
$ dmesg
[18417.738752] nbd5: p1

It looks like the disk is just 1 sector short of a full partition (yeah, yeah - takes one to know one).

I'll drop the "Incomplete" flag, since I don't think any more information is required from the submitter.

Changed in ubuntu-on-ec2:
status: Incomplete → Confirmed
Scott Moser (smoser)
no longer affects: ubuntu-on-ec2
Changed in ubuntu:
importance: Undecided → High
status: New → Confirmed
tags: added: cloud-images cloud-images-build
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Revision history for this message
dann frazier (dannf) wrote :

Oops - missed a step there. Here's how I added the extra sector to the raw image & reconverted to qcow2:

$ dd if=/dev/zero bs=512 count=1 oflag=append conv=notrunc of=precise-server-cloudimg-armhf-disk1.raw
1+0 records in
1+0 records out
512 bytes (512 B) copied, 8.7139e-05 s, 5.9 MB/s
$ qemu-img convert -O qcow2 precise-server-cloudimg-armhf-disk1.raw precise-server-cloudimg-armhf-disk1.img+1

Changed in ubuntu:
status: Confirmed → Fix Released
Mathew Hodson (mhodson)
affects: ubuntu → cloud-images
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.