FSTRIM(8)

๐Ÿ’– FSTRIM(8) โ€” the system administration girlie ๐Ÿ’–

okay bestie, welcome to fstrim, section 8 of the manual (system administration, we love a maintenance era). this is the page where we teach your SSD to let go of the stuff it doesn't need anymore. genuinely iconic behavior. ๐Ÿงนโœจ


โœจ NAME โœจ

fstrim โ€” discard unused blocks on a mounted filesystem

๐ŸŒธ SYNOPSIS ๐ŸŒธ

fstrim [-v] [-o offset] [-l length] [-m minimum-size] -A|-a|mountpoint

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so basically, fstrim is what you run on a mounted filesystem to discard (aka "trim") the blocks that the filesystem isn't using. it's giving spring cleaning. it's giving letting go. and it's so useful for solid-state drives (SSDs) and thinly-provisioned storage, no cap. ๐Ÿ’…

by default, fstrim will discard all the unused blocks in the filesystem. and if you wanna be picky about it, the options below let you tweak that behavior based on range or size. choose your own adventure, queen. ๐ŸŽ€

the mountpoint argument is the pathname of the directory where the filesystem is mounted โ€” and it is required when -A, -a, --fstab, or --all are unspecified. don't forget it or she will simply not know where to aim her trim energy. ๐Ÿซถ

โš ๏ธ real talk, bestie: running fstrim frequently, or even using mount -o discard, might negatively affect the lifetime of poor-quality SSD devices. like, that's not a vibe, that's wear. for most desktop and server systems a sufficient trimming frequency is once a week. and heads up โ€” not all devices support a queued trim, so each trim command incurs a performance penalty on whatever else might be trying to use the disk at the time. so like, share the disk. it's a community. ๐Ÿ˜ญ

๐Ÿ‘‘ OPTIONS ๐Ÿ‘‘

first, the lore: the offset, length, and minimum-size arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") โ€” or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB. two whole number systems and she speaks both fluently. bilingual queen. ๐ŸŒˆ

  • -A, --fstab โ€” trims all mounted filesystems mentioned in /etc/fstab on devices that support the discard operation. the root filesystem is determined from the kernel command line if it's missing in the file. the other supplied options, like --offset, --length and --minimum, are applied to all these devices. errors from filesystems that do not support the discard operation, read-only devices, autofs and read-only filesystems are silently ignored. filesystems with "X-fstrim.notrim" mount option are skipped. she's very forgiving, she's just not gonna tell you about it. ๐Ÿ™ˆ
  • -a, --all โ€” trims all mounted filesystems on devices that support the discard operation. the other supplied options, like --offset, --length and --minimum, are applied to all these devices. errors from filesystems that do not support the discard operation, read-only devices and read-only filesystems are silently ignored. go everywhere, say nothing. main character energy. ๐Ÿ’…
  • -n, --dry-run โ€” this option does everything apart from actually call FITRIM ioctl. the dress rehearsal. the run-through. the vibe check. ๐Ÿ”ฅ
  • -o, --offset offset โ€” byte offset in the filesystem from which to begin searching for free blocks to discard. the default value is zero, starting at the beginning of the filesystem. right from the top, always. โญ
  • -l, --length length โ€” the number of bytes (after the starting point) to search for free blocks to discard. if the specified value extends past the end of the filesystem, fstrim will stop at the filesystem size boundary. the default value extends to the end of the filesystem. she knows when to stop. boundaries, we love her. ๐ŸŽ€
  • -I, --listed-in list โ€” specifies a colon-separated list of files in fstab or kernel mountinfo format. all missing or empty files are silently ignored. the evaluation of the list stops after first non-empty file. for example:
--listed-in /etc/fstab:/proc/self/mountinfo.

filesystems with "X-fstrim.notrim" mount option in fstab are skipped. first non-empty file wins, periodt. โœจ

  • -m, --minimum minimum-size โ€” minimum contiguous free range to discard, in bytes. (this value is internally rounded up to a multiple of the filesystem block size.) free ranges smaller than this will be ignored and fstrim will adjust the minimum if it's smaller than the device's minimum, and report that (fstrim_range.minlen) back to userspace. by increasing this value, the fstrim operation will complete more quickly for filesystems with badly fragmented freespace, although not all blocks will be discarded. the default value is zero, discarding every free block. zero chill about discarding, ironically. ๐Ÿ’€
  • -t, --types list โ€” specifies allowed or forbidden filesystem types when used with --all or --fstab. the list is a comma-separated list of the filesystem names. the list follows how mount -t evaluates type patterns. only specified filesystem types are allowed. all specified types are forbidden if the list is prefixed by "no" or each filesystem prefixed by "no" is forbidden. if the option is not used, then all filesystems (except "autofs") are allowed. gatekeeping, but make it configurable. ๐Ÿšช๐Ÿ’–
  • -v, --verbose โ€” verbose execution. with this option fstrim will output the number of bytes passed from the filesystem down the block stack to the device for potential discard. this number is a maximum discard amount from the storage device's perspective, because FITRIM ioctl called repeated will keep sending the same sectors for discard repeatedly.

fstrim will report the same potential discard bytes each time, but only sectors which had been written to between the discards would actually be discarded by the storage device. further, the kernel block layer reserves the right to adjust the discard ranges to fit raid stripe geometry, non-trim capable devices in a LVM setup, etc. these reductions would not be reflected in fstrim_range.len (the --length option). so the number is aspirational, bestie. it's a vision board. ๐Ÿ˜ญ

  • --quiet-unsupported โ€” suppress error messages if trim operation (ioctl) is unsupported. this option is meant to be used in systemd service file or in cron(8) scripts to hide warnings that are result of known problems, such as NTFS driver reporting Bad file descriptor when device is mounted read-only, or lack of file system support for ioctl FITRIM call. this option also cleans exit status when unsupported filesystem specified on fstrim command line. she's not ignoring the problem, she's just not gonna text you about it. ๐Ÿซถ
  • -h, --help โ€” display help text and exit. the "explain it to me like i'm five" button. ๐ŸŒธ
  • -V, --version โ€” display version and exit. ๐Ÿ‘‘

๐Ÿ’€ EXIT STATUS ๐Ÿ’€

  • 0 โ€” success ๐Ÿ’š
  • 1 โ€” failure ๐Ÿ˜ญ
  • 32 โ€” all failed ๐Ÿ’€
  • 64 โ€” some filesystem discards have succeeded, some failed ๐ŸŽญ

the command fstrim --all returns 0 (all succeeded), 32 (all failed) or 64 (some failed, some succeeded). it's giving a group project where some people did the work. ๐Ÿ“


๐ŸŽ€ AUTHORS ๐ŸŽ€

Lukas Czerner <lczerner@redhat.com>, Karel Zak <kzak@redhat.com>

๐ŸŒŸ SEE ALSO ๐ŸŒŸ

blkdiscard(8), mount(8)

๐Ÿ› REPORTING BUGS ๐Ÿ›

for bug reports, use the issue tracker <https://github.com/util-linux/util-linux/issues>.

๐Ÿ“ฆ AVAILABILITY ๐Ÿ“ฆ

the fstrim command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.


and that's the whole page, bestie!! ๐Ÿซถ this little manual lives in util-linux 2.42.4, dated 2026-09-21 โ€” so if you're reading this, hi from the future, go trim responsibly and hydrate. ๐Ÿ’œโœจ๐ŸŒธ

๐Ÿ“ฆ where this page comes from
  • arch rolling: util-linux 2.42.4-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ISC AND LGPL-2.1-or-later AND LicenseRef-PublicDomain
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms