Snippet Path

Extend default LVM space

Authors

Investigate free space state

To check current state of free disk space:

shell
df -h

You'll see /dev/mapper/ubuntu--vg-ubuntu--lv almost full.

Use vgdisplay command to check how much free space you have. This information is displayed in the Free PE / Size row.

Use lvdisplay to check the current size of the logical volume.

Change size of the LVM

When Logical Volume is not using all the Volume Group's available storage:

shell
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Now use lvdisplay again to check if the size is changed. Remember the lvextend does not automatically commit the changes on the LVM. You need to use this command to apply the changes:

shell
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 

When LVM has a wrong idea of the size of a partition, for example sda1:

shell
pvresize /dev/sda1

# Physical Storage/Disk: sda (for example SSD), sdb (for example HDD)
# PV: sda1, sda2, sda3 (different partitions of the same disk)
# VG: ubuntu-vg (for example: a group of sda3 and sdb)
# LV: ubuntu-lv (an LV on top of ubuntu-vg that uses all the free space of vg)

Summary

In short, use these two commands:

shell
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv