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.<ID>
VAAI Plugin Name: VMW_VAAIP_NETAPP
ATS Status: supported
Clone Status: supported
Zero Status: supported
Delete Status: supported
SCSI UNMAP is not supported on a local datastore if you see a output similar to:
naa.<ID>
VAAI Plugin Name:
ATS Status: unsupported
Clone Status: unsupported
Zero Status: unsupported
Delete Status: unsupported
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=number
i.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-########-####-########780e, run this command:
esxcli storage vmfs unmap -l MyDatastore
or
esxcli storage vmfs unmap -u 509a9f1f-########-####-########780e
Notes:
- 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.
- The esxcli storage vmfs unmap command does not utilize the Zero Page Reclaim function. During the UNMAP process, ESXi sends SCSI UNMAP commands to the storage array, notifying it of free blocks that can be deallocated. The array must then execute the necessary zero-page/zero-block operations internally to complete the reclamation process. If the zero-page operations fail or are inefficient at the array level, an alternative is to use the FStrim command within the guest operating system. However, the exact end-to-end workflow and support for this method should be confirmed with the SAN array vendor.
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 /vmfsPath
[--reclaimBlocksUnit #blocks]
Example :
vmkfstools -y --reclaimBlocksUnit 200 /vmfs/volumes/vmfsPath
Notes: