Extending a logical volume and filesystem online in RHEL after disk resize

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

  • How do I make the extended size visible in PV and VG after extending the size of the existing disk?
  • When the existing vmdk disk is extended in ESX, PV and VG does not detect the new size.
  • How can I increase the size of my physical volume without rebooting?

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.


  1. Extend the disk in question (/dev/sdx) from the storage side, then rescan the device:
# echo 1 > /sys/block/sdx/device/rescan 

Verify the new size:

# lsblk
  1. Determine how the disk is used, check whether the disk is partitioned:
# lsblk

Proceed according to one of the following scenarios:

Scenario A: Disk is not partitioned (PV directly on /dev/sdx)
No partition changes are required. Resize the physical volume:

# pvresize /dev/sdx

Scenario B: Disk has a single partition that will be extended
Extend the existing partition to use all available space:

# parted /dev/sdx resizepart 1 100%

Resize the physical volume on the partition:

# pvresize /dev/sdx1

Scenario C: Disk has existing partitions, and a new partition will be created
Create a new partition using the free space:

# parted /dev/sdx u s p (to check the current configuration)
# parted /dev/sdx

Create a PV on the new partition:

# pvcreate /dev/sdx2 

Extend the VG:

# vgextend vgname /dev/sdx2
  1. Extend the logical volume using the newly available free space. The following example extends the logical volume to use all new free space in the volume group:
# lvextend -l +100%FREE /dev/vgname/lvname
  1. 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

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.