How to reduce the size of an LVM disk on a Debian system on Proxmox and an underlying EXT4 disk

Background

I’ve never reduced the size of a disk. Everywhere you read up about it there are huge disclaimers that it can break your system, so I’ve stayed away. But this time I really needed to shrink the size of a disk. The reason is the disk is almost 4TB big, and most of the data has been removed. I don’t want to reinstall the operating system, so reducing the size of the disk was the only way.

Every situation is different, and here is mine

  • LVM
  • Ext4
  • Root is boot is root partition is everything. I don’t ever partition disks as it’s old school crap that’s not relevant for 99% of my workloads.
  • Debian operating system, but I’m sure if you have LVM and EXT4 on other operating systems, it might work. (you have a backup right?)

At first I thought about doing this with a live CD but that failed. The reason is when Proxmox deletes information it doesn’t actually delete it but rather¬† just makes it zeros. This is for performance reasons. So even though you’re not using that space, the moment you run space reduction utilities you’ll end up with massive performance problems. For example, my disk was stored on an iSCSI NAS, and when I ran lvreduce inside the VM, it took forever and maxed out the NAS disk. Eventually I aborted after reading that the defragmentation and reallocation of data can take around 16 hours from 4 TB to 1 TB.

In the end, after much more googling, I found one article that spells it out, but still with a lot of complexity and ambiguity:

https://forum.proxmox.com/threads/decrease-a-vm-disk-size.122430/

In the end, I gave up. It took too much time and was too risky.

There are other people, that have however, figured this out and made the tutorials more clear:

https://dallas.lu/pve-reduce-ubuntu-vm-disk-size/

Traditional Method

Note: If you’re using Proxmox, don’t follow this method.

You can’t do this live or when the partition is mounted so you’ll have to install an Ubuntu 24.04 live Desktop ISO. As of 29 June 2024 this ISO is a whopping 5.7 GB which is really a major pain in this process, but since all the guides I found said “get a live CD” I stuck with it.

Terminology is key to understanding reduction. For example, these are all intermingled but all of them might mean something else:

  • Disk
  • File system
  • Physical disk
  • Underlying physical disk
  • Partition
  • Logical volume

Next boot the CD on the machine with the disk you want to reduce. This is easy with Proxmox.

After many clicks, you’ll get to a ‘try Ubuntu’ step.

Next battle through configuring the network.

Next, try this (it didn’t work on my system):

sudo -i
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
apt-get update
apt-get install system-config-lvm

Then go to a terminal and let’s reduce from 4 TB to 1 TB:

Unmount

umount /dev/mapper/pbs-root

Check

This took around 3 minutes:

e2fsck -f /dev/mapper/pbs-root

Reduce

This took around 20 minutes

lvreduce --resizefs -L 1024G /dev/mapper/pbs-root (this took around 20 minutes)

Next, read here:

https://pve.proxmox.com/wiki/Shrink_Qcow2_Disk_Files

See Also

https://askubuntu.com/questions/196125/how-can-i-resize-an-lvm-partition-i-e-physical-volume

 

 

 

Share this article

Leave a Reply

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

Scroll to Top