When we resize the virtual hard disk of a virtual machine or restore a disk image to a larger disk, the free space of the partition detected by Ubuntu will not increase because the partition table is unchanged. In the past, we could easily resize the ext4 root partition with the help of resize2fs. However, things get complex when Ubuntu utilizes LVM partition as their default root partition.

## Quick Intro to LVM

Logical Volume Manager (LVM) is similar to Dynamic Disks under Windows, which can take several GPT / MBR partitions on different hard disks as a storage pool (LVM call it Volume Groups, VG), and allocate spaces from this pool, then Linux will recognize each space (LVM call it Logical Volume, LV) as an useable partition.

Thus, we should modify not only the GPT / MBR partition table, but also the LVM configuration.

## Update GPT / MBR partition table

I suggest all the operations should be done under live CD environment to avoid the occurrence of unpredictable problems. I didn't test online resizing on the root partition so far.

1. The following instructions in this section assume the last partition on your disk is the LVM Physical Volume. You could verify this with the command lsblk --fs. nvme0n1p3 is the last GPT partition on the disk nvme0n1, and it is easy to identify this partition is a LVM PV, and ubuntu--vg-ubuntu--lv is the corresponding LV.

Note that ubuntu--vg-ubuntu--lv is the root partition of the system here.

Also you could check the LVM Volume Group status by vgs.

1. Update the GPT / MBR partition table using fdisk. I will use an emulated disk /dev/loop3 to demonstrate the whole process. Don't worry, you won't loss your data under normal circumstances. These commands will only modify the partition table, but make sure DO NOT remove the LVM's signature, otherwise the system may no longer recognize your LVM PV.

## Update LVM Configuration

1. Notify LVM there is an update on the partition table.

At this moment, the LVM Volume Group status has changed to,

Observe that VFree of test-vg has increased by 524.00 MB.

1. Resize LVM Logical Volume. The following command will allocate all the free space of VG to the LV.

The free space of VG is used up now.

## Resize ext4 File System

Up to now, although LVM LV is resized, the ext4 file system is not aware of the extra available space. Simply run resize2fs to let it know.

We can see the available space of test--vg-test--lv has been enlarged.