Expanding a Mounted Root LVM Filesystem

These instructions are from https://www.rootusers.com/lvm-resize-how-to-increase-an-lvm-partition/. Note: Some output to the commands below that’s not relevant to these instructions has been removed, so your output will be different.

See capacity of current root file system:

$ df -h /
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root2   99G   82G   12G  88% /

Check size of volume group to make sure it has enough space:

$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  VG Size               931.27 GiB
Alloc PE / Size 53231 / 207.93 GiB
Free PE / Size 185174 / 723.34 GiB

Check size of logical volume:

$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root2
  LV Name                root2
  VG Name                ubuntu-vg
  LV Size                100.00 GiB

It has 100GB, but needs 175GB.

To expand the volume group by 75GB:

$ sudo lvextend -L+75G /dev/ubuntu-vg/root2

Check that it’s now 175GB:

$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root2
  LV Name                root2
  VG Name                ubuntu-vg
  LV Size                175.00 GiB

Now expand the file system:

$ sudo resize2fs /dev/ubuntu-vg/root2

Check that it’s done:

$ df -h /
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root2  173G   93G   72G  57% /