Here are the steps to convert a thick VMDK file to thin. Steps 2-4 are optional, but if you want to shrink it down as small as possible then don’t skip them!
- Evaluate how much space you have on the datastore. You will be creating 2 copies of the .vmdk file before we’re all done, so don’t fill up the datastore and crash all the VMs!
- Within the VM run a defrag of the disk. (this is optional but recommended)
- Download MS Windows Sysinternals ‘SDelete’ exe to the VM: http://technet.microsoft.com/en-us/sysinternals/bb897443
- Run ‘sdelete -c’ on the the disk. This will zero out unused space.
- Power offthe VM and make a note of what what datastore(s) the virtual disks are on and what they are named.
- SSH in to (or go the console of) the ESXi host and go to the path where the .vmdk files are. (Somewhere under /vmfs/volumes/ )
- Convert the original thick .vmdk into a 2GBspare one:
vmkfstools -i SERVERNAME.vmdk -d 2gbsparse SERVERNAME-temp.vmdk
(This will clone the file while shrinking it down)
- Now convert it again from the 2gbspare temp .vmdk to a thin disk. (If you convert straight to a thin disk and skip the 2gbsparse conversion it will not shrink!)
vmkfstools -i SERVERNAME-temp.vmdk -d thin SERVERNAME-thin.vmdk
- Now edit the settings of the VM and detach the thick drives and attach the thin drive(s). Boot the VM and make sure everything is working.
- Delete the thick and temp 2gbspare .vmdk files.