Resizing qcow2 images

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

To date (as of qemu 0.12.5), it was not possible to resize qcow2 images. The only workaround was to convert the image to some other format, resize it, and convert it back to qcow2. Which could be quite lengthy and meant plenty of IO. Moreover, it was even more tricky if the image was already more than 50% of your storage space and you still wanted to increase its size.

It changed with qemu 0.13.0 (still release candidate as of writing this blog post), where resize option was added to qemu-img.

To resize a qcow2 image, download the latest release candidate of 0.13.0, compile it, and resize the image:

srv1:/usr/src/qemu-0.13.0-rc1# ./qemu-img -h
qemu-img version 0.12.90, Copyright (c) 2004-2008 Fabrice Bellard
usage: qemu-img command [command options]
  resize filename [+ | -]size

srv1:/var/lib/vz/images/108# /usr/src/qemu-0.13.0-rc1/qemu-img resize vm-108-disk-1.qcow2 +5G
Image resized.