Reputation: 151
I use Hyper-V on Windows 2016 Server and the problem is with size of Linux Virtual Machine's VHDX files. They are growing up in light speed. For instance I have Linux Mint and In Disk Usage Utility I see 125,4 GB available/133,7 GB total. The vhdx file is 40GB.
What I tried: - shrink in Hyper-V, - use e4defrag in VM, - use dd if=/dev/zero of=wipefile bs=1M; sync; rm wipefile in VM.
After above instead 39GB I have 40GB. Any suggestions? What should I do?
Upvotes: 0
Views: 2950
Reputation: 151
After couple of hours I found the solution.
cat /dev/zero > zero.file
sync
rm zero.file
Shutdown the machine.
Open command prompt on Hyper-V machine and type:
diskpart
select vdisk file="D:\Hyper-V\somedisk.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
Voila! The VHDX file is reduced in my case from 40GB to 18GB.
Upvotes: 3