How Windows 11 Uses TRIM to Optimize SSDs
Solid-state drives (SSDs) require proactive management to prevent write-performance degradation over time, which Windows 11 achieves by automatically sending TRIM commands to the drive controller. Through a combination of real-time file system notifications and scheduled background optimization routines, Windows 11 informs the SSD which data blocks are no longer in use, allowing the drive’s internal garbage collection processes to clear NAND flash cells in advance and maintain peak read and write speeds.
The Role of TRIM in SSD Storage
Traditional hard disk drives can overwrite existing data in a single operation, but SSDs cannot overwrite data directly. Instead, NAND flash memory must erase entire blocks of data before writing new data to individual pages within those blocks. Without TRIM, an SSD is unaware that a file has been deleted in the operating system until it attempts to write new data to those specific sectors, triggering a slow read-modify-write cycle. The TRIM command bridges this communication gap between the operating system and the SSD controller.
Real-Time Command Execution via the Storage Stack
Windows 11 handles TRIM dynamically during standard operation. When you delete a file, empty the Recycle Bin, or format a partition using NTFS or ReFS:
- File System Notification: The file system identifies the specific logical block addresses (LBAs) associated with the deleted data and marks them as free space.
- Driver Communication: The Windows storage stack
(via the
Storportdriver and the storage controller miniport) translates this action into an industry-standard command. For SATA SSDs, it sends the ATAData Set Management(TRIM) command; for NVMe drives, it issues the NVMeDataset Management(Deallocate) command. - Controller Execution: The SSD’s internal controller receives these LBAs and flags the physical NAND pages as invalid. During idle periods, the SSD’s garbage collection consolidates the remaining valid data and erases the invalid blocks in advance, ensuring fresh blocks are ready for immediate writing.
Scheduled Maintenance via Drive Optimization
In addition to real-time commands, Windows 11 includes a scheduled maintenance feature called “Optimize Drives” (formerly Disk Defragmenter). By default, Windows runs this utility weekly.
When Optimize Drives runs on an SSD, it does not perform traditional defragmentation, which causes unnecessary wear on flash memory. Instead, it performs a process called “ReTrim.” This scans the entire volume for any deleted space that might have been missed during real-time operations—such as during high I/O workloads where immediate TRIM commands were queued or dropped—and issues a bulk TRIM command to ensure the entire drive remains synchronized.
Verifying TRIM Status in Windows 11
Windows 11 enables TRIM automatically whenever it detects a compatible solid-state drive. You can verify that TRIM is active through the Windows Terminal or Command Prompt:
- Open PowerShell or Command Prompt as an Administrator.
- Run the command:
fsutil behavior query DisableDeleteNotify - If the output displays
0for NTFS or ReFS, TRIM is enabled and actively communicating with your SSD. If it returns1, TRIM is disabled.