How to shrink roaming profile (VHDX)


1. Mount VHDX (direct in windows over explorer). (example vhdx je saved to D:\temp\test.vhdx, a mounted drive is G:)

2. If you want, delete the files you do not need (temp, desktop, download, WER, …), or skip this step.

3. (from sysinternals) run sdelete64.exe -z G: (mark empty block as zero)

4. Use Windows Defrag to drive G: (clean the space)

5. Umount drive G:

6. run diskpart

6a).  select vdisk file=”d:\temp\test.vhdx”

6b). Compact vdisk (and exit from diskpart)

The free space may be more than 90%.. (over 1 GB VHDX my experience from 25-90%).