Expand KVM based image with lvm partition

Lets take a quick look at how to expand kvm raw image with lvm partition running CentOS7 guest. We will need to download gparted for this to re-size image. It cam be downloaded from here. We will be expanding our image by 10G.

1. Expand raw image with qemu-img.

qemu-img resize myimage.img +10G 

2. There are few ways to do this. One of the easy ones is simply connect cd in virtual machine manager to downloaded iso with gparted and set vm to boot to this iso. Ones booted expand image by 10G

3. Reboot system to boot back to vm image. Ones system started expand LVM volume by 10 G

lvextend -L+10G /dev/myvg/myvol

4. Now based on weather it is xfs or ext4 expand file system
xfs

xfs_growfs /dev/myvg/myvol

ext4

resize2fs /dev/myvg/myvol