
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.
Like this:
Like Loading...