Greetings everyone!
If you use Azure and you have been deploying Red Hat (LVM) images, you might have noticed or not! that you have some free space that you can reclaim in your LVM configuration.
This is just an example of allocating all the free space not allocated across three different volumes, but you could allocate them whatever way you want.
To dive a bit more into what I am mentioning, here are a few things to look and do.
Let's first see how much space is not allocated:
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sdb4 rootvg lvm2 a-- 62.50g 37.50g
$sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
homelv rootvg -wi-ao---- 1.00g
rootlv rootvg -wi-ao-— 2.00g
tmplv rootvg -wi-ao---- 2.00g
usrlv rootvg -wi-ao---- 10.00g
varlv rootvg -wi-ao---- 10.00g
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sdb4
VG Name rootvg
PV Size <62.51 GiB / not usable 4.98 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 16001
Free PE 9601
Allocated PE 6400
PV UUID JAEeL4-7tg0-T69n-w4jz-7Kgs-vlhq-UhL6yk
You can then, increase by PE's available. In this example, I am using 3000 for varlv, 3000 for tmplv and 3601 for rootlv:
$ sudo lvextend -l +3000 /dev/rootvg/varlv
$ sudo lvextend -l +3601 /dev/rootvg/rootlv
$ sudo lvextend -l +3000 /dev/rootvg/tmplv
You should see these outputs with the operation details:
Size of logical volume rootvg/varlv changed from 10.00 GiB (2560 extents) to <21.72 GiB (5560 extents).
Logical volume rootvg/varlv successfully resized.
Size of logical volume rootvg/rootlv changed from 2.00 GiB (512 extents) to <16.07 GiB (4113 extents).
Logical volume rootvg/rootlv successfully resized.
Size of logical volume rootvg/tmplv changed from 2.00 GiB (512 extents) to <13.72 GiB (3512 extents).
Logical volume rootvg/tmplv successfully resized.
Then you can verify that there are no PE's left:
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sdb4
VG Name rootvg
PV Size <62.51 GiB / not usable 4.98 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 16001
Free PE 0
Allocated PE 16001
PV UUID JAEeL4-7tg0-T69n-w4jz-7Kgs-vlhq-UhL6yk
Finally, resize the partitions to make use of the new allocated space:
$sudo xfs_growfs /dev/rootvg/varlv
$sudo xfs_growfs /dev/rootvg/tmplv
$sudo xfs_growfs /dev/rootvg/rootlv