How to resize (shrink) an ext4 partition and disk to fit within a thin-LVM pool in Proxmox

The goal of the steps below is to resize (shrink) the ext4 partition /dev/sda2 and its disk /dev/sda below to 6.9T, so that they fit within the thin-LVM pool sized at 6.95T

Disclaimer: I have no idea what I’m doing, so follow these steps at your own risk.


1. Trim Unused Space

Inside the VM, run:

fstrim -a

This will save time during the disk operations.


2. Boot into GParted Live ISO

Boot the VM using the GParted Live ISO.


3. Resize the Partition

Use the GParted GUI to shrink the partition /dev/sda2 to the smallest size possible, leaving a little headroom.
Example:


4. Shutdown the VM

After resizing, the partition /dev/sda2 will now be smaller, but the disk itself (/dev/sda) will still be the original size. Let’s fix that. Shut down the VM.
Example:
Partition Resized


5. Resize the Disk on the Proxmox Host

On the Proxmox host (hypervisor), resize the VM disk to fit within the thin-LVM pool:

lvreduce -L 6.9T /dev/media/vm-101-disk-0

Replace /dev/media/vm-101-disk-0 with your VM’s disk path.

Why 6.9T? My thin-LVM is 6.95T, so I left a bit of headroom to avoid overcommitting the pool.
Example:


6. Rescan the Disk in Proxmox

Run the following to make Proxmox aware of the new disk size:

qm rescan

Example output:
QM Rescan


7. Attempt to Boot the VM

If you’re lucky, the VM will boot without issues. However, you’ll most likely encounter an error like:

ALERT! /dev/disk/by-uuid/xxxxxxxxx does not exist. Dropping to a shell

If this happens, boot the VM into the GParted Live ISO again. The GParted GUI will show all storage as unallocated, but don’t panic (famous last words).
Example:
Unallocated Storage


8. Fix Partition Errors with gdisk

Open a terminal in GParted and run:

sudo gdisk /dev/sda
  • Type v to verify the disk.
  • You’ll likely see warnings or errors. Follow the on-screen instructions to fix them.
    • For example, I had to go to the expert menu (x), then press e, and so on, until all errors were resolved.
  • Once everything is fixed, type w to write the changes to the disk and press Enter.
    Example:
    Gdisk Fix

9. Resize the Partition Back to Match the Disk

Open the GParted GUI again. This time, you can expand the partition to fill the resized disk.
Example:
Resize Partition to Match Disk


10. Verify the Disk Layout

Check that the disk size and partition size match your desired configuration:

sudo fdisk -l

Example:
Verify Disk Layout


11. Check the Filesystem for Errors

Run a filesystem check to ensure no errors:

e2fsck -f /dev/sda2

12. Reboot the VM

Finally, reboot the VM. It should boot without any issues, and the disk and partition should now be sized as desired.
Example:
Final Result


That wasn’t so hard after all… lol. I hope it helps

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top