Out of curiosity: Why is virtual disk compacting not possible like in hyper-v?

AlpsView

New Member
Apr 1, 2025
2
0
1
In Hyper-V, if i want to shrink a vhdx runnig i.e. Ubuntu as guest os, i can shrink the virtual disk by first setting all unused blocks to 0 with sudo fstrim /, shut the vm down and on Powershell run Optimize-VHD virtualdisk.vhdx -Mode Full. Optimize-VHD obv. works by detecting all unused blocks (zeros) which is why fstrim is needed. I have done this a good number of times and it always worked fast and smooth.

Not knowing how this and how virtual disks are working in detail and with no intention for a A is better than B discussion, I'm wondering why this approach wouldn't work with proxmox or better said with the virtual disks we are using in proxmox. It would be a very nice feature to have, as the "gold standard" with cloning to a reduced size disk is just more work and not integrated into the proxmos UI. Again, I'm not complaining, just trying to understand if this is more a "we haven't tried it" or a "can't be done" or a "other things are more imporant" or "...." "issue".
 
Last edited:
I understand, that's freeing up unused space of a dynamic size virtual disk. So that's basically what I described. I need to distinguish between compacting and reducing size. Not the same, even when compacting leads the same result in terms of reduced space needed, since a dynamic disk still can grow to its initial capacity if needed.

So compacting is not a problem, but reducing comes with hurdles and challenges?
 
Last edited:
oh you mean reducing logical size? thats ALWAYS a fraught prospect. having this function integrated into vhdx is nice although I'm not certain it would work for any guest filesystem other then ntfs (not an expert in this;) in any case there is always clone to smaller as an available method.
 
  • Like
Reactions: Johannes S