How to delete unallocated VM disk space and display the new disk size on proxmox GUI

Raekon

New Member
Jun 4, 2022
3
0
1
On the Proxmox GUI I accidentally increased the disk space of my Ubuntu VM by too much, and now I'm left with 15 GB of unallocated space, as the Gparted screenshot shows. completely unused and never partitioned because I realized my mistake immediately. What is the best way to delete this unallocated space, so both my VM and proxmox itself in the VM settings displays and recognizes the correct disk size I had before mistakenly increasing it in proxmox GUI? (I had 20gb showing in the VM settings, and now it obviously shows 35gb because I increased it by 15gb from there). I'd like to revert this change but I'm not sure what's the way to do it properly and safely.

67653AE3-3E43-4217-8F40-60AE4A880B39.jpeg
40338D75-BA4C-48F8-9C98-97BAFF1A887D.jpeg
 
this thread should be educational for you - the warning in the reply from Proxmox stuff is still in effect, keep it in mind:
https://forum.proxmox.com/threads/decrease-size-of-vm-hard-disk.76293/

The specific steps will depend on your underlying storage pool. You appear to be using LVM, you should google for "shrink lvm volume" and study the articles before running any commands, ie https://www.rootusers.com/lvm-resize-how-to-decrease-an-lvm-partition/.
If the VM is not important, the safest way, for you, is to rebuild it with proper sizes.

In theory, if you are using LVM Thin, as long as you dont write data to that free space (and you wont as long as its not partitioned), then it doesnt matter how big the disk appears in VM - it only takes as much as you've actually written to it.



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Thank you @bbgeek17 for pointing me in the right direction with your helpful reply. After some research, I managed to fix my issue and remove the unallocated space. I'll post the steps here for reference, because some people might find it helpful If they are in the same (and very specific) circumstance.

Let's say you are using LVM Thin and you just increased the VM hard disk size on the Proxmox GUI by going into the VM settings->Hardware-> Hard Disk-> Disk Action->Resize (or if you have done the same thing from the CLI), but you immediately realize after submitting your input that you increased the size by too much by mistake. The fix at this point is very simple, granted you did absolutely no disk/file system management operation on the VM itself, either through the CLI or tools like Gparted, and everything is left untouched over there (even in Gparted when you go and inpect the disk, press Ignore if it asks you if you want to fix the partition table).
Usually when you increase the disk size of a VM, first you have to do it in Proxmox either through the Proxmox GUI or CLI, then you have to input a bunch of other commands on the VM itself so that it can start using the new exra disk space). In case we did not do this second part of the disk enlargement process, and everything is absolutely untouched on the VM itself, you might find yourself in a situation similar to what I have shown in the screenshots in the first post. To remove all the unwanted space:
  1. Shutdown the target VM. I also recommend doing a full backup of the VM in proxmox at this point, so if something somehow goes wrong you can restore everything to its previous state very easily.
  2. In the appropriate Proxmox Node CLI, type lvdisplay to get a list of all the logical volumes on the machine, so we can identify the one that we need to shrink back. Take note of its LV Path.
  3. Type lvreduce -L -<size we want to subtract from volume> <LV Path> . Putting a - before the size will reduce the volume BY the amount you choose. Only as an example, in my case I had to do lvreduce -L -15G /dev/pve/vm-100-disk-0 , but you should input the size and volume path relevant to your specific situation. Make sure not to reduce this volume by more than what the total unallocated space is. It's probably a good idea to reduce it by slightly less than what the total unallocated space is, and leave some unallocated space still on the volume just for safety (it's possible to fix this later on in the VM itself if one wants to use this unallocated space and make things neat again).
  4. Type qm rescan so that Proxmox can notice the new volume size and can display the new disk size correctly in the hypervisor.
If on the other hand you already conducted filesystem/partition management operations on the VM itself, shrinking the disk is a lot more riskier and there are a lot of helpful resources and comments on the forum that can point you in the right direction, including the one above this post. In my case, since I did not go through all the way in the VM disk enlargement process, but stopped after the first step, reverting the changes was way easier and much less risky.
I wish all of this was better documented in the proxmox documentation, however given the complexities of file systems and partitioning, and the dangers associated with modifying these things, I suspect that leaving the documentation a bit vague discourages people that don't really know exactly what they are doing from performing very dangerous operations on their machines. In any case, before doing anything you are not too sure about, backup. End result for my case right below.
3F1A030B-D657-4EA1-8A47-C88FFF098A2F.jpeg6ECAEF6E-AB71-480C-82E6-C0524AE906F8.jpeg
 
Last edited: