Assuming that your Linux machine is a virtual one and you already extended its disk, now we have to perform a rescan to discover new allocated space (alternatively, you could reboot the virtual machine).

echo '1' > /sys/class/scsi_disk/0\:0\:0\:0/device/rescan

We will use parted command to extend the partition.

parted /dev/sda

Now, we will use print command to view all partitions. Then, assuming that we want to extend the 4th partition with all available space

print
resizepart 4 -0
quit

Finally, we will check how much available free space is in the volume group and extend the logical volume using this space. After that, we will extend the file system.

pvresize /dev/sda4
vgdisplay rhel | grep "Free"
lvextend -L+500.00G /dev/mapper/rhel-aux1
xfs_growfs /dev/mapper/rhel-aux1

Update! As o the new versions of xfs_growfs, it does not accept any more devices as parameter:
xfs_growfs expands an existing XFS filesystem (see xfs(5)). The mount-point argument is the pathname of the directory where the filesystem is mounted.

So, if you will receive an error message like this:
Error: xfs_growfs: /dev/mapper/cl-root is not a mounted XFS filesystem
You will have to replace /dev/mapper/cl-root with the mount-point. E.g. If you want to expand the root fyle sistem, jut type xfs_growfs /

# xfs_growfs /
meta-data=/dev/mapper/cl-root    isize=256    agcount=14, agsize=877824 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0 spinodes=0 rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=12055552, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
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 12055552 to 16248832

Leave a Reply