[libvirt-users] Re-sizing qcow2 images

Eric Blake eblake at redhat.com
Mon Oct 29 20:07:47 UTC 2012


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 at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20121029/f961cf7b/attachment.sig>


More information about the libvirt-users mailing list