This guide asumes gparted or similar has been used to extend the disk first.
vgdisplay
You will get an outpout similar to this one.
--- Volume group --- --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <99.00 GiB PE Size 4.00 MiB Total PE 25343 Alloc PE / Size 5120 / 20.00 GiB Free PE / Size 20223 / <79.00 GiB VG UUID 0dJIdX-owJK-tT6W-E5CG-VbVu-1pZU-OqA9oe
Here we have 79 GB free as shown by this line:
"Free PE / Size 20223 / 79.00 GiB"
Let's have a look at the logical volumes.
lvdisplay
You will get an outpout similar to this one.
--- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID r4t303-MwxK-MYvc-Ufdv-rx2K-sN49-oettLL LV Write Access read/write LV Creation host, time ubuntu-server, 2021-06-01 11:07:11 +0000 LV Status available # open 1 LV Size 20.00 GiB Current LE 5120 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
We will expand "/dev/ubuntu-vg/ubuntu-lv" as shown by this line:
"LV Path /dev/ubuntu-vg/ubuntu-lv"
If we want to use all availabe space we can run the following command:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
If however you only want to extend with like say 5 GB use this command:
lvextend -L+5G /dev/ubuntu-vg/ubuntu-lv
Now we need to resize the file system.
resize2fs /dev/ubuntu-vg/ubuntu-lv
Note you can skip the resize2fs part by using the -r (resizefs) flag in lvextend like this:
lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Once done check that everything is in order.
df -H