I was working in my lab to create a new Windows 2012R2 Template that I can use. Since it is in my Lab and only have so much SSD space (lucky to have my Lab on SSD Drives 🙂 ) I wanted to makes sure that after the all the patches for Windows 2012R2 is loaded and I did a disk cleanup that I could have the least amount of space used by my new Template. I scratched around to find a util that I could use to do a “Zero out of free space” and found Sdelete. After reading a few blogs on how other people have used sdelete I was ready to use the following command:
- sdelete.exe -c
Well that did not work to well for me as there was a change in the way sdelete -c worked. So -c would write out the free space with random data. Anyway…so I saw that -z was the correct option. But now my thin disk was a thick disk. So I followed the following way to get my newly created Thick VMDK Thin again.
Then I ran sdelete.exe -c from within the OS and the VMDK basically inflated to full size:
Next was to run sdelete.exe -z to Zero Out all the free space inside the OS:
After this the VMDK is still at 40Gb ..only the free space have been Zeroed out. No we need to power down the VM and from the ESXi cmd line we need to run vmkfstools -K virtualmachinevmdk.vmdk. In my case the command was : vmkfstools -K Test.vmdk. Note the K is caps. -K will “Punch Holes” in the free spaces that have been Zeroed out.
After all this you can power on the VM and your VMDK will be thin.
In my case I saved about 3Gb on my template.