Online LVM Capacity Expansion on Running RHEL Virtual Machines
search cancel

Online LVM Capacity Expansion on Running RHEL Virtual Machines

book

Article ID: 431753

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides the steps for extending an existing LVM Volume Group (VG) and Logical Volume (LV) using a newly added virtual disk (VMDK) on a running Red Hat Enterprise Linux (RHEL) 8.x system.

Environment

VMware vSphere ESXi

Resolution

Phase 1: Adding a New VMDK in vSphere

  1. Log in to the vSphere Client.

  2. Right-click the target Virtual Machine and select Edit Settings.

  3. Click ADD NEW DEVICE and select Hard Disk.

  4. Specify the required Capacity (e.g., 100 GB).

  5. Ensure the Disk Provisioning (Thin/Thick) matches your environment's policy.

  6. Click OK to save the settings


Phase 2: LVM Expansion on Guest OS (GOS) Level

  1. Verify the new disk is recognized on GOS using the following command:
    lsblk

    Note: If the disk is not visible, run:

    for host in /sys/class/scsi_host/host*; do echo "- - -" > ${host}/scan; done

     

  2.  Initialize the Physical Volume to prepare the new disk for LVM use:
    pvcreate /dev/sdb

    * Replace /dev/sdb with the actual device name from lsblk

  3. Add the new PV to your existing Volume Group to increase the available capacity:
    # Identify the VG name (e.g., "rhel" or "vg01")
    vgs
    
    # Extend the VG
    vgextend [VG_Name] /dev/sdb

     

  4. Allocate the new space to the target Logical Volume (e.g., /var) and resize the filesystem online:
    # Identify the LV path for /var
    df -h /var
    
    # Extend the LV and resize the filesystem simultaneously
    lvextend -r -l +100%FREE [LV_Path]

    * -r performs the filesystem resize (XFS/Ext4) automatically
    * +100%FREE = Uses all unallocated space in the VG

  5. Confirm size of the target Logical Volum:
    df -h /var