Environment

  • Red Hat Enterprise Linux (RHEL) 5, 6, 7, 8
  • Logical Volume Manager (LVM) 2

Issue

  • What is the procedure to grow an existing filesystem based on Logical Volume?
  • How can I extend my logical volume and the filesystem in the command line?
  • I have extended a logical volume using lvextend which shows the extension in volume group vgdisplay but df isn't reflecting the size, am I missing anything?
  • How do I grow an ext3/ext4/XFS filesystem on LVM?
  • How do I increase my filesystem on the fly, without unmounting it ?
  • We are using LVM for mounting the filesystem, how can we use the lvextend command to extend the volume group and increase the filesystem size?
  • What are the steps to extend a filesystem after a LUN capacity has been extended?
  • What is the procedure to increase the size of an LVM2 logical volume and resize its filesystem?
  • I need to expand a filesystem created on LVM partition, does the filesystem need to be unmounted when expanding it or can I resize it online?
  • How to grow an ext filesystem with pvcreatevgextendlvextend and resize2fs commands
  • How to grow an XFS filesystem with pvcreatevgextendlvextend and xfs_growfs commands
  • I have extended the logical volume size with lvextend command but the size of the file system its not reflecting this change

Resolution


Warning: Red Hat recommends that all critical data be backed up and verified before making any changes to the underlying storage as an unforeseen problem might occur.


The following are sample steps to extend a Volume Group (VG), a Logical Volume (LV), and a filesystem using a device named /dev/sdN as its Physical Volume (PV).

  1. Create a PV from a free disk or partition (e.g. /dev/sdN1 as a partition):

    # pvcreate /dev/sdN1
    
  2. Extend the VG (/dev/sdN1 is an existing PV path):

    # vgextend vgdata /dev/sdN1
    
  3. Extend the LV and resize the underlying filesystem together (/dev/vgdata/lvdata is the existing LV path), which will be extended by 125 GB:

    # lvextend -r -L +125G /dev/vgdata/lvdata
    

Root Cause

Logical Volume Manager 2 (LVM2) allows you to aggregate physical storage devices into volume groups. You can then divide that aggregated space into one or more logical volumes.

Once created, logical volumes can be extended to utilize unused space within the volume group, allowing the file system residing on the logical volume to be extended as well. However, if all of the physical storage in a volume group is already occupied by logical volumes, then more physical volumes must be added before the logical volume can be extended.

Note: if you have not run resize2fs or xfs_growfs on the block device after extending the Logical Volume you will see the file system size as the same as before extending it. In order to use the extended space on the LVM run resize2fs or xfs_growfs to fill up the partition with the existing file system. After resizing the file system you will now be able to see the extended size of the file system in df command output.

Diagnostic Steps

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.