Reducing disk size

lngarrett

New Member
Sep 17, 2024
1
0
1
I googled a lot and couldn't find these steps in one place. I beat my head on the wall a bunch with this so I thought others might find this useful. This is how I successfully reduced the boot disk size on Ubuntu.

There's an order of operations that's important:
1. Reduce the filesystem size
2. Reduce the LV size (slightly larger)
3. Reduce the partition (a bit larger yet)
4. Rightsize the pv
5. Reduce the disk size (the largest of all).
6. If desired, expand everything back out to fill the disk.

Code:
# boot live CD to shell
e2fsck -fy /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 28G # smallest size, aim low - you can expand back up later.
lvreduce -L 29G /dev/mapper/ubuntu--vg-ubuntu--lv # slightly bigger

parted /dev/sda
resizepart 3 35436 # 31Gib + 2150 offset from start of disk. lsblk is base2 while parted is base10
quit

pvresize /dev/sda # refits the PV to the partition

# Shutdown VM, switch to proxmox:
lvreduce -L 35G /dev/pve/disk-name # Remember, the disk needs to cover all partions. E.g. boot is 2GB. Give healthy buffer, you can expand into it.
qm rescan --vmid 103

#Back into rescue to fix partition table
gdisk /dev/sda
x #expert (lol, thats me)
e # relocate backup partition table to end of the disk
w # write

# Boot into VM. Expand LV and FS to utilize slack space.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!