How to expand an existing XFS filesystem on LVM Logical Volume on Linux

This example was done in RHEL7.9.
Expand an existing XFS filesystem on LVM Logical Volume.

Display information about 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 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 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 centos LVM Volume Group.

$ sudo vgextend sdavg /dev/sdb
  Volume group "sdavg" successfully extended

Display information about 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 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 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 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

Expands an 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=15178752, 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