I have tried a truckload of guides, but neither seems to work properly. My issue is the following:
- I have a host with 1TB SSD drives
- The VMs barely use ~50G/150G of space (when checked with
df -h
), yet, they consume 170 and 260gb of space respectively on the disk. - I have the Hyper-V guest services enabled in the VMs.
- They keep growing.
Host OS: Windows Server 2022 Datacenter 21H2
Guest OS: Ubuntu 22.04.1 (ext4 root partition)
The latest guide I tried was this: https://helgeklein.com/blog/faster-trimming-compacting-hyper-v-ubuntu-vms/
In short:
- Issue on VMs:
sudo fstrim -v /
- Shut down VMs
- Issue from PowerShell (change the path in command so it matches your vhdx folder):
gci -File -Filter *.vhd* -Path D:\VMs -Recurse | % {Mount-VHD $_.FullName -ReadOnly; Optimize-VHD $_.FullName -Mode full; Dismount-VHD $_.FullName}
But, it does not really work. Didn't shed all that much from my VMs at all, unfortunately. The command did run for a few minutes, the NVMe SSD was spiking really high and that's about it.
It's just annoying because the SSDs are not in RAID, and if the VMs keep growing, I'll just run out of space, which is not so simple to add on a server.
Thank you.