Reclaiming VMFS deleted blocks on Thin Provisioned LUNs

内容

book

Article ID: 323112

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides steps to reclaim unused storage blocks on a VMFS datastore for a thin-provisioned LUN. 

vSphere 5.5 introduced a new command in the esxcli namespace that allows deleted blocks to be reclaimed on thin provisioned LUNs that support the VAAI UNMAP primitive.

You can run the command without any maintenance window, and the reclaim mechanism has been enhanced:

  • Reclaim disk space size can be specified in blocks instead of a percentage value to make it more intuitive to calculate.
  • Dead disk space is reclaimed in increments instead of all at once to avoid possible performance issues.

With the introduction of 62 TB VMDKs, UNMAP can now handle much larger dead space areas. However, UNMAP operations are still manual. This means Storage vMotion or Snapshot Consolidation tasks, for example, on VMFS do not automatically reclaim disk space on the array LUN.

Environment

VMware vSphere ESXi 6.0

VMware vSphere ESXi 6.5VMware vSphere ESXi 6.7

VMware vSphere ESXi 7.#

VMware vSphere ESXi 8.#

Resolution

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.<ID>VAAI Plugin Name: VMW_VAAIP_NETAPPATS Status: supportedClone Status: supportedZero 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=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.

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.<ID>

Notes:

thumb_up Yes

thumb_down No

总结
本文介绍了如何在VMFS数据存储上回收未使用的存储块,特别是针对薄配置LUN的操作。vSphere 5.5引入了esxcli命令,允许在支持VAAI UNMAP原语的薄配置LUN上回收已删除的块。该机制可以在没有维护窗口的情况下运行,并且回收的磁盘空间大小可以以块为单位指定,避免了性能问题。虽然UNMAP操作仍需手动执行,但可以通过esxcli或vmkfstools命令来实现。用户可以通过SSH会话确认LUN是否支持SCSI UNMAP,并使用相应的命令进行回收。命令的使用需要注意默认值和临时文件的生成,建议在执行前咨询存储阵列提供商以获得最佳实践。