Procedure to Enable TRIM/UNMAP
search cancel

Procedure to Enable TRIM/UNMAP

book

Article ID: 326595

calendar_today

Updated On:

Products

VMware vSAN

Issue/Introduction

  • Reclaim unused blocks from Guest OS level
  • Enabling TRIM / UNMAP on vSAN
  • VMs which are already running  before enabling the UNMAP, require a power cycle to apply the UNMAP setting. 
  • VMs that are created after UNMAP will be applied with the UNMAP setting by default 

Impact/Risks:

Per VMware by Broadcom best practices it is recommended to enable TRIM/UNMAP on vSAN however, post enabling TRIM/UNMAP for the fist time on a cluster already in production we recommend restarting VMs in batches to avoid a cluster wide performance impact to the cluster.

In larger environments, it is possible for a huge number of blocks inside multiple VMs ( at guest OS level ) to be deleted around the same time, which can impact performance of the cluster. For example a batch process run on multiple VMs to delete a large amount of data inside the guest OS, the burst of IOPS coming from the VMs to caching device(s) will cause congestion on caching device(s) causing a performance impact.


Enabling TRIM/UNMAP feature on all the VMs at the same time may impact production depending on workload and thus it is not recommended to power cycle all the VMs at the same time.
Once you enable the feature on the VMs it will automatically start reclaiming the space and it cannot be stopped. 

NOTE:

Prior to enabling TRIM/UNMAP for the first time on your cluster ensure your cluster is running ESXi version 7.0U3l or higher to avoid the known issues with TRIM/UNMAP as outlined in the below KBs:

vSAN high LLOG consumption leading to LogCongestion

If you have TRIM/UNMAP enabled and running an ESXi version below 7.0U3l we recommend you upgrade to 7.0U3l or higher to avoid the known issues with TRIM/UNMAP as outlined in the above KBs.

 

Environment

VMware vSAN 7.x
VMware vSAN 8.x
Vmware ESXi 7.x
Vmware ESXi 8.x

Resolution

Steps to Enable TRIM/UNMAP :

Step 1 :
TRIM/UNMAP is enabled per vSAN cluster using the RVC Console 

login as: administrator@vsphere.local to vCenter server in cli

Command> rvc administrator@vsphere.local@localhost
Next, browse to compute, and identify the cluster name.

Welcome to RVC. Try the 'help' command.
0 /
1 localhost/
> ls
0 /
1 localhost/
> cd 1
/localhost> ls
0 vSAN-DC (datacenter)
/localhost> cd 0
/localhost/vSAN-DC> ls
0 storage/
1 computers [host]/
2 networks [network]/
3 datastores [datastore]/
4 vms [vm]/
/localhost/vSAN-DC> cd 1
/localhost/vSAN-DC/computers> ls
0 vSAN-Cluster (cluster): cpu 37 GHz, memory 108 GB
/localhost/vSAN-DC/computers>


RVC Command: vsan.unmap_support [ -e/-d ]
-e —enable unmap support on vSAN cluster
-d —disable unmap support on vSAN cluster.

Before running this command make sure the vSAN cluster is healthy, and all hosts are connected to the vCenter. Please check vSAN health before running the task ( Host & Cluster view > vSAN cluster > Monitor > Health ( skyline Health ) > Run test. (About the vSAN Skyline Health

Step 2 : Power cycle the VMs to apply the unmap setting

Note : Below prerequisite must meet before selecting the VMs to be power cycled

  • A minimum of virtual machine hardware version 11 for Windows
  • A minimum of virtual machine hardware version 13 for Linux 

Step 3 : Run the trim/UNMAP for the corresponding OS 

For Windows :

Automated Space Reclamation

Windows Server 2012 and newer support automated space reclamation. This behavior is enabled by default. To check this behavior, the following PowerShell can be used. 

Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\FileSystem" -Name DisableDeleteNotification

To enable automatic space reclamation this value the following:

Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\FileSystem" -Name DisableDeleteNotification -Value 0

For linux :

There are two primary means of reclaiming thin provisioning. 

1. fstrim is used on a mounted filesystem to discard (or "trim") blocks which are not in use by the filesystem.  This is useful for thinly-provisioned storage. ( ex. fstream -v <File System Mount Point > )

2. blkdiscard is used to discard device sectors.  Unlike strip(8), this command is used directly on the block device. blkdisacrd is known to have more performance overhead than fstrim. As a result, fstrim is recommended over blkdiscard.


As of vSAN 8.x you can enable TRIM/UNMAP via the vCenter Web Client via vSAN Advanced Settings.

 

 

  • In order to check if TRIM/Unmap is enabled on cluster level, user can use the following command on ESXi host:

esxcli system settings advanced list -o /VSAN/Unmap
     Path: /VSAN/Unmap
     Type: integer
     Int Value: 1
     Default Int Value: 1
     Min Value: 0
     Max Value: 1
     String Value:
     Default String Value:
     Valid Characters:
     Description: Whether Unmap feature is turned on

 

vsish -e get /config/VSAN/intOpts/Unmap
Vmkernel Config Option {
     Default value:1
     Min value:0
     Max value:1
     Current value:1
     hidden config option:1
     Description:Whether Unmap feature is turned on
}

 

  • In order to check if TRIM/Unmap is enabled on Guest OS level, user can use the following command on ESXi host:

 esxcli system settings advanced list -o /VSAN/GuestUnmap
     Path: /VSAN/GuestUnmap
     Type: integer
     Int Value: 0   >>>> Disable= 0, Enable = 1 
     Default Int Value: t 
     Min Value: 0
     Max Value: 1
     String Value:
     Default String Value:
     Valid Characters:
     Description: Whether Guest Unmap feature is turned on

 

vsish -e get /config/VSAN/intOpts/GuestUnmap
Vmkernel Config Option {
     Default value:0
     Min value:0
     Max value:1
     Current value:0   >>>> Disable= 0, Enable = 1 
     hidden config option:1
     Description:Whether Guest Unmap feature is turned on

 

  • User can monitor UNMAP Activity from vCenter Web Client, statistics are available at vSAN Cluster > Monitor > vSAN Performance > Backend > UNMAP

 

Additional Information