Extending a logical volume and filesystem online in RHEL using a new disk

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 10
  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 5
  • 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 without rebooting?
  • How can I resize my Logical Volume and my filesystem together?
  • I have an LVM device and have expanded my Volume Group, but my filesystem is the same size. How do I grow my Logical Volume and filesystem?
  • 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 pvcreate, vgextend, lvextend, and resize2fs commands
  • How to grow an XFS filesystem with pvcreate, vgextend, lvextend, and xfs_growfs commands
  • I have extended the logical volume size with lvextend command, but the size of the file system is not reflecting this change.
  • The system needs more inodes.
  • How to increase the amount of available inodes.

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 new 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 vgname /dev/sdN1
    
  3. Extend the LV (/dev/vgname/lvname is the existing LV path). Example of commands:

    # lvextend -L +125G /dev/vgname/lvname
    # lvextend -l +100%FREE /dev/vgname/lvname
    
  4. Resize the filesystem:

    # resize2fs /dev/mapper/vgname-lvname (for ext4)
    # xfs_growfs /dev/mapper/vgname-lvname (for xfs)
    

For further assistance, please open a Red Hat support This content is not included.case.

Notes:

-r, --resizefs
          Resize underlying filesystem together with the logical volume using

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.