Expanding an XFS Filesystem on LVM Logical Volume in RHEL 7.9
To expand an existing XFS filesystem on an LVM logical volume, you can follow these steps. Please note that this example is specific to RHEL 7.9.
-
Display information about the LVM physical volumes:
$ sudo pvs PV VG Fmt Attr PSize PFree /dev/sda2 sdavg lvm2 a-- <15.51g 0 /dev/sda3 sdavg lvm2 a-- <44.00g 0
-
Add a physical disk
/dev/sdb
:$ sudo lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 60G 0 disk ├─sda1 8:1 0 500M 0 part /boot ├─sda2 8:2 0 15.5G 0 part │ ├─sdavg-rootlv 253:0 0 57.9G 0 lvm / │ └─sdavg-swaplv 253:1 0 1.6G 0 lvm [SWAP] └─sda3 8:3 0 44G 0 part └─sdavg-rootlv 253:0 0 57.9G 0 lvm / sdb 8:16 0 40G 0 disk
-
Initialize
/dev/sdb
disk for use by LVM:$ sudo pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created.
-
Display information about the LVM physical volumes:
$ sudo pvs PV VG Fmt Attr PSize PFree /dev/sda2 sdavg lvm2 a-- <15.51g 0 /dev/sda3 sdavg lvm2 a-- <44.00g 0 /dev/sdb lvm2 --- 40.00g 40.00g
-
Display information about the LVM volume groups:
$ sudo vgs VG #PV #LV #SN Attr VSize VFree sdavg 2 2 0 wz--n- <59.50g 0
-
Add
/dev/sdb
LVM physical volume to thesdavg
LVM volume group:$ sudo vgextend sdavg /dev/sdb Volume group "sdavg" successfully extended.
-
Display information about the LVM volume groups:
$ sudo vgs VG #PV #LV #SN Attr VSize VFree sdavg 3 2 0 wz--n- <99.50g <40.00g
-
Display information about the LVM logical volumes:
$ sudo lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert rootlv sdavg -wi-ao---- 57.90g swaplv sdavg -wi-ao---- 1.60g
-
Extend the root LVM logical volume to use all available free space in the LVM volume group:
$ sudo lvextend --extents +100%FREE /dev/sdavg/rootlv Size of logical volume sdavg/rootlv changed from 57.90 GiB (14823 extents) to <97.90 GiB (25062 extents). Logical volume sdavg/rootlv successfully resized.
-
Display information about the LVM logical volumes:
$ sudo lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert rootlv sdavg -wi-ao---- <97.90g swaplv sdavg -wi-ao---- 1.60g
-
Expand the root XFS filesystem:
$ sudo xfs_growfs /dev/mapper/sdavg-rootlv meta-data=/dev/mapper/sdavg-rootlv isize=256 agcount=17, agsize=908800 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 spinodes=0 data = bsize=4096 blocks=25663488, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 15178752 to 25663488
This process allows you to expand an existing XFS filesystem on an LVM logical volume. Ensure you follow the steps carefully, as any mistakes may cause data loss.