How to reclaim deleted storage from VM in ESXi 5.5 server
I have some VMs in ESXi 5.5 server. My ESXi server reached its maximum storage.It is showing 4 GB free space. I deleted useless data from one of my VMs about 300GB but ESXi 5.5 server still showing 4 GB space. My all disk of VMs are thin provisioned. How can I fix the issue? I also rebooted ESXi server but no to avail.
Solution 1:
Thin provisioned .vmdk files don't shrink by themselves when data is deleted, they always maintain the size of their maximum fill state.
What you want, reducing the .vmdk size to the actual used space size, is called "thinning".
VMwares knowledge base gives these instructions:
Deletion of files in most file systems will not completely remove them; merely file tables will be altered. Use of freeware secure file deletion utilities are useful, such as Eraser or SDelete to zero out the space to 'zero' the free space on the volume, effectively clearing the free space of data. It is then, that the disk can be properly thinned. You can then use the vmkfstools -K command (ESXi/ESX 4.1 and later) to complete the block reclaim or use Storage vMotion to migrate the virtual machine to a datastore with different VMFS block size.
So:
- Zero out the disk space inside the VM with one of the suggested tools
- Shutdown the VM, otherwise the .vmdk will be locked.
- Run
vmkfstools -K <file.vmdk>
on the local ESXi console or via SSH.
Note that the alternative method, migrating the VMs to a different datastore, only frees up space when the blocksize differs on the datastores!
Afterwards the .vmdk should only have the size of the data currently stored on it.
See the Knowledge Base article for details.
Solution 2:
5.5 is quite old but if you're able to upgrade to 6.0 you can use in-guest UNMAP:
Q. What are the prerequisites required for UNMAP to run?
There are a number of prerequisites which must be met. These are:
- VMDK must be thin provisioned
- Virtual Machine Hardware version must be 11 (ESXi 6.0)
- The advanced setting EnableBlockDelete must be set to 1
- The Guest OS must be able to identify the disk as thin (Windows 2012 [updated 30-Oct-2015] uses the B2 mode page to achieve this)
VSPHERE 6.0 STORAGE FEATURES PART 8: VAAI UNMAP CHANGES
With 6.5, in-guest UNMAP should also work with Linux.