nova does not grow qcow disk images correctly

Bug #836759 reported by Scott Moser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Scott Moser

Bug Description

I've just loaded a full disk qcow2 image from [1] to nova. I've noticed that the disk is not "resized up" as it is if a partition image is loaded. (Note related bug 833265)

Ie, given these 2 images, both running as 'm1.small' in this cloud:
ami-00000067 private smoser-bucket/oneiric-server-cloudimg-amd64-disk1.qcow2.manifest.xml
ami-00000066 public smoser-ubuntu-images-testing/ubuntu-oneiric-daily-amd64-server-20110829.img.manifest.xml

Where:
$ qemu-img info oneiric-server-cloudimg-amd64-disk1.qcow2
image: oneiric-server-cloudimg-amd64-disk1.qcow2
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: 194M
cluster_size: 65536

An m1.small instance launched from the qcow2 disk gets:
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 2.0G 575M 1.3G 31% /
$ grep . /proc/partitions
major minor #blocks name
 253 0 2097152 vda
 253 1 2088450 vda1
 253 16 20971520 vdb

But a m1.small instance launched from the partition image (ami-00000066) gets:
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/vda 9.9G 576M 8.8G 7% /
$ grep . /proc/partitions
major minor #blocks name
 253 0 10485760 vda
 253 16 20971520 vdb

Note, I'm not expecting nova to rewrite the partition table and then attempt to resize the partition filesystems inside. I explicitly do not want that. I am asking that nova simply grow the disk, extending it with zeros.

The Ubuntu images have code that will rewrite the partition table on first boot if the disk is larger than the first partition [2], so all that is needed is to grow the disk.

[1] https://cloud-images.ubuntu.com/server/oneiric/current/
[2] http://ubuntu-smoser.blogspot.com/2011/03/todo-start-1104-instance-with-larger.html

Tags: server-o-rs

Related branches

Scott Moser (smoser)
summary: - nova does not resize disks like it does partitions
+ nova does not grow disks images it does partition images
Scott Moser (smoser)
summary: - nova does not grow disks images it does partition images
+ nova does not grow disk images as it does partition images
Revision history for this message
Vish Ishaya (vishvananda) wrote : Re: nova does not grow disk images as it does partition images

Scott: thanks for the info there. I thought it was using truncate to expand the image, but it may not be doing so, especially in the case of a qcow2 disk.

Changed in nova:
importance: Undecided → Medium
status: New → Triaged
Scott Moser (smoser)
summary: - nova does not grow disk images as it does partition images
+ nova does not grow qcow disk images correctly
Revision history for this message
Scott Moser (smoser) wrote :

I just verified, that if I pass a full disk image, it does use truncate to resize the disk. However, that is insufficient if the format is other than 'raw'.

I downloaded an Ubuntu qcow image, then ran:
 qemu-image convert -O raw $input $output.raw
 cloud-publish-image --type image $output.raw ....

And then, inside, I see:

ubuntu@ubuntu:~$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 9.9G 576M 8.8G 7% /
ubuntu@ubuntu:~$ cat /proc/partitions
major minor #blocks name

 253 0 10485760 vda
 253 1 10474380 vda1
 253 16 20971520 vdb

And in console output, I see:
 GROWROOT: CHANGED: partition=1 start=16065 old: size=4176900 end=4192965 new: size=20948760,end=20964825

Revision history for this message
Scott Moser (smoser) wrote :

qemu-img resize should be able to resize 'raw' images also. So, for this specific bug, I think that it is sufficient to do:

--- nova/virt/disk.py 2011-08-23 05:17:51 +0000
+++ nova/virt/disk.py 2011-08-30 10:51:34 +0000
@@ -58,7 +58,7 @@
     file_size = os.path.getsize(image)
     if file_size >= size:
         return
- utils.execute('truncate', '-s', size, image)
+ utils.execute('qemu-img', 'resize', image, size)
     # NOTE(vish): attempts to resize filesystem
     utils.execute('e2fsck', '-fp', image, check_exit_code=False)
     utils.execute('resize2fs', image, check_exit_code=False)

Dave Walker (davewalker)
tags: added: server-o-rs
Scott Moser (smoser)
Changed in nova:
status: Triaged → In Progress
Thierry Carrez (ttx)
Changed in nova:
assignee: nobody → Scott Moser (smoser)
Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → 2011.3
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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