Reclaiming disk space from thin provisioned VMDK files when ESXI Host still sees blocks even after removed from GuestOS
search cancel

Reclaiming disk space from thin provisioned VMDK files when ESXI Host still sees blocks even after removed from GuestOS

book

Article ID: 340005

calendar_today

Updated On: 05-06-2025

Products

VMware vSphere ESXi

Issue/Introduction

This article provides steps to manually reclaim unused disk space by the Guest OS to shrink the thin provisioned disk. For more information, see Storage Space Reclamation.


Symptoms:

Virtual Machines (VM) using thin provisioned disk do not see size decrease after deleting files from the Guest Operating System.
 

 

Environment

VMware vSphere ESXi 8.x

VMware vSphere ESXi 7.x

VMware vSphere ESXi 6.x

Cause

Deleting data from Guest OS only removes the data from the file allocation table but does not zero the blocks. As a result, the ESXi Host still sees the blocks in use even after deleting the data.

Resolution

Note: Reclaiming disk space only works when the blocks on the virtual disk are not in use by the Guest OS. 

Reclaiming disk space is a two steps process

The first step is to delete the blocks on the Guest Operating System then reclaim space on the VMFS datastore. Be sure to follow the bellow steps in order.

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. When multiple partitions exist on a single virtual disk, this step must be performed on all partitions for it to be effective. Otherwise, reclamation will be partial, as 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 
 
Once the free space is filled with zeroes, manually delete the zeroes directory by running the command:
 
   rm -f /zeroes

​​​​​Notes:
  • Be sure to shut down all services which writes to the target volume to avoid running out of space and keep shut down until after step 2 is finished then you may start them.
  • If there are multiple partitions on a single virtual disk, same step needs to be performed on all partitions. Otherwise, the reclamation will be partial because not every data block will be zeroed.

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: 
  • The file used here is descriptor file .vmdk file not the data file -flat.vmdk
  • The process may take longer depending on the size of the disk and number of blocks.

Additional Information

Disclaimer: VMware is not responsible for the reliability of any data, opinions, advice, or statements made on third-party websites. Inclusion of such links does not imply that VMware endorses, recommends, or accepts any responsibility for the content of such sites.