Reclaiming disk space from thin provisioned VMDK files on ESXi


Step 1: Delete the blocks on the Guest OS

Windows Operating System
  1. Download SDelete Command Line Tool available at https://docs.microsoft.com/en-us/sysinternals/downloads/sdelete
Note: SDelete -z will cause the guest OS to use up 100% of the available space disk during this process while zeroing free space. This will lead to a temporary increase in used space on the datastore.
  1. Open an elevated command prompt.
  2. Run this command
sdelete.exe -z drive_letter:
 
Note: Replace [drive:] with the target disk or partition. Note that when you have multiple partitions on a single virtual disk, you need to do this on all partitions for it to be effective. Otherwise, reclamation will only be partial because not every data block will be zeroed.
Linux Operating Systems:

Linux has different ways to delete the unused blocks, the most common method is to fill the free space with a file of zeroes using the dd command:
 
dd if=/dev/zero of=/mounted-volume/zeroes && rm -f /mounted-volume/zeroes

Notes:

Step 2: Reclaim space on VMFS

  1. Power off the virtual machine.
  2. Log in to the ESXi host using SSH and root credentials.
  3. Navigate to the directory that contains the virtual machine disk using the command:
cd /vmfs/volumes/DATASTORE_NAME/VM_NAME
  1. Run this command:
vmkfstools -K disk_name.vmdk

Notes: 

 

Refs:
https://kb.vmware.com/s/article/2136514
https://kb.vmware.com/s/article/2004155



Article ID: 106
Created On: Sun, Feb 27, 2022 at 4:11 PM
Last Updated On: Sun, Feb 27, 2022 at 4:11 PM
Authored by: Saeed Nobakht [[email protected]]

Online URL: https://www.navel.ir/article/reclaiming-disk-space-from-thin-provisioned-vmdk-files-on-esxi-106.html