7

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.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
user420966
  • 71
  • 1
  • 2

3 Answers3

9

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:

  1. Zero out the disk space inside the VM with one of the suggested tools
  2. Shutdown the VM, otherwise the .vmdk will be locked.
  3. 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.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
  • Or if they have a licence for Storage vMotion they can just SvM the VM to a different datastore - maintaining thinning - and the moved VM will be smaller. Edit - sorry, only just spotted you'd mentioned this but I'll still leave my comment as it clarifies that option I believe. – Chopper3 Jun 21 '17 at 08:22
1

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.

Mario Lenz
  • 1,612
  • 9
  • 13
0

I use the vSphere Client to export the VM as an OVF Template. Then, remove the VM from the host and deploy the OVF Template. Make sure you choose thin provision during deployment. As a bonus, you'll have a VM backup on your local or network drive. This method works on the free version of ESXi.

kkenwort
  • 1
  • 1
  • 1
    How excatly is this _hack_ better than the official _thinning_ method? – Esa Jokinen Jun 21 '17 at 12:00
  • It's easy to understand and remember. It doesn't require an OS specific utility to zero out the blocks. It doesn't require ssh to be enabled. It is flexible, it can thin, convert thick to thin, and convert thin to thick. It is safe, the thinned VM can be deployed before the bloated one is deleted. – kkenwort Jun 27 '17 at 14:37