Tonight on my ESXi host I noticed that I accidentally created a virtual machine with a thick-provisioned disk of 127 GB which was only using 13 GB, so I wanted to free up the 114 GB for other VMs.
The following instructions were extremely useful in resolving this problem:
- Turn off the VM which contains the thick-provisioned drive.
- Log into ESXi (I used an
ssh
connection). - Convert the thick .vmdk file into a thin one:
vmkfstools -i SERVERNAME.vmdk -d thin thinSERVERNAME.vmdk
- Rename the original .vmdk flat file:
mv SERVERNAME-flat.vmdk orig-SERVERNAME-flat.vmdk
- Rename the new thin-provisioned flat file to replace the old one:
mv thinSERVERNAME-flat.vmdk SERVERNAME-flat.vmdk
- Unregister the VM, and re-register it so that it picks up the new .vmdk file.
- Start up the VM to make sure all drives are available.
- Delete the original .vmdk files to free up space.
rm thinSERVERNAME.vmdk
rm orig-SERVERNAME-flat.vmdk
This is based on a post I found on the VMware community site, modified for my own use. Thanks to mabedfo for the content.