How to Resize a qcow2 Image and Filesystem
In this post, I am going to quickly document the process I used to grow a qcow2 disk image and increase the size of the underlying filesystem.
In this instance, I ran out of disk space on my virtual disk named undercloud.qcow2. Apparently, the underlying disk image that I was using was too small for my needs.
Below, I have used qemu image to inspect the disk size. This disk is only 10G in size.
# qemu-img info undercloud.qcow2
image: undercloud.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 9.8G
cluster_size: 65536
…
Let’s add 20G to the disk. Note, the VM must be powered down before proceeding.
# qemu-img resize undercloud.qcow2 +20G
Image resized.
Finally, mount the qcow2 disk image to the host (use qemu-nbd for example to mount it as a network block device) and resize/move partitions and filesystems