Skip to main content

Extend LVM after VM Disk resize

To extend LVM in a Linux VM after a disk resize in Proxmox, resize the partition, expand the Physical Volume (

), and extend the Logical Volume (

). The core commands to run inside the VM are growpart /dev/sda 2 (adjust device), pvresize /dev/sda2, and lvresize -l +100%FREE /dev/mapper/vg-lv.


Steps to Extend LVM After Proxmox Disk Resize
  1. Resize Disk in Proxmox: Go to the VM's Hardware tab, select the hard disk, click Resize, and add the desired amount.
  2. Scan for New Space (Inside VM): The VM might not see the space immediately. Rescan the SCSI bus:
    bash
    echo 1 > /sys/class/block/sda/device/rescan
    # Replace sda with your disk identifier found via lsblk
    
  3. Expand Partition (If needed): Use growpart to expand the partition containing the LVM PV. For example, if LVM is on /dev/sda2:
    bash
    growpart /dev/sda 2
    
    If growpart is not installed, use apt install cloud-utils-growpart or yum install cloud-utils-growpart.
  4. Resize Physical Volume (PV): Tell LVM the partition is larger:
    bash
    pvresize /dev/sda2
    
  5. Extend Logical Volume (LV): Extend the LVM to use all new free space:
    bash
    lvextend -l +100%FREE /dev/mapper/vgname-lvname
    # Use 'lvs' to find your correct volume group/logical volume name
    
  6. Resize Filesystem: Update the filesystem to use the new space.
    • For ext4: resize2fs /dev/mapper/vgname-lvname
    • For XFS: xfs_growfs /