[libvirt-users] Re-sizing qcow2 images

Hello All, I am using Centos 6.3 with libvirt 0.910 and qemu-kvm 0.12 I had to resize a qcow2 disk, and came across several issues; I used this command to resize the image: sudo -i /usr/bin/qemu-img /var/lib/libvirt/images/mydisk.img resize +100G . The disk is attached using virtio. I then tried to use parted from within the guest to resize the partition. The first problem was that the guest os did not see the increase disk size. Is there something that I need to do, to force the guest to see the higher disk size ? I got round this by re-starting the guest, but it would be better if there is some way to force the guest to see the new size. The second problem was that parted gave an error : Error: Filesystem has an incompatible feature enable. Some reading showed that this was caused by the "resize_inode" feature on the file system. I removed this feature using debugfs, and rans fsck, but parted still gave the same error: Error: Filesystem has an incompatible feature enable. I would like some advice on how this is supposed to be done. Thanks in advance. Chandana

On 10/28/2012 04:43 AM, Chandana De Silva wrote:
Hello All,
I am using Centos 6.3 with libvirt 0.910 and qemu-kvm 0.12
I had to resize a qcow2 disk, and came across several issues;
I used this command to resize the image:
sudo -i /usr/bin/qemu-img /var/lib/libvirt/images/mydisk.img resize +100G . The disk is attached using virtio.
For my resizes I use libguestfs's virt-resize [1] tool. It's been working flawlessly so far -- it resizes both the image file/device and partitions inside that image. I can't recommend it enough. Best, Hristo [1] http://www.libguestfs.org/virt-resize.1.html

On 10/27/2012 08:43 PM, Chandana De Silva wrote:
Hello All,
I am using Centos 6.3 with libvirt 0.910 and qemu-kvm 0.12
I had to resize a qcow2 disk, and came across several issues;
I used this command to resize the image:
sudo -i /usr/bin/qemu-img /var/lib/libvirt/images/mydisk.img resize +100G . The disk is attached using virtio.
Is this while the guest is running, or while it is offline? NEVER use qemu-img to modify a disk image while a guest is simultaneously running on that image, as you risk data loss due to image corruption. If the guest is running, then 'virsh blockresize' is the only way to resize the disk in a manner visible to the guest; from there, once the guest sees the new partition size, then run commands within the guest to make the file system expand to the new larger partition size (assuming of course that your file system is one like ext4 that can do online resizing). This is also supposing you have new enough libvirt and qemu to support online resizing (if you don't, then your only solution is offline resizing, although depending on which disk, you can perhaps mitigate guest downtime by hotunplugging the disk, doing the resize, and then hotplugging the disk back in, if that particular disk is not essential to the guest's operation). If the guest is offline, then I recommend 'virt-resize' from libguestfs, rather than trying to use qemu-img yourself. virt-resize not only knows how to resize the partitions, but also most file systems residing in those partitions, which will save you a lot of steps. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Hello Eric, Thank you very much for this. Yes, I need to be able to resize a live disk. I will give virsh blockresize a go. Thanks and regards Chandana On 30/10/12 07:07, Eric Blake wrote:
On 10/27/2012 08:43 PM, Chandana De Silva wrote:
Hello All,
I am using Centos 6.3 with libvirt 0.910 and qemu-kvm 0.12
I had to resize a qcow2 disk, and came across several issues;
I used this command to resize the image:
sudo -i /usr/bin/qemu-img /var/lib/libvirt/images/mydisk.img resize +100G . The disk is attached using virtio. Is this while the guest is running, or while it is offline? NEVER use qemu-img to modify a disk image while a guest is simultaneously running on that image, as you risk data loss due to image corruption.
If the guest is running, then 'virsh blockresize' is the only way to resize the disk in a manner visible to the guest; from there, once the guest sees the new partition size, then run commands within the guest to make the file system expand to the new larger partition size (assuming of course that your file system is one like ext4 that can do online resizing). This is also supposing you have new enough libvirt and qemu to support online resizing (if you don't, then your only solution is offline resizing, although depending on which disk, you can perhaps mitigate guest downtime by hotunplugging the disk, doing the resize, and then hotplugging the disk back in, if that particular disk is not essential to the guest's operation).
If the guest is offline, then I recommend 'virt-resize' from libguestfs, rather than trying to use qemu-img yourself. virt-resize not only knows how to resize the partitions, but also most file systems residing in those partitions, which will save you a lot of steps.
participants (3)
-
Chandana De Silva
-
Eric Blake
-
Hristo Deshev