Disk shrink on ESXi guests

  1. Zero all unused space inside the VM:

    dd if=/dev/zero bs=1048576 of=/zero ; sync ; rm /zero

  2. Do the same with other mount points, swap partitions, etc.
  3. Shut down the VM.
  4. SSH to ESXi, and issue this command:

    vmkfstools -K /vmfs/volumes/volumename/vmname/vmname.vmdk

This will take some time… vmkfstools “punches holes” inside your VMDK, e.g. deallocates all blocks that are filled with zeros, effectively shrinking your VMDK.

 

http://serverfault.com/questions/398162/disk-shrink-does-not-work-on-esxi-guests