We have all been there. You create a Proxmox Linux VM, give it a massive 300GB disk because you think you will need it for Nextcloud, and then realize you are barely using 30GB. That storage space is valuable and could be used for other VMs in your homelab.
Today I am sharing the specific commands I used to shrink my Docker VM disk from 300GB down to roughly 44GB.
Prerequisites:
- Backup: Do not skip this. Shrinking disks involves manipulating partition tables. If a byte goes missing, your data is gone. Run a backup in Proxmox now.
- Storage Type: This guide is for Proxmox users using LVM or LVM-Thin storage (where disks look like
/dev/pve/vm-104-disk-1).
Step 1: Prepare the Guest VM
First, we need to work inside the Linux VM. We have to shrink the filesystem and the partition before we touch the physical disk on the server.
1. Stop Services and Unmount
We cannot shrink a mounted drive. Since I run Nextcloud via Docker, I need to stop all containers first.
# Stop all running Docker containers
sudo docker stop $(docker ps -q)
# Unmount the target disk (sdb1 in my case)
sudo umount /mnt/nc-data
Verify the disk is unmounted:
md
2. Shrink the Filesystem
Before resizing, we must check the disk for errors. Never resize a dirty filesystem.
# Force a filesystem check
sudo e2fsck -f /dev/sdb1
Now, shrink the filesystem to your target size. I am going for 42GB for the filesystem itself.
sudo resize2fs /dev/sdb1 42G
3. Update the Partition Table
Now we need to tell the OS that the partition ends at the 42GB mark. We use fdisk to delete the old partition and create a new, smaller one in the exact same spot.
sudo fdisk /dev/sdb
Follow these interactive inputs carefully:
- d: Delete the partition.
- n: Create a new partition.
- p: Primary partition.
- 1: Partition number 1.
- 2048: First sector (Press Enter to accept default).
- +42G: Last sector (Type exactly the size you used in resize2fs).
- N: If asked to remove the signature, type N (No).
- w: Write changes and exit.
Note: Once fdisk finishes, it is good practice to run sudo resize2fs /dev/sdb1 one more time just to ensure the filesystem fills the new partition boundaries perfectly.
At this point, your VM sees a small partition, but Proxmox still sees a large 300GB disk.
Step 2: Resize on Proxmox Host
Now switch to your Proxmox Node Shell (not the VM).
1. Identify the Disk
We need to shut down the VM to modify the LVM volume safely.
# Shutdown the VM (ID 104 in this example)
qm shutdown 104
Find the path to your disk. You can look at the config to be sure:
qm config 104
Look for the line describing your disk, e.g., scsi1: local-lvm:vm-104-disk-1.
2. Shrink the LVM Volume
We will reduce the Logical Volume size. Crucial Tip: I always resize the physical container to be slightly larger than the partition inside it to avoid accidental data corruption.
My partition is 42GB, so I will resize the LVM volume to 44GB.
# Reduce the volume size
lvreduce -L 44G /dev/pve/vm-104-disk-1
Confirm “y” when it warns you about data loss.
3. Rescan Configuration
Update Proxmox so the UI reflects the new size.
qm rescan
Step 3: Verify and Finish
Start your VM back up.
qm start 104
Log into your VM and mount the drive:
sudo mount -a
lsblk
You should now see your partition is roughly 42GB, and the physical disk (sdb) is 44GB. You have successfully reclaimed over 250GB of space for your other projects!
