Storage Reclamation from SCSI UNMAP command in VMware

Storage Reclamation from SCSI UNMAP command in VMware

VMware supports to reclaim the deleted thin provisioned Storage blocks from UNMAP commands also known as SCSI UNMAP command. This VAAI storage reclamation primitive feature has been introduced in vSphere 5.0 for the first time. This feature was introduced to reclaim deleted blocks effectively from the storage. Initially it was designed to reclaim the space from the storage soon after deleted or migrated a Virtual Machine from the Storage, but there were some issues in this approach and VMware advised to disable this feature in 5.0.

This automatic reclamation process was disabled in ESXi500-201112001 (ESXi 5.0 Patch 02) and ESXi 5.0 Update 1 which means storage vMotion, deletion, snapshot consolidation or any other process stopped the automatic storage reclamation after this patch version and 5.0 U1. It was a manual process in vSphere 5.5 and now it has been automated in vSphere 6.0 with improvements.

What is the meaning of Storage Reclamation in a simple word?

Once you perform an operation like Virtual Machine Deletion, Storage vMotion or Snapshot Consolidation you free up the space of the VMFS datastore from the thin provisioned virtual disks. These operations leave blocks in the storage array allocated and shows as allocated in the capacity. This is due to the array does not know these blocks have been deleted and cleared from the space, storage has to release these blocks to show the actual deleted space in the storage. These UNMAP commands manually inform to the storage array that there are some deleted blocks in the storage array and you are free to clear up the space.

As I mentioned, this was automated in vSphere 5.0 and VMware stopped after experiencing some serious issues. Now again, this has been automated in vSphere 6.5. In vSphere 5.5 it was a manual process and introduced a new command.

esxcli storage vmfs unmap <Volume_Label or UUID>

Previously, in 5.1 it was using vmkfstools -y <percentage_to_reclaim> (however, you won’t be able to see the options in vmkfstools –help option), I have been using these two commands in my environments as I had to work with both 5.1 and 5.5 ESXi hosts.

Let’s see how we can execute these commands in vSphere 5.5 and 5.1 ESXi hosts.

Executing SCSI commands in ESXi 5.5 Host to reclaim the deleted blocks

Open a putty session to an ESXi host and execute the esxcli storage vmfs unmap -l <datastore_name>

I had to cut off the datastore name

This command will take sometime to complete the operation and it depend on the size of the datastore. Once you execute the command .asyncUnmapFile file will be created in the datastore. This file will delete after completion of the operation. In case if the operation is interrupted before the completion, this file left in the datastore and you have to run the command again against the datastore, file will delete once it complete the operation. This is the only option to check the status of the operation.

Executing SCSI UNMAP commands in ESXi 5.1 ESXi hosts

As I mentioned this esxcli commands introduced in vSphere 5.5 and vmkfstools is the command for this UNMAP operation. Change the directory in to the datastore which you need to reclaim and execute vmkfstools -y <percentage_of_the_deleted_blocks_to_reclam> (vmkfstools -y 60)

esxcli command will not work

VMFS 6 new features with automatic space reclamation

In vSphere 6.5 you have the option to set the reclamation priority in the datastore. However you can disable and set the priority only to Low for the reclamation

If you need to turn this automatic reclamation feature off set the priority to None from Low.

Click to rate this post!
[Total: 4 Average: 5]

7 responses

  1. Rajitha Wijekoon Avatar
    Rajitha Wijekoon

    Nice post as always.Thank You

    1. Aruna Lakmal Avatar
      Aruna Lakmal

      Thank You Rajitha!

  2. vijoy Avatar

    Informative, thank you

  3. Wesley Avatar

    Great post. One more question though.
    How do you tell if there is a space that can be reclaimed?
    Can you use a command that will display/list such space on the datastores?

    1. Aruna Lakmal Avatar

      Thanks for the comment!
      As per my knowledge there is no such command and check the dead space of your LUN from a command. In one of the practical scenario we have compared the previous space and the space after running the command to figure out how much savings we made through the UNMAP.

  4. WK Avatar

    Great post. One question.
    How do you tell if such space exists on the datastores?
    Any commands that will show/list it?

    1. Aruna Lakmal Avatar

      Adding to my above reply,
      NFS datastores reclaims the space immediately after deleting the Virtual Machines or data in the LUN. This applies if you use the Thin Provisioned, LUN based VMFS datastore in your environment and you can use UNMAP to reclaim the dead space from your LUN. Hope this answered to your question. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *