Increasing the Size of My Ubuntu VM and Docker LV in Proxmox

I recently ran into some storage issues in my docker container, I was running out of space so none of my containers were playing nice - I should note, that proxmox didn't show any issues, as if unaware of the space the Logical Volume Docker was taking up.
To resolve the issue I had to perform several steps:
- Increase the disk allocation to the Ubuntu VM running Docker
- Recreate the physical partition to use the newly available storage
- Extend the logical volume to make use of the new partition size
Here is a step by step guide to the actions I performed, please be aware I reference my own partitions and volumes, make sure you verify everything you are taking action on to prevent data loss (backup before you proceed!):
Step 1: Increase the Virtual Disk Size in Proxmox
Log in to Proxmox Web Interface:
Open your web browser and log in to the Proxmox web interface.
Select the VM:
Navigate to the VM you want to resize.
Resize the Disk:
- Go to the "Hardware" tab.
- Select the disk you want to resize (usually scsi0, ide0, or virtio0).
- Click on "Resize Disk".
- Enter the additional space you want to add (e.g., +20G to add 20 GB).
- Confirm the resize operation.
Step 2: Verify Disk Space Allocation
Check Disk Layout:
lsblk
Note the partition of interest and the space used versus space available.
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 98G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 49G 0 lvm /
As you can see I have increased my VM from 100GB to 200GB, but I need to extend my logical volume from 49G to take use of the space.
- Recreate The Partition:
To expandsda3
to use the additional space, you'll need to resize the partition and then expand the logical volume and filesystem.
Step 3: Recreate sda3
Partition
- Backup Data: Ensure you have a backup of your data before proceeding.
- Resize
sda3
Usingfdisk
:- Inside
fdisk
:- Press
p
to print the partition table. - Note the starting sector of
sda3
. - Press
d
and then3
to delete the third partition. (don't worry, you wont lose the data as you are just modifying the partition table) - Press
n
to create a new partition. - Select
primary
and partition number3
. - For the first sector, use the same starting sector as the deleted partition.
- For the last sector, accept the default to use all available space.
- Press
w
to write the changes and exitfdisk
.
- Press
- Inside
- Reboot (if necessary): Sometimes, you may need to reboot the system for the kernel to recognize the new partition table.
Start fdisk
on /dev/sda
:
sudo fdisk /dev/sda
Check the Disk Layout: Verify your current disk layout one last time.
sudo lsblk
Step 4: Resize the Physical Volume (PV)
Resize the Physical Volume:
sudo pvresize /dev/sda3
Step 5: Resize the Logical Volume (LV)
Extend the Logical Volume:
- Check the name of the logical volume
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Step 6: Resize the Filesystem
Resize the Filesystem:
For xfs:
sudo xfs_growfs /dev/ubuntu-vg/ubuntu-lv
For ext4:
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
Step 7: Reboot for Good Measure
sudo reboot
Hopefully you are up and running with no data loss! This took me approximately 15 minutes to resolve, but a good 30 minutes of research.