virt-resize

When you get a qcow2 image with a given size – it can’t be simply changed on-the-fly while running a VM or by giving just more space to a VM flavor in OpenStack. Situation gets even more complex when image has LVs inside but fortunately by using guestfishand virt-resizeimage can be suited to one’s needs. Below are the steps that I used to perform such modifications:

Default image: image-name-250G.qcow2
Resized: image-name-750G.qcow2

1. Check which device to resize (this image has LVM created PV on /dev/sda2):

1

2

3

guestfish-aimage-name.qcow

run

pvs-full--SHOWS WHICH DEVICE TORESIZE

2. Resize image (from 250 to 750GB) – resizing is NOT performed in place:

1

2

cp image-name-250G.qcow2image-name-750G.qcow2

qemu-img resize image-name-750G.qcow2+500GB

3. Resize disk and specific device (in this case it is /dev/sda2) and LVM PV:

4. Go to guestfish and use free space on VGS to create additional LV, create additional filesystem and mount point (DISABLE 64bit flag on EXT4, required by this image as it uses outdated e2fsck
that doesn’t support 64bit option):