How to Resize a qcow2 Image and Filesystem with Virt-Resize


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.

Now we need to resize the underlying filesystems using “virt-resize“. Note, however, that that “virt-resize” CANNOT resize disk images in-place. So we need to use make a backup copy and use the backup copy of the qcow as input and use the original qcow as output. See example below.

First, we make a backup copy of the disk as shown below.

# cp undercloud.qcow2 undercloud-orig.qcow2


Then we run the command below to grow /dev/sda.

NOTE: In this example /dev/sda1 is not the /boot partition. So be careful you are growing the correct partitions on your qcow.

# virt-resize –expand /dev/sda1 undercloud-orig.qcow2 undercloud.qcow2

Output shown below:

virt-resize: warning: unknown/unavailable method for expanding the xfs
filesystem on /dev/sda1
/dev/sda1: This partition will be resized from 10.0G to 30.0G.

We now inspect new disk

# qemu-img info undercloud.qcow2
image: undercloud.qcow2
file format: qcow2
virtual size: 30G (32212254720 bytes)
disk size: 9.4G
cluster_size: 65536
Format specific information:
compat: 0.10

Finally, we verify that the filesystems have grown.

# virt-filesystems –long -h –all -a undercloud.qcow2
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem xfs – – 30G –
/dev/sda1 partition – – 83 30G /dev/sda
/dev/sda device – – – 30G –

We can now boot our Virtual Machine.

9 thoughts on “How to Resize a qcow2 Image and Filesystem with Virt-Resize

  1. Pingback: Resizing a qcow2 Image | Adam Molnar

  2. Hello and thanks for your post,

    I got this error message :

    virt-resize –expand /dev/sda2 MBtestORIGIN.qcow2 MBtest.qcow2
    Examining MBtestORIGIN.qcow2 …
    Fatal error: exception Guestfs.Error(“part_get_parttype: unknown signature, expected “BYT;” as first line of the output:Error: The backup GPT table is not at the end of the disk, as it should be.”)

  3. Hi there! That was the life saver for me in a critical task. Thanks a bunch for posting that!

    One note worth mentioning: WP has replaced double dashes with long dashes. That’s Ok for text publishing, but may totally screw up the command line.

  4. Correction – this is the only guide that works and its not in the top results for Google search. This page was linked from another search result.

  5. Pingback: How to Resize qcow2 Image Using virt-resize and qemu-img(KVM tools) in 6 Easy Steps | CyberITHub

  6. Pingback: Kubernetes homelab with KVM and OpenVSwitch

  7. Thanks, excellent guide. I just add. If your guest is windows, after adding the space to the image, verify the assignment. Start your virtual machine, and finish the expansion through the Windows disk manager.

  8. Thanks! This worked very well. I have a qcow2 image that I’ve set up on my Intel NUC running RHEL8.3. The default size of the image has only 5G all in and by the time I added two or three add-ons, it ran out of space. I had then followed your instructions above and move it to 25G in size. Thank you very much!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.