LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

fstrim

SSD TRIM command issuer

TLDR

Trim all mounted partitions
$ sudo fstrim -a
copy
Trim specific partition
$ sudo fstrim /
copy
Trim with verbose output
$ sudo fstrim -v /
copy

SYNOPSIS

fstrim [OPTIONS] mountpoint

DESCRIPTION

fstrim discards unused blocks on a mounted filesystem, sending TRIM commands to the underlying storage device. This is primarily useful for SSDs and flash storage to maintain performance and extend device lifespan.

PARAMETERS

-a, --all

Trim all mounted filesystems that support discard
-v, --verbose
Display number of bytes trimmed
-n, --dry-run
Print what would be done without actually trimming
-o, --offset offset
Byte offset in filesystem to start trimming
-l, --length length
Number of bytes to trim after offset
-m, --minimum size
Minimum contiguous free range to trim

CAVEATS

Only works on filesystems whose underlying storage supports discard (most SSDs, NVMe, thin-provisioned devices). Running too frequently provides no benefit; a weekly schedule via the fstrim.timer systemd unit is typical. Continuous discard mount option is an alternative but generally less efficient than periodic fstrim.

HISTORY

fstrim is part of the util-linux package, providing TRIM support for SSD optimization on Linux systems.

SEE ALSO

blkdiscard(8), mount(8)

Copied to clipboard
Kai