Resize QCOW2 disk image · uwot.eu
another meaningless subtitle

Resize QCOW2 disk image

· by fabio · Read in about 1 min · (137 Words)
Fedora CentOS Linux XFS qemu

QCOW2 disk images can be easily grown using libvirt command line utils.
Unfortunately it isn’t possible to grow QCOW2 images in-place or online.
First of all, power off the virtual machine, grow the file and make a copy of it:

$ qemu-img resize image.qcow2 +200G
$ cp image.qcow2 image-new.qcow2

Identify the specific partion you intend to grow:

$ virt-filesystems -a image.qcow2 -l
Name       Type        VFS   Label  Size           Parent
/dev/sda1  filesystem  ext4  -      536870912      -
/dev/sda3  filesystem  xfs   -      45885612000  -

Expand the actual partition:

$ virt-resize --expand /dev/sda3 image-new.qcow2 image.qcow2

Use qemu-img to check that the image is actually 200 GB bigger:

$ qemu-img info image.qcow2

Boot up the VM and grow the XFS filesystem, in my case I wanna grow /dev/sda3 which is mounted as root FS:

$ xfs_growfs /

virt-filesystem
virt-resize
qemu-img
xfs_growfs