Decrease a VM Disk Size

I've never used LVM before, after trying vgs and vgdisplay, I get nothing on on the screen, the command goes through but just blank.
 
I've never used LVM before, after trying vgs and vgdisplay, I get nothing on on the screen, the command goes through but just blank.

I suggest you start a new thread, but if you used a ZFS-based boot/root instead of ext4 + LVM when you installed Proxmox, you're not even using LVM

You should also do some research into LVM if you want to use it - not having a grasp of the basics and trying commands blindly leads to pitfalls
 
not having a grasp of the basics and trying commands blindly leads to pitfalls
Especially when running commands like lvreduce that might destroy data...especially without the needed prequisites like shrinking filesystems and partitions on that LV first.
Thats also the reason why PVE webUI/API/CLI won't allow you to do that.
 
Last edited:
  • Like
Reactions: Kingneutron
excellent tutorial, a lot of fear but actually it was 2 commands:
Code:
lvm lvreduce -L -32g pve/vm-103-disk-0
qm rescan
and from 64GB it became 32GB
Did the command reduce it by 32G or reduce it to 32G. In this case it is the same answer but I'm looking at different numbers. I couldn't find the syntax definition of "lvreduce" anywhere in the Proxmox admin guide! All I could find was "resize".

In my case I want to reduce it from 100G to 66G (ie. reduce by 34G). Would I use -34g or -66g in the first command? I wasn't sure it the - implied "minus" or simple a dash in the syntax! You'll have to excuse me, but I'm a novice with all of this!

Your assistance is much appreciated.
 
I couldn't find the syntax definition of "lvreduce" anywhere in the Proxmox admin guide!

because thats not a PVE thing. man lvreduce show the docs to that command:

Code:
-L|--size [-]Size[m|UNIT]
    Specifies the new size of the LV.  The --size and
    --extents options are alternate methods of specifying
    size.  The total number of physical extents used will be
    greater when redundant data is needed for RAID levels.
    When the plus + or minus - prefix is used, the value is
    not an absolute size, but is relative and added or
    subtracted from the current size.

so should be -34g.
 
And a warning again, as this is a destructive command:
If you shrink a virtual disk without shinking its partitions and filesystems first, you will lose data. If you want to shrink it by 34GB, the last 34GB should be unallocated on that LV.
 
Last edited:
  • Like
Reactions: Kingneutron
I know this thread is an antique...but I'm kind of in a pickle.

Will Gparted live be able to resize an LVM I accidentally shrank? The VM was having disk issues (100% usage) and showed plenty of space inside the vm.

I now know I made 3 mistakes:
didn't check discard & shut off defrag inside the vm
Over provisioned
Shrank the LVM instead of making it larger (this was my last and fatal mistake)
EDIT: this was in GUI under VM hardware, not LVM command or in storage menu if that helps...I don't know what the underlying commands for that setting are).
Oh, I also moved the VM recently to a larger hard drive(my backup drive) and was getting everything all set up feeling protected by snapshots before I made a new backup
So maybe 6 or 7 mistakes.

Current status: borked
LVM errors out on boot saying it needs manual repair and I have scoured the Internet looking for hope. I added an additional 1tb SSD to VG but it won't extend the LVM because it can't load it.

I have 80+ android VMs running on the guest windows machine (actually not running now) and about 6 months into the project so I would prefer not to wipe it.

I'm betting if I can get in, select discard, and run trim it will fix this issue. Then I'll backup and recreate the VM.

If it helps I have a windows back up of the VM...inside the same container along with 4 worthless snapshots .

Any help would be greatly appreciated
 
Last edited:
I tried to execute the following command just to test shrinking on a cloned OpenMediaVault VM disk as was suggested above, but interestingly, it doesn't have FS.
How can the VM run? What do I miss?

Bash:
root@server:/mnt/storage# lvreduce -r -L 10G /dev/pve/vm-100-disk-1
fsadm: Cannot get FSTYPE of "/dev/mapper/pve-vm--100--disk--1".
  Filesystem check failed.


root@server:/mnt/storage# lsblk -f /dev/pve/vm-100-disk-1
NAME                 FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
pve-vm--100--disk--1

root@server:/mnt/storage# file -L -s /dev/pve/vm-100-disk-1
/dev/pve/vm-100-disk-1: DOS/MBR boot sector
 
Last edited:
Hi Everyone,

I'm new to Proxmox and recently ran into an issue with disk management. Here's the situation:

I created an Ubuntu 24 server VM with an initial disk size of 150 GB. Later, I realized I needed to add an additional 25 GB, but I accidentally extended the disk by 175 GB, bringing the total size to 325 GB.

The issue is that I haven’t allocated the extra disk space to the VM's filesystem yet, but now I need to reduce the disk size back to the correct size.

Here’s some additional info about my setup:

  • LVM is used for the volume management.
  • Below are the outputs of df -h and lsblk commands:

    df -h:


  • Filesystem Size Used Avail Use% Mounted on
    tmpfs 2.0G 8.5M 2.0G 1% /run
    efivarfs 256K 94K 157K 38% /sys/firmware/efi/efivars
    /dev/mapper/ubuntu--vg-lv--0 145G 111G 27G 81% /
    tmpfs 10G 0 10G 0% /dev/shm
    tmpfs 5.0M 0 5.0M 0% /run/lock
    /dev/sda2 2.0G 183M 1.7G 10% /boot
    /dev/sda1 1.1G 6.2M 1.1G 1% /boot/efi


    lsblk:


  • NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
    sda 8:0 0 325G 0 disk
    ├─sda1 8:1 0 1G 0 part /boot/efi
    ├─sda2 8:2 0 2G 0 part /boot
    └─sda3 8:3 0 146.9G 0 part
    └─ubuntu--vg-lv--0 252:0 0 146.9G 0 lvm /
    sr0 11:0 1 2.6G 0 rom



  • What I Need Help With:
    1. Is it possible to reduce the size of the disk back to the desired size (175 GB or 150 GB)?
    2. If yes, what is the safest way to achieve this without affecting the data in the VM?
    3. Any specific steps for LVM would be greatly appreciated.
  • I understand resizing can be risky, so I’m being cautious here and asking for advice before proceeding.

    Thanks in advance for your guidance!
 
> Is it possible to reduce the size of the disk back to the desired size (175 GB or 150 GB)?

No. This is thin-provisioned, so basically you just extend the in-vm disk partition table to whatever is needed and don't worry about the rest, bc it will never grow to that size. And make a note in the VM config for yourself

Otherwise, you create a new vdisk of the appropriate size, copy everything over in-vm, detach the original. Might be more hassle than it's worth