VMware – Shrink Thin Provisioned Disk

VMware3DgraphicPop quiz, hotshot.  You drag your butt into work on Monday after a weekend of decompressing action packed fun and you reluctantly commence with your morning system checks.  Unfortunately, that pesky warning threshold on a VMware thin provisioned disk that you have been ignoring for several weeks has finally past its critical threshold.  What do you do?  What do you do?

STEP #1:  Defrag the target disk on the Windows Virtual Machine


warning:  READ the information below Before Running Defrag!
  • /X     Perform free-space consolidation.  Free-space consolidation is useful if you need to shrink a volume, and it can reduce fragmentation of future files.
  • You cannot schedule to defragment a Solid State Drive (SSD) or a volume on a Virtual Hard Disk (VHD) that resides on an SSD.
  • A volume must have at least 15% free space for defrag to completely and adequately defragment it.
  • By default, defrag displays a summary of both the analysis and defragmentation reports if you do not specify the /a or /v parameters.
  • You can send the reports to a text file by typing >FileName.txt, where FileName.txt is a file name you specify.
    Example:  defrag c: /v>FileName.txt
  • To interrupt the defragmentation process, at the command line, press CTRL+C

STEP #2:  Download “SDelete” by Mark Russinovich at Windows Sysinternals

Click here to Read more about “SDelete”

Click here to Download now


STEP #3:  Zero Free Space of the target disk on the Windows Virtual Machine


Example:  sdelete -z d:
  • This command will zero out any free space on your thin provisioned disk by filling any unused space on the specified drive with zero-blocks.
  • This process will increase the size of the vmdk.  Don’t worry!  We will shrink it down later.
  • Please be patient This process is not quick.

STEP #4:  Shutdown the Windows Virtual Machine

  • Shutting down the virtual machine will release the lock on the .vmdk file by the ESXi host.

STEP #5:  connect to the VMware ESXi Host

  • Open a PuTTY session to the ESXi Host with logon as root.

STEP #6:  Search for the .VMDK File

  • Search command:  find / | grep vmdk

 STEP #7:  Punch Zeros!  Shrink that Disk!

  • Shrink command:  /user/sbin/vmkfstools –K /vmfs/volumes/***/diskname.vmdk
  • This process will decrease the size of the vmdk.  Nice!
  • Please be patient This process is not quick.
  • Wait for Eagerly zeroing:  100% done.

STEP #8:  Power-up the Windows Virtual Machine – You’re Done!


“What else do you got?”  Stay tuned . . .

Facebook Comments