Resizing a Proxmox LVM Partition
- Published on
Every so often I find myself needing to resize a Proxmox VM disk and resize the LVM partition, and everytime I forget entirely how to do it. So I thought it's probably best for me to document how I do it so I can reference this when I need it.
The Problem
So you have your Proxmox server setup and your VMs are working perfectly, but one day a VM is misbehaving so you connect via VNC to take a look and it's screaming at you have no available space in /.
It's bound to happen every so often, your VM has been rock-solid stable for years, but you've unknowingly pushed it past your original limits and you use df to confirm your worst fears.
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv 50Gi 50Gi 0 100% /
The Solution
The first step is of course, resizing the disk in Proxmox. This can be done easily via the UI.
The second step is to extend the size of the logical volume to fill the free space:
\# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 50GiB
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
Our final step is to resize the file system itself:
\# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old\_desc\_blocks = 3, new\_desc\_blocks = 25
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 51962880 (4k) blocks long.
And there we have it! Problem solved.