Skip to content

Technology card

Shipping

TRIM

ATA TRIM

How unused blocks reach a storage device, what fstrim reports, and why deallocation, zero-filled reads and sanitization need different evidence.

Glossary entry on hesela.dev · JSON record · Discard · Deallocated read behavior �� Deallocation contracts · Sanitization evidence

On this page6 sections

In one minute

TRIM is an ATA operation that tells a storage device which logical block ranges are no longer needed, allowing their storage to be reclaimed without treating file deletion as a physical erase.

A filesystem can mark space free while the device still retains a mapping for its logical addresses. TRIM communicates that those addresses no longer need their previous contents. In NAND flash, pages are programmed and erase blocks are erased; garbage collection may relocate still-valid pages before reusing a block. Releasing obsolete mappings can reduce that work, but it does not promise a fixed throughput or endurance gain. [4] [5] [1]

Keep the command families separate. ATA DATA SET MANAGEMENT with the Trim bit, SCSI UNMAP and NVMe Dataset Management with the Deallocate attribute have related purposes, not interchangeable encodings. Linux discard is the block-stack interface above these operations. A label saying TRIM support does not describe every layer between a filesystem and the media. [3] [6] [7]

On Linux, fstrim asks a mounted filesystem to discard ranges it considers unused. It is different from blkdiscard, which addresses device ranges directly and can destroy live data. Zero-filling and secure discard are also separate blkdiscard options; ordinary discard is neither. Understanding or diagnosing support does not require issuing a destructive command. [7] [8]

Record the invocation options and per-filesystem outcome. In util-linux 2.41.2, --dry-run omits FITRIM, --all and --fstab silently ignore specified unsupported or read-only errors, and --quiet-unsupported also clears the failure exit status for an unsupported filesystem. Process success alone does not prove that the intended filesystem was trimmed. [7]

Treat fstrim's verbose byte count as potential discard, not newly reclaimed physical capacity. Repeated runs can include the same ranges, and reductions deeper in the stack need not appear in the reported amount. Do not add successive reports to estimate unique bytes returned to an SSD or pool. [7]

Schedule and granularity matter. The fstrim manual warns that frequent or online discard can hurt some workloads and suggests weekly operation for many desktop and server systems, not as a universal optimum. Its minimum-length setting skips small free extents, trading coverage for less work. The manual describes minimum adjustment, but the effective threshold must be checked against the filesystem implementation. Offset and length select a byte range within the filesystem, not a raw-device overwrite range. Preserve the selected range and requested minimum; do not assume returned minlen reveals an adjusted value. Linux v6.12 ext4 changes its local threshold but leaves that field unchanged. [12] Linux also exposes discard granularity and hardware/software request limits; those values describe supported requests, not a reclaimed-capacity counter. [7] [9]

A thin pool may reclaim capacity without forwarding the request to its backing device. Linux device-mapper's no_discard_passdown removes thin mappings but stops further discard; ignore_discard instead disables discard support. Passdown configured at table load can also be disabled when the backing device lacks support; inspect the reported pool status. Diagnose the layer whose capacity matters, and keep a pool-allocation observation separate from a claim about physical NAND erasure. [10]

Readback depends on the protocol and state. NVM Command Set 1.1 permits a controller to take no action on Dataset Management ranges. For blocks actually deallocated or unwritten, supported and enabled DULBE selects an error; otherwise DLFEAT describes the specified data pattern, which need not be zero. A completed request alone does not establish which state was reached. [6]

FlashVM (USENIX ATC 2010) illustrates why the timing of discard matters. Its merged-discard policy batches free swap clusters. Its dummy-discard policy instead omits a discard when those clusters are likely to be overwritten soon: the later write invalidates the old mapping. Unlike a real discard, this does not create extra clean blocks in advance. This was a flash-backed virtual-memory design evaluated with an OCZ-Vertex SSD, not a recommendation to overwrite live files or a throughput prediction for current devices. [5]

Encryption adds a policy decision. Linux dm-crypt ignores discard by default; allow_discards enables forwarding but can disclose used-space patterns or filesystem information through identifiable discarded ranges. The documented concern is allocation-pattern leakage; it is not a general confidentiality guarantee. Review the deployment's threat model before enabling it. [11]

Revision 1.0c, dated October 3rd, 2022, shows a maximum case of 256 ranges in Figure 41, Range 0 through Range 255, with Range 255's Starting LBA at bytes 4095:4088. Number of Ranges (NR), Command Dword 10 bits 07:00, is a 0's-based count of 16 byte range sets, and the length in logical blocks field is 1-based. If the controller reports a non-zero Dataset Management Ranges Limit (DMRL), it does not process attributes or context attributes for any range number greater than or equal to that value. A non-zero Dataset Management Range Size Limit (DMRSL) means the controller does not process attributes or context attributes for a logical block whose LBA offset from the starting LBA of the range is greater than or equal to that value. A non-zero Dataset Management Size Limit (DMSL) is a processing limit on the total number of logical blocks for the command. DMRL, DMRSL, and DMSL are all non-zero or all 0h. An unused DMRL set to all bits 1 still leaves 255 of the 256 ranges, because DMRL is 1-based and NR is 0's-based. Section 3.2.3.1.1 prints DMRL 1 or 2, DMSL 1,048, range 0 of 1,024 logical blocks, range 1 of 512 logical blocks, and the first 24 logical blocks of range 1 only as an example, and only when ONCS bit 2 is 1 and DMRSL is at its maximum. When the Deallocated or Unwritten Logical Block error is not enabled, a read is all bytes 0h if DLFEAT bits 2:0 are 001b, all bytes FFh if they are 010b, or either all 0h or all FFh if they are 000b, and that value stays the same until a write. [2]

Interpreting the evidence

Use TRIM for the ATA operation, discard for the Linux block request, and the appropriate protocol name for other interfaces. Reclamation, logical readback and disposal assurance are separate questions.

Match each observation to the question it can answer; none alone is a sanitization certificate.

fstrim exits successfully
Relevant evidenceOptions and per-filesystem results still need inspection. [7]
Not establishedFITRIM ran for every intended filesystem.
Passdown was enabled at load
Relevant evidenceCurrent pool status reports effective forwarding. [10]
Not establishedThe lower device still accepts discard.
fstrim reports bytes
Relevant evidenceFilesystem ranges submitted for potential discard. [7]
Not establishedUnique physical bytes reclaimed.
Thin-pool allocation falls
Relevant evidenceMappings released at the pool layer. [10]
Not establishedDiscard reached the backing device.
A deallocated NVMe range reads zero
Relevant evidenceA result to interpret with DLFEAT and DULBE. [6]
Not establishedAll previous physical copies were erased. [4]
discard_zeroes_data is 0
Relevant evidenceLinux 6.12 documents this attribute as always zero. [9]
Not establishedA working readback-capability test.

Uncertainty notes

  • Reference behavior is scoped to the cited Linux 6.12, util-linux 2.41.2 and NVM Command Set 1.1 documents, not a claim that these are the latest releases.
  • FAST 2011 and FlashVM (2010) supply historical mechanism evidence, not current-drive failure rates or transferable speedup figures.
  • Frankie and colleagues provide a workload model and simulation, not measurements of current SSDs; mapping invalidation and later block erasure are separate steps.
  • This is a source review, not a device benchmark. ATA command naming is corroborated by sg3_utils; no inaccessible ATA standard clause or single invention date is asserted.

Sources

  1. 01Frankie et al. (2012): Trim, overprovisioning and write amplification, sections 2.1-2.3.2 · accessed 2026-10-23
  2. 02NVM Express NVM Command Set 1.0c (2022-10-03), sections 3.2.3.1 and 3.2.3.2.1 · accessed 2026-10-28
  3. 03sg3_utils: sg_unmap manual, DESCRIPTION and ATA DATA SET MANAGEMENT relationship · accessed 2026-10-18
  4. 04Wei et al., FAST 2011: Reliably Erasing Data From Flash-Based Solid State Drives, section 2.2 and section 3.3 · accessed 2026-10-18
  5. 05Saxena and Swift, USENIX ATC 2010: FlashVM, section 4.3 on communicating free clusters and garbage collection · accessed 2026-10-18
  6. 06NVM Express NVM Command Set 1.1: section 3.3, Figure 45 and section 3.3.3.2.1 · accessed 2026-10-21
  7. 07util-linux 2.41.2: fstrim manual, description, minimum extent and verbose output · accessed 2026-10-21
  8. 08util-linux 2.41.2: blkdiscard manual, direct ranges, zeroout and secure discard · accessed 2026-10-21
  9. 09Linux 6.12: stable sysfs block ABI, discard limits and discard_zeroes_data · accessed 2026-10-21
  10. 10Linux 6.12: device-mapper thin provisioning, ignore_discard and no_discard_passdown · accessed 2026-10-21
  11. 11Linux 6.12: dm-crypt, allow_discards and information leakage · accessed 2026-10-21
  12. 12Linux v6.12: ext4_trim_fs minimum conversion and returned length · accessed 2026-11-08

Published by Hesela team

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. TRIM. Hesela. https://hesela.com/tech/trim/