Note: If you are using datastores as VMFS-6 in ESXi 6.5 or above, this article is not applicable.
There are two ways in which the disk space reclamation tasks could be invoked:
- Using the esxcli command
- Using the vmkfstools command
To confirm if SCSI UNMAP is supported on a LUN, open an SSH session to an ESXi host and run this command:
esxcli storage core device vaai status get -d naa.##############You see output similar to:
naa.60a98000572d54724a346a6170627a52
VAAI Plugin Name: VMW_VAAIP_NETAPP
ATS Status: supported
Clone Status: supported
Zero Status: supported
Delete Status: supported
Using the esxcli command
To reclaim unused storage blocks on a VMFS datastore for a thin-provisioned device, run this command:
esxcli storage vmfs unmap --volume-label=volume_label|--volume-uuid=volume_uuid --reclaim-unit=numberi.e. specify the volume by label
or uuid:
-l|--volume-label=volume_label
The label of the VMFS volume to UNMAP. -u|--volume-uuid=volume_uuid
The UUID of the VMFS volume to UNMAP. optionally specify:
-n|--reclaim-unit=number
The number of VMFS blocks to UNMAP per iteration. If it is not specified, the command uses a default value of 200.For example, for a VMFS volume named
MyDatastore with UUID of
509a9f1f-4ffb6678-f1db-001ec9ab780e, run this command:
esxcli storage vmfs unmap -l MyDatastoreor
esxcli storage vmfs unmap -u 509a9f1f-4ffb6678-f1db-001ec9ab780eNotes:
- The default value of 200 for the -n number or --reclaim-unit=number argument is appropriate in most environments, but some array vendors may suggest a larger or smaller value depending on how the array handles the SCSI UNMAP command.
- This command creates temporary hidden files at the top level of the datastore, with names using the .asyncUnmapFile pattern. By default, the space reservation for the temporary files depends on the block size of the underlying VMFS file system (the default is --reclaim-unit=200):
- 200 MB for 1 MB block VMFS3 / VMFS5
- 800 MB for 4 MB block VMFS3
- 1600 MB for 8 MB block VMFS3
- Depending on the use case, you can select a different --reclaim-unit value, for example, if the reserved size is considered to be too large or if there is a danger that the UNMAP primitive may not be completed in a timely manner when offloaded to an array. VMware recommends that you consult with your storage array providers on the best value or best practices when manually defining a --reclaim-unit value.
- If the UNMAP operation is interrupted, a temporary file may be left on the root of a VMFS datastore. However, when you run the command against the datastore again, the file is deleted when the command completes successfully. The .asyncUnmapFile will never grow beyond the --reclaim-unit size.
Using the vmkfstools command
Alternatively, you could use
vmkfstools with the switch
-y to reclaim unused storage blocks. Historically, this command could only be used to reclaim only a certain percentage of space, but now, this has been tweaked to accommodate blocks.
The use case would be as follows:
vmkfstools -y --reclaimBlocks /vmfsPath
[--reclaimBlocksUnit #blocks]Example :
vmkfstools -y --reclaimBlocks 200 /vmfs/devices/disks/naa.6589cfc00000056ef3af090272007105Notes: