How to extend an lvm volume
check if vg has free space (VFree)
$ vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 3 0 wz--n- <1.82t 1.13t
If enough space is free we can resize the logical volume
This will extend the volume by 1G
$ lvextend -L+1G /dev/mapper/datavg-testlv
Size of logical volume datavg/testlv changed from 1.00 GiB (256 extents) to 2.00 GiB (512 extents).
Logical volume datavg/testlv successfully resized.
This will extend the volume to the size of 10G
$ lvextend -L10G /dev/mapper/datavg-testlv
Size of logical volume datavg/testlv changed from 2.00 GiB (512 extents) to 10.00 GiB (2560 extents).
Logical volume datavg/testlv successfully resized.
check new size with lvs
$ lvs
LV VG Attr LSize Pool Origin
testlv datavg -wi-ao---- 10.00g
now the LV is extended. to make the space usable we have to extend the filesystem
$ df -hTP | grep test
/dev/mapper/datavg-testlv ext4 974M 24K 907M 1% /mnt/test
$ resize2fs -p /dev/mapper/datavg-testlv
resize2fs 1.46.5 (30-Dec-2021)
Dateisystem bei /dev/mapper/datavg-testlv ist auf /mnt/test eingehängt; Online-Größenänderung ist
erforderlich
old_desc_blocks = 1, new_desc_blocks = 2
Das Dateisystem auf /dev/mapper/datavg-testlv is nun 2621440 (4k) Blöcke lang.
$ df -hTP | grep test
/dev/mapper/datavg-testlv ext4 9.9G 4.5M 9.4G 1% /mnt/test
Now we have the 10G as usable space