Resizing LVM disk on Ubuntu VM

Resizing LVM storage in a 22.04 Ubuntu VM in Proxmox v7.3

So after searching the webs I was trying to resize a proxmox ubuntu vm using LVM storage but wasn’t able to find the exact solution without piecing together a few different sites and fumbling through the steps. I was getting an error disk was in use following this guide how-to-enlarge-an-ext4-disk-on-an-ubuntu-proxmox-vm

The Issue

You can select the VM in proxmox and go to hardware and then select your hard disk then select edit, resize ( can only add additional GB of space and not remove ) once you have your extra GB added you should be gtg right? NOPE. If your like me you don’t like to give to much GB space to a VM if you don’t know exactly what it will be used for in the long run, using a zfs pool of nvme ssd’s is precious resources. You can always add later but not take away very easily. First always make a backup before messing around with any system changes.

Ok so ssh into the Ubuntu VM. In my case was using Ubuntu 22.04 server and was setup on LVM storage using my zfs pool on proxmox.

once in the command line change to root user using sudo su then the below commands.

fdisk -l

noramlly /dev/sda will show hard drive space, your drive could be different like /dev/sdb1, ect..

Take note it will show all partitions like




then do

parted /dev/sda

using /dev/sda will end up showing (parted) waiting for the next command. type the word print and then F

(parted) print

Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 1048576000
blocks) or continue with the current setting?

Fix/Ignore? F         

it will then show you the different numbers you can select. The partition to resize like 1, 2, 3, or however many partions you have on the disk. You will be able to tell as it is normally the larger size. We are only interested in the main partition we added the extra space to.

We will type resizepart ( then select the correct number to resize from above 1,2,3, ect ) mine in this example was 3. Then type 100%

(parted) resizepart 3 100%

To exit out of parted type quit

then use the below commands

lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

and then

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Bingo now your Ubuntu 22.04 VM using LVM storage on proxmox will be correct size. Use the command to see if it worked.

df -h

Here is another guide on Proxmox forums that had some of the pieces to solve this but the above walk through is what I was able to do to get it to work. resize-disk-of-ubuntu-19-10-vm-on-proxmox.70352

This post is licensed under CC BY 4.0 by the author.

© bigsk1. Some rights reserved.

AI | Tech | HomeLab | Crypto | Docker and more 🚀