Shrink a thin provisioned VMDK disk

When maintaining a Horizon View environment I like to keep my parent images as small as possible and over time a thin provision disk can start to grow on you if you don’t watch it – be it from downloading installers, updates, or even running disk defrag. While there isn’t a simple, one click button in the View Administrator Console there is a fairly easy manual method using vmfkstools.

Before we can use “vmkfstools” to shrink the VMDK file we must zero out any unused space on the thin provisioned disk. A simple way of doing this is by using a free utility called SDelete from Sysinternals.

  1. Download SDelete onto the VM you want to shrink and run the following command, replacing [DRIVE:] with the actual drive letter to be reduced:
    sdelete.exe -z [DRIVE:]

    Note: In Linux VM’s you’ll want to run this command, replacing [PATH] with the actual path of the storage:

    dd if=/dev/zero of=/[PATH]/zeroes bs=4096 && rm -f /[PATH]/zeroes
  2. Power off the VM and SSH into your ESXi host and navigate to the VMDK’s datastore -> directory and check the VM’s current size by typing:
    Check virtual disk size:

    ls -lh *.vmdk

    current vmdk size
    Check actual size:

    du -h *.vmdk

    actual vmdk size

  3. Now we’ll punch all the zeroed blocks out of the VMDK file by typing, replacing [DISK] with the name of the VM VMDK file:
    vmkfstools --punchzero [DISK].vmdk
  4. Once complete, again check the size by repeating step 2. If all went well you should now have a smaller VMDK file and newly reclaimed space!
    resized vmdk size

If you do this on the parent image of a View Pool the changes won’t be “pushed” out to the VM’s within the Pool until your next recompose.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


  1. I only have the vsphere hypervisor. So then after performing these steps, could I simply do a clone of the changed image with vmkfstool -i -d thin to achieve the same result?


  2. I tried to locate the vmdk file. but couldn’t find. when i tried it says permission denied or cannot locate. could you please guide me to find the vmdk file?

    1. Nuwan, are you able to view the directory listing when going to /vmfs/volumes/ ? Find the folder your VM is located, then CD into it and follow the steps above.

  3. Be aware that sdelete will inflate your thin provisioned disk before it can be shrunk using vmkfstools.
    I was running low on datastore space, so I deleted a bunch of files from a VM, and tried to run sdelete, which resulted in VM stop. Luckily this was just test setup :-)

    So you can’t use this to shrink your VM files if you are already low on datastore space (Chances are your VM will stop because your disks can’t expand enough).

  4. My Linux VM showing 6 GB filesystem size through linux cli using df command but i am unable to reduce the .vmdk size less than 16 GB at esxi cli level. I have used above mentioned workaround at both the levels. the VMOS is thin provisioned. So how i can reduce the 16 GB size for an linux VM .vmdk file. where as in Windows VM there are no such issues.

  5. Hi;
    After performing these steps, I found the vmdk file with new lower size through esxi web console; but within ssh by ls command the file still has its previous size. Although the du command also shows the lower size same as web console. What is the problem?