Skip to content

Instantly share code, notes, and snippets.

@rh917
Created December 17, 2018 20:14
Show Gist options
  • Save rh917/bde95cf399d27cbce40d2ac4100880cc to your computer and use it in GitHub Desktop.
Save rh917/bde95cf399d27cbce40d2ac4100880cc to your computer and use it in GitHub Desktop.
ResizeRootLV


How do I resize the root LV after installation on Red Hat Enterprise Linux?

SOLUTION VERIFIED - Updated March 13 2018 at 7:49 AM -

English

Environment

  • Red Hat Enterprise Linux
  • The root partition is an LVM logical volume.

Issue

  • How do I resize the root LV after installation on Red Hat Enterprise Linux?

Note: Resizing non-LVM root partitions is not covered in this document and is not supported by Red Hat Global Support Services.

Resolution

  • Determine which Logical Volume provides the root (/) device, in the example below the /dev/mapper/VolGroup-lv_root device provides root.

Raw

 [root@host ~]# df -h /
 Filesystem                    Size  Used Avail Use% Mounted on
 /dev/mapper/VolGroup-lv_root  360G  212G  130G  62% /

  • Verify the free Physical Extents (PE) in the Volume Group in which the Logical Volume is residing.

Raw

 [root@host ~]# vgdisplay VolGroup | egrep 'PE Size|Free  PE'
   PE Size               4.00 MiB
   Free  PE / Size       109467 / 427.61 GiB

  • After confirming the free Physical Extents (PE), resize the Logical Volume by the desired amount by specifying the number of extents to extend by with the -l flag or by specifying a size to extend by via the -L flag. For example:

Raw

 [root@host ~]# lvextend -l +125 /dev/mapper/VolGroup-lv_root
   Extending logical volume lv_root to 365.13 GiB
   Logical volume lv_root successfully resized

OR

Raw

 [root@host ~]# lvextend -L +500M /dev/mapper/VolGroup-lv_root 
   Extending logical volume lv_root to 365.62 GiB
   Logical volume lv_root successfully resized

  • Resize the mounted filesystem.

Red Hat Enterprise Linux 4

  • The resize2fs command in the e2fsprogs rpm could only be used on an unmounted filesystem in RHEL4 system, but after RHEL5, it could be used to extend a mounted filesystem.

Raw

 [root@host ~]# ext2online /dev/VolGroup/lv_root

Red Hat Enterprise Linux 5.x and 6.x

Raw

 [root@host ~]# resize2fs /dev/mapper/VolGroup-lv_root 

Red Hat Enterprise Linux 7.x (XFS Filesystem)

For xfs filesystem we need to run xfs_growfs instead of resize2fs.

Please refer the article for more information How to grow/extend XFS filesytem using xfs_growfs command?

Raw

 [root@host ~]# xfs_growfs /dev/VolGroup/lv_root

Note: If you miss this step, no error will occur, however only the logical volume size will increase, thus when you mount the filesystem it will still be the same size.
or
Adding -r will grow filesystem after resizing the volume.

Raw

# lvextend -L +500M /dev/mapper/VolGroup-lv_root -r

  • More information on increasing the size of logical volumes in general can be found here:

How to extend a logical volume and its filesystem online in Red Hat Enterprise Linux?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment