Increasing LVM Partition Size in Proxmox Guest

Qazi Murtaza Ahmed
3 min readDec 8, 2024

--

This guide outlines the steps to increase the size of an LVM (Logical Volume Management) partition on a Proxmox guest machine, assuming it has free space within the existing Volume Group.

Prerequisites:

  • You have a Proxmox guest VM running.
  • You have SSH access to the guest VM.
  • There is free space within the existing Volume Group.

Steps:

  1. Check Disk and Volume Group Information:
  • Use dmesg | grep sda (replace sda with your disk if different) to check if the kernel has detected the increased disk size. You should see a message indicating a capacity change.
[    0.959629] sd 2:0:0:0: [sda] 461373440 512-byte logical blocks: (236 GB/220 GiB)
[ 0.960052] sd 2:0:0:0: [sda] Write Protect is off
[ 0.960416] sd 2:0:0:0: [sda] Mode Sense: 63 00 00 08
[ 0.960452] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 0.964725] sda: sda1 sda2 sda3
[ 0.965509] sd 2:0:0:0: [sda] Attached SCSI disk
[ 3.451244] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[ 203.903185] sd 2:0:0:0: [sda] 463470592 512-byte logical blocks: (237 GB/221 GiB)
[ 203.903254] sda: detected capacity change from 461373440 to 463470592
  • List partitions: Use fdisk -l /dev/sda to display the partition table of your disk (/dev/sda in this case). Identify the partition that holds your LVM Physical Volume (usually the largest).
/dev/sda1     2048      4095      2048    1M BIOS boot
/dev/sda2 4096 4198399 4194304 2G Linux filesystem
/dev/sda3 4198400 356515806 352317407 168G Linux filesystem
  • Display Volume Group information: Use vgs to view the Volume Groups and their free space. Note the name of your Volume Group (e.g., ubuntu-vg).
  VG        #PV #LV #SN Attr   VSize    VFree
ubuntu-vg 1 1 0 wz--n- <168.00g 0

2. Extend the Partition:

  • Usefdisk to extend the partition that holds your LVM Physical Volume:
  • Run sudo fdisk /dev/sda (replace sda with your disk).
  • Type p and press Enter to list partitions. Note the starting sector of the LVM partition (e.g., /dev/sda3).
  • Type d and press Enter to delete the LVM partition.
  • Type n and press Enter to create a new partition.
  • Choose partition type p for primary.
  • Enter the same partition number as the one you deleted.
  • Set the first sector to the starting sector you noted earlier.
  • Set the last sector to use all available space (press enter).
  • Do you want to remove the signature? [Y]es/[N]o: n (if you select ‘y’, it will corrupt your filesystem)
  • Type w and press enter to write the changes.

3. Resize the Physical Volume:

  • Use pvresizeExecute the following command to add all available free space to your Logical Volume
sudo pvresize /dev/sda3
  • (Replace /dev/sda3 with the actual partition if different.)

4. Extend the Logical Volume

  • Use lvextendExecute the following command to resize the filesystem to match the new Logical Volume size:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Again, replace /dev/ubuntu-vg/ubuntu-lv with the path to your Logical Volume.)

5. Resize the Filesystem:

  • Use resize2fs to resize the filesystem:
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

(Replace /dev/mapper/ubuntu--vg-ubuntu--lv with the path to your Logical Volume.)

6. Verify the Changes:

  • Run df -h to confirm that the size of your partition has increased.
  • Backups: Create a backup of your VM before making any disk changes.
  • Online Resizing: resize2fs usually resizes the filesystem online. However, minimize disk activity during the process.

This guide provides a framework. Refer to official documentation for the most accurate information.

--

--

Qazi Murtaza Ahmed
Qazi Murtaza Ahmed

No responses yet