archive:centos_extend_logical_volume
CentOS extend logical volume (lvm)
This guide asumes gparted or similar has been used to extend the disk first.
Check current free space
vgdisplay
You will get an outpout similar to this one.
--- Volume group --- VG Name vg0 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 7 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 <49.00 GiB PE Size 4.00 MiB Total PE 12543 Alloc PE / Size 9727 / <38.00 GiB Free PE / Size 2816 / 11.00 GiB VG UUID L6MTYI-RIC3-D40W-pJOq-tEvn-UQEe-BFvkb3
Here we have 11 GB free as shown by this line:
"Free PE / Size 2816 / 11.00 GiB"
List current logical volumes
Let's have a look at the logical volumes.
lvdisplay
You will get an outpout similar to this one.
--- Logical volume --- LV Path /dev/vg0/root LV Name root VG Name vg0 LV UUID rCx5XM-BPPn-eJVj-CvbE-ahfX-7fpa-2XtgDN LV Write Access read/write LV Creation host, time localhost, 2019-05-23 15:16:53 +0200 LV Status available # open 1 LV Size <38.00 GiB Current LE 9727 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
Expand logical volume
We will expand "/dev/vg0/root" as shown by this line:
"LV Path /dev/vg0/root"
If we want to use all availabe space we can run the following command:
lvextend -l +100%FREE /dev/vg0/root
If however you only want to extend with like say 5 GB use this command:
lvextend -L+5G /dev/vg0/root
Resize file system
Now we need to resize the file system.
resize2fs /dev/vg0/root
Note you can skip the resize2fs part by using the -r (resizefs) flag in lvextend like this:
lvextend -r -l +100%FREE /dev/vg0/root
Check if things are ok
Once done check that everything is in order.
df -H
archive/centos_extend_logical_volume.txt · Last modified: 24/11/2023 12:42 by Allan