Shrink Thin Provisioned Disk

Here’s a very quick overview over how to shirnk a bloated vmdk.

Check Datastore

Get ID of Datastore:

esxcli storage core device list | grep -B1 '  Display Name:'

Check state of Datastore:

$ esxcli storage core device list -d naa.668a828100177dc6c624663100000006 | grep 'Thin Provisioning\|Attached Filter\|VAAI\|Revision'
   Revision: XXXX
   Thin Provisioning Status: yes
   Attached Filters:
   VAAI Status: supported

$ esxcli storage core device vaai status get -d naa.668a828100177dc6c624663100000006 | grep 'Delete Status'
   Delete Status: supported

Clear File-System

Windows

You can use SDelete by Sysinternals: https://docs.microsoft.com/en-us/sysinternals/downloads/sdelete

sdelete.exe -z C:\

Linux

Create a file containing zeros and fill disk with it:

dd if=/dev/zero of=/[mounted-volume]/zeroes && rm -f /[mounted-volume]/zeroes

Shrink VMDK

Now you can ssh into the esx and “punsh” the zeros:

vmkfstools -K [disk].vmdk

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.