Extending a logical volume and filesystem online in RHEL using a new disk
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
lvextendwhich shows the extension in volume groupvgdisplay, butdfisn'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
lvextendcommand 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, andresize2fscommands - How to grow an XFS filesystem with
pvcreate,vgextend,lvextend, andxfs_growfscommands - I have extended the logical volume size with
lvextendcommand, 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).
-
Create a
PVfrom a free disk or partition (e.g./dev/sdN1as a partition):# pvcreate /dev/sdN1 -
Extend the
VG(/dev/sdN1is an existingPVpath):# vgextend vgname /dev/sdN1 -
Extend the
LV(/dev/vgname/lvnameis the existingLVpath). Example of commands:# lvextend -L +125G /dev/vgname/lvname # lvextend -l +100%FREE /dev/vgname/lvname -
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:
- If the filesystem is GFS2, refer to: How do I grow a GFS2 file-system on RHEL?.
- Once an XFS filesystem is extended, it cannot be reduced: How to reduce XFS file system
- The
lvextendcommand supports resizing the filesystem automatically using the-roption. From the man page:
-r, --resizefs
Resize underlying filesystem together with the logical volume using
- If you are extending the size of the existing disk (
PV) instead of adding a new disk, please refer to the solution: - If you are extending the existing disk rather than adding a new disk (
PV) to extend the logical volume, please refer to the corresponding solution: Extending a logical volume and filesystem online in RHEL after disk resize.
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
- See the following man pages and manuals:
man pvcreate 8man vgextend 8man lvextend 8man resize2fs 8man xfs_growfs 8- RHEL5: Logical Volume Manager Administration LVM Administrator's Guide
- RHEL6: Logical Volume Manager Administration LVM Administrator's Guide
- RHEL7: Logical Volume Manager Administration LVM Administrator's Guide
- RHEL8: Configuring and managing logical volumes
- RHEL9: Configuring and managing logical volumes
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.