fitrim · shipping · also Filesystem trim ioctl

FITRIM

FITRIM is a Linux ioctl that asks a mounted filesystem to discard unused extents according to a requested byte range and minimum free-extent length.

The fields start, len and minlen are unsigned 64-bit integers in the Linux UAPI. The start is filesystem-relative, not an offset within the file used to select the filesystem. fstrim is a userspace caller, not another name for the ioctl or ATA TRIM. [1] [2]

Input len is the requested search length in bytes; after a successful ioctl, fstrim v2.41.2 prints returned len with --verbose. Its dry-run path exits before the ioctl. Neither process success nor that byte count certifies physical reclamation or sanitization. [3] [2]

Do not assume returned minlen is the effective threshold. Linux v6.12 ext4 converts the requested value to allocation units and applies device granularity locally when the requested minimum is smaller. It replaces range.len with its reported byte count while leaving range.minlen unchanged before the ioctl copies the structure back. This implementation detail is not a cross-filesystem guarantee. [4] [5]

Relations

related
Discard, TRIM, Thin provisioning, Deallocated read behavior

Advantages

  • Allows a filesystem to select unused extents instead of indiscriminately discarding a raw device range. [2]

Limitations

  • A returned byte count does not identify unique physical space reclaimed. [2]
  • Parameters and repeat-run behavior depend on the filesystem implementation; ext4 can skip already-trimmed groups. [4]

Citations

  1. Linux v6.12: fstrim_range and FITRIM UAPI (accessed 2026-11-08)
  2. util-linux v2.41.2: fstrim range selection and reporting (accessed 2026-11-08)
  3. util-linux v2.41.2: fstrim invocation and returned-length output (accessed 2026-11-08)
  4. Linux v6.12: ext4_trim_fs minimum conversion and returned length (accessed 2026-11-08)
  5. Linux v6.12: ext4 FITRIM ioctl input and output copy (accessed 2026-11-08)

Further reading

  1. Hesela: Discard is not zeroing (accessed 2026-11-08)

JSON: /data/terms/fitrim.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. FITRIM. Hesela. 2026-11-08. https://hesela.dev/terms/fitrim/