How to grow an XFS filesystem with pvcreate, vgextend, lvextend and xfs_growfs commands?

image

The methods below show how to extend a Volume Group (VG), a Logical Volume (LV), and a filesystem with a Physical Volume designated /dev/sda. (PV).

  • Create a PV from a free disk or partition (e.g., a partition named /dev/sda1):

# pvcreate /dev/sda1

  • Extend the VG name vg. /dev/sda1 is the existing PV path.

# vgextend vg /dev/sda1

  • Extend the LV and resize the underlying filesystem at the same time (the existing LV path is /dev/vg/lv00), which will be expanded by 150 GB.

# lvextend -r -L +150G /dev/vg/lv00

If you don’t run resize2fs or xfs_growfs on the block device after growing the Logical Volume, the file system size will be the same as it was before. To make use of the LVM’s extra capacity, use resize2fs or xfs_growfs to fill the partition with the current file system. You can now see the extended size of the file system in the df command output after resizing the file system.

Leave a Reply