Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Enjoy members-only rewards and discounts
  • Create and access a list of your products

How to Schedule Disk Maintenance for Thin Disks if TRIM on Windows is Disabled

Summary: In a Windows environment where large datasets are frequently deleted and re-created, thin disk drives may suffer from a preceding TRIM or UNMAP activity and TRIM ("fsutil behavior set disabledeletenotify 1") may have to be disabled. This action may lead to the question of how to maintain storage efficiency if TRIM is off. ...

This article applies to   This article does not apply to 

Instructions

Overview

In a Windows environment, if you frequently delete and re-create large datasets (for example: Back up to disk), a preceding delete action may result in a high number of UNMAP commands on the array. If you rewrite the same disk space, your write performance may suffer, because the incoming writes wait for the UNMAPs to be processed, UNMAPs return disk space elements to the disk pool on the array side.

The operating system mechanism that drives this storage efficiency logic is called "TRIM." If TRIM is active, and if you delete a block on the file system, the file system (NTFS) generates meta data about the freed space and passes it down the I/O stack. At the disk level in the I/O stack, a decision is made whether the target disk is ATA-attached. In that case an ATA TRIM command is sent to the physical disk object. If the disk is a SCSI disk, then the TRIM is converted to a SCSI UNMAP.

If you delete and rewrite the same data section again, the storage efficiency aspect of this return-to-pool mechanism is limited. Under these circumstances, you may either have chosen to disable TRIM at NTFS level for the duration for the respective production job, or disable TRIM altogether.

The resulting question is how can you assure that the disks are still space-efficient over the long term?
 

Limitations

To trigger retrim on a device, you usually run the defrag command with the /L option. When you disabled TRIM using "fsutil behavior set disabledeletenotify 1," you may be under the impression that the trim or unmap is only disabled on delete and that the retrim works as expected. This is not the case. The retrim action in defrag is a mechanism that allocates an empty sparse file and then calls FSCTL_MOVE_FILE to move the data. See "Windows Internals 7," "Part II," p. 644 ff for further details. The resulting behavior implies a delete action under the hood. Unfortunately, if disabledeletenotify is "1," the retrim command still succeeds. It does not result in unmaps.

As a result, the sequence to reclaim the storage must include a step to activate TRIM before the defrag is run.

Further, if you have disabled TRIM on the system globally, activate it, defrag and then deactivate it again, the deactivation process may collide with incomplete retrim command execution, although the command has returned to the prompt. When lab-testing this on Windows 2019, we found that we had to wait for a couple of seconds, before setting disabledeletenotify to "1" again. We believe that this is a result of an interaction between the defrag command and the optimizer service in the background.

If you schedule the TRIM using Drive Optimizer, the default Explorer menu requires a scheduled task called "ScheduledDefrag" (/Microsoft/Windows/Defrag) in Task Scheduler. If you modify the task, the Drive Optimizer detects this fact and asks to restore the defaults before you can continue. If you disable the task, you can still run the defrag commands manually, but you cannot schedule them.

This "ScheduledDefrag" task is also called System Maintenance (Control Panel\All Control Panel Items\Security and Maintenance\Automatic Maintenance).
 

Solution

As a result, we recommend that you leave these system default settings as they are and instead consider creating a new task in the task scheduler, that:

  1. Enables TRIM ("fsutil behavior set disabledeletenotify 0")
  2. Runs defrag /l against all drives ("defrag /C /L")
  3. Waits until the resulting commands are submitted to the array ("timeout /t 60")
  4. Disables TRIM again ("fsutil behavior set disabledeletenotify 1")

The timeout value in step 3 is an interpolation of lab tests. We never needed longer than 10 seconds for the defrag to succeed and believe that the 60 seconds are a reasonable starting point. If you find that discrepancies between the array-side allocated capacity values and the file system reported used capacity values build up, try to use a larger value, like 300 seconds (5 minutes).
 

XML Task Template

In the following, we provide a template for you to import into a task scheduler for you to use as a basis. Copy and paste the below xml code to a file, place the file within reach of the server system that you want to configure and use the task import action to import the task. The below task template is called DellSanDiskMaintenance. It runs the above four steps weekly, on a Saturday at 20:00h (8 pm), and is placed in the root of the scheduler, for example:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Source>Dell Technologies</Source>
    <Date>2023-07-07T09:21:50.4883878</Date>
    <Author>Dell Technologies</Author>
    <Description>This task is an example of how to optimize thin SAN drives, if TRIM is globally disabled on the system.</Description>
    <URI>\DellSanDiskMaintenance</URI>
    <SecurityDescriptor>D:AI(A;;FA;;;BA)(A;;FA;;;SY)(A;;FRFX;;;LS)(A;;FR;;;AU)</SecurityDescriptor>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2023-07-01T20:00:00</StartBoundary>
      <ExecutionTimeLimit>PT2H</ExecutionTimeLimit>
      <Enabled>true</Enabled>
      <ScheduleByWeek>
        <DaysOfWeek>
          <Saturday />
        </DaysOfWeek>
        <WeeksInterval>1</WeeksInterval>
      </ScheduleByWeek>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="LocalSystem">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>false</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <MaintenanceSettings>
      <Period>P1D</Period>
      <Deadline>P4D</Deadline>
      <Exclusive>false</Exclusive>
    </MaintenanceSettings>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT4H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="LocalSystem">
    <Exec>
      <Command>%windir%\system32\fsutil.exe</Command>
      <Arguments>behavior set disabledeletenotify 0</Arguments>
    </Exec>
    <Exec>
      <Command>%windir%\system32\defrag.exe</Command>
      <Arguments>/C /L /U</Arguments>
    </Exec>
    <Exec>
      <Command>timeout</Command>
      <Arguments>/t 60</Arguments>
    </Exec>
    <Exec>
      <Command>%windir%\system32\fsutil.exe</Command>
      <Arguments>behavior set disabledeletenotify 1</Arguments>
    </Exec>
  </Actions>
</Task>

 

Affected Products

PowerMax
Article Properties
Article Number: 000215628
Article Type: How To
Last Modified: 09 Aug 2023
Version:  3
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.