- User ID
- 1
- Joined
- 7 Jan 2019
- Messages
- 1,315
- Reaction score
- 87
- Points
- 48
Do you have a Linux VM on a Hyper-V with a bloaty .VHDX?
Then you are on the right page, follow these instructions down below:
The idea is you need to TRIM your thin-provisioned drive first before you can compact your .VHDX
Then you are on the right page, follow these instructions down below:
The idea is you need to TRIM your thin-provisioned drive first before you can compact your .VHDX
- Run fstrim on the Linux system.
fstrim has become my personal favourite method when it comes to trimming SSD on Linux systems, here are some of the reasons:- It works very quickly
- It doesn't cause unnecessary wear on SSDs
- It ships in the default tool set of most distributions
- It's ridiculously simple to use
Bash:sudo fstrim /
- Now we need to shut down our Linux VM (I couldn't find any better way than shutting down as Optimize-VHD cmdlet requires full access over the .VHDX while doing its job) -- if you find a better way, please share with us here by commenting down below.
- Run PowerShell as administrator and then run Optimize-VHD on the target .VHDX.
Example Usage:Optimize-VHD 'D:\CANA\Virtual Hard Disks\CANA.vhdx' -Mode Full