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
- Resize Disk in Proxmox: Go to the VM's Hardware tab, select the hard disk, click Resize, and add the desired amount.
- 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 - Expand Partition (If needed): Use
growpartto expand the partition containing the LVM PV. For example, if LVM is on/dev/sda2:bash
Ifgrowpart /dev/sda 2growpartis not installed, useapt install cloud-utils-growpartoryum install cloud-utils-growpart. - Resize Physical Volume (PV): Tell LVM the partition is larger:
bash
pvresize /dev/sda2 - 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 - Resize Filesystem: Update the filesystem to use the new space.
- For ext4:
resize2fs /dev/mapper/vgname-lvname - For XFS:
xfs_growfs /
- For ext4: