[libvirt-users] Re-sizing qcow2 images

Chandana De Silva chandana at desilva.id.au
Mon Oct 29 21:38:41 UTC 2012

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

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.

More information about the libvirt-users mailing list