Situation: I had originally created one of my QEMU/KVM Virtual Machines with a qcow2 format disk image of 25GB. I realised I needed more space on my /data partition.

mount:
/dev/mapper/vg_icky-lv_data on /data type ext4 (rw)

lvscan:
ACTIVE '/dev/vg_icky/lv_data' [12.54 GiB] inherit

pvscan:
PV /dev/vda2 VG vg_icky lvm2 [24.51 GiB / 0 free]

The VM's disk resides on the host at:
/raiddata/VMRAID/icky.img

This is what I did:
  • stop the virtual machine.
  • On the host, execute the following:
    • qemu-img resize /raiddata/VMRAID/icky.img +37G
  • start the virtual machine.
  • Since the new disk space was added at the end, we can just increase the size of the existing /dev/vda2 partition:
    • /dev/vda2 1018 52013 25701376 8e Linux LVM
  • Execute "fdisk /dev/vda":
    • delete partition 2 (d 2)
    • create a new partition starting from the old block till the last cylinder (n p 2 1018 [enter])
    • Set the file type for the partition (t 2 8e).
  • reboot
  • Grows the physical volume to its partition's new space:
    • Look at the size of the physical volume with "pvscan":
      • PV /dev/vda2 VG vg_icky lvm2 [24.51 GiB / 0 free]
    • resize the /dev/vda2 physical volume to match the size of its partition:
      • pvresize /dev/vda2
    • pvscan should now reflect the new size:
      • PV /dev/vda2 VG vg_icky lvm2 [61.51 GiB / 37.00 GiB free]
  • Grow the logical volume to use up the extra space in its physical volume:
    • Look at the size of the logical volume with "lvscan":
      • ACTIVE '/dev/vg_icky/lv_data' [12.54 GiB] inherit
    • resize the /dev/vg_icky/lv_data logical volume at all available free space:
      • lvextend -l +100%FREE /dev/vg_icky/lv_data
    • Look at the size again:
      • ACTIVE '/dev/vg_icky/lv_data' [49.54 GiB] inherit
  • Grow the file system
    • Size before (df -kh | grep data):
      • /dev/mapper/vg_icky-lv_data 13G 828M 11G 7% /data
    • grow the ext file system:
      • resize2fs -p /dev/mapper/vg_icky-lv_data
    • Size after (df- kh | grep data):
      • /dev/mapper/vg_icky-lv_data
        49G 837M 46G 2% /data
  • Done!