TRIM
The ATA DATA SET MANAGEMENT Trim function tells a device that specified logical block ranges are no longer needed.
TRIM is ATA terminology; SCSI UNMAP and NVMe Dataset Management Deallocate are related operations, not alternate names for the same command. Linux exposes discard above these protocol-specific interfaces. [8] [12] [10]
On Linux, fstrim asks a mounted filesystem to discard ranges it considers unused. Its byte count is potential discard, not newly reclaimed physical space, and repeated runs can report the same ranges. Stack geometry and unsupported lower devices can reduce the ranges reaching storage. Offset and length choose a filesystem byte range. Preserve the requested minimum separately from any verified effective threshold; Linux v6.12 ext4 leaves returned minlen unchanged despite internal conversion and device-granularity adjustment. [14] Record options and per-filesystem results: --dry-run omits FITRIM and --quiet-unsupported can clear an unsupported-filesystem failure status. [10]
NVMe Dataset Management is advisory: command success alone does not prove deallocation. Readback guarantees for actually deallocated blocks are interface-specific, rather than a universal property of the word TRIM. [12]
Relations
- related
- Solid-state drive (SSD), Garbage collection (flash), Serial ATA (SATA), NVMe, Data sanitization, NVMe sanitize, Discard, SCSI UNMAP, Deallocated read behavior, Effective spare factor, FITRIM
Advantages
- Can reduce garbage-collection copying by identifying logical data that no longer needs preservation; the effect depends on workload and controller policy. [1]
Limitations
- Ordinary discard is not secure discard; util-linux documents secure discard as a separate, device-dependent operation that also erases garbage-collection copies. [6, 11]
- Discard can add I/O latency; very frequent trimming is not automatically better for device lifetime. [10]
Citations
- Frankie, Hughes and Kreutz-Delgado (2012): Analysis of Trim Commands on Overprovisioning and Write Amplification, sections 2.1-2.3.2
- util-linux: blkdiscard documentation
- sg3_utils: sg_unmap manual, description
- util-linux 2.41.2: fstrim manual, description and verbose output
- util-linux 2.41.2: blkdiscard manual, secure discard
- NVM Express NVM Command Set 1.1: Dataset Management, sections 3.3.3 and 3.3.3.2.1
- Linux v6.12: ext4_trim_fs minimum conversion and returned length
Further reading
- TRIM
- TechTarget — What is SSD TRIM?
- NVM Express — NVM Command Set Specification (Dataset Management / deallocate)
- Linux storage — discard/TRIM stack discussion (LF slides)
- Hesela: SSD sanitization: why TRIM and a successful command are not enough
- Hesela: Discard is not zeroing
- Hesela: TRIM technology guide