Reclaim space from deleted files on thin Linux vmdk (on VMFS) when guest unmap fails/unavailable
search cancel

Reclaim space from deleted files on thin Linux vmdk (on VMFS) when guest unmap fails/unavailable

book

Article ID: 446393

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

  • Files have been deleted on a thin provisioned Linux VM running on a VMFS datastores

  • Guest level unmap fails to reclaim the space or is unsupported at guest level i.e. the used space within the guestOS reduces reflecting the deletions, but vmdk used space at VMFS datastore level does not 

Environment

VMware vSphere ESXi (all versions)

Resolution

1. Ensure the VM is not running on snapshots 


2. Zero unused blocks on the Linux guestOS:

This may be achieved using a guest level utility, if available, or via dd command:
 
dd if=/dev/zero of=/<mounted-volume>/zeroes
rm -f /<mounted-volume>/zeroes

where <mounted-volume> is the name/path to the volume:

Note: the dd command will create a file of zeroes named "zeroes" which consumes all free space on the disk. This causes the thin disk to inflate to its full provisioned size. The file is then deleted.

3. Power off the VM and, via SSH to the ESXi host, run:


vmkfstools --punchzero /vmfs/vo/umes/<datastore>/<VmName>/<Name>.vmdk

where /vmfs/vo/umes/<datastore>/<VmName>/<Name>.vmdk is the full path to the vmdk. (The command is run against the descriptor file, not the -flat.vmdk file)

Note: The time to complete the process will vary with the size of the disk and number of blocks to be reclaimed.