LVM2: Extend file system

LVM2 refers to the userspace toolset that provide logical volume management facilities on Linux. It is reasonably backwards-compatible with the original LVM toolset.

Resizing volumes with the LVM2 toolset is easy. First you have to adjust your physical partition table using fdisk. Let’s say you have a 60GB physical disk and a 50GB physical partition on it.

You want to resize the partition to take the whole disk. To do that you delete the partition and create it again with the new geometry.

The highlighted rows show the commands issued to fdisk. After the partition table is rewritten reboot the system.

The new partition table should now look like this:

Now that the new partition is setup you can assign the new space to a PV (physical volume). You can check the physical volumes with the pvs command.

In this case you have only one PV (physical volume) of size 50GB. Since you know your partition is 60GB you can very easily resize the PV to take all space with the pvresize command.

As you can see now the PV is of size 60GB and there is 10GB of free space. You can now use the free space to resize an LV (logical volume) using the lvextend command.

The -r option tells lvextend to resize the underlying filesystem (e.g. ext4 or btrfs) along with the LV. The -l option tells lvextend to set the LV size in units of logical extents. In this case the argument to -l is +100%FREE which means that 100% of the free space will be used. In other words all free space will be added to the system/root LV. After lvextend returns the file system should be resized and operational without system reboot.