In an effort to allow future expansion of my VMs OS disk, I chose to create the root filesystem on a LVM based logical volume.

However, after getting close to running out of space, I found getting LVM to “see” the new size involved a few more steps than I was initially expecting, this post is to simply document how to get the new disk size recognised and made available to the root partition.

Step 1 - Parted

First step is to use parted (I used GPT partitions which fdisk and cfdisk appear to struggle with) to correct the partition table and resize the LVM partition.

Note: My LVM partition is the last on the disk and I will be expanding it to the end of the resized disk.

sudo parted
print devices
select <device path e.g. /dev/vda>
print

At this point parted will recognise that the GPT table doesn’t match the size of the disk and will ask if you want to fix it, enter “fix” to resolve this.

resizepart <number of the last partition from print statement> <total disk size>
quit

Step 2 - Extend LVM’s physical volume for the new space

sudo pvresize -v <device partition, e.g. /dev/vda3>

Step 3 - Extend LVM’s logical volume for the new space

Note: The below example assumes you have increased the disk size by 10GB.

sudo lvextend -L +10GB <lvm path>

Step 4 - Extend the filesystem

sudo resize2fs <lvm path>