[ad_1]
It’s easy enough to compact a VHDX file attached to a Windows VM: Just shut down the VM, then edit the disk and specify “Compact” as the action:
But for Linux VMs, Hyper-V doesn’t understand the disk contents as well (at all?) so you have to add an extra step. From a command prompt (sudo required), run “fstrim” for the volume(s) you want to shrink (e.g. “fstrim /opt” because I want to shrink my half-terabyte volume that churns through Windows update content). Then you can shut down the OS in the VM, compact the disk, and start the VM back up again.
Of course the savings will vary based on the file churn on the disk. In my case, I was able to free up nearly 200GB, which gives me breathing room for a while. (It’s sad that I can still run out of disk space with 6TB of disk space attached to my Hyper-V server. And yes, this is a self-serving post so I can find this more easily the next time I need to do this.)
[ad_2]
Source link