2 .TH FSTRIM 8 "July 2014" "util-linux" "System Administration"
4 fstrim \- discard unused blocks on a mounted filesystem
19 is used on a mounted filesystem to discard (or "trim") blocks which are not in
20 use by the filesystem. This is useful for solid-state drives (SSDs) and
21 thinly-provisioned storage.
25 will discard all unused blocks in the filesystem. Options may be used to
26 modify this behavior based on range or size, as explained below.
30 argument is the pathname of the directory where the filesystem
35 frequently, or even using
36 .BR "mount -o discard" ,
37 might negatively affect the lifetime of poor-quality SSD devices. For most
38 desktop and server systems the sufficient trimming frequency is once a week.
40 devices support a queued trim, so each trim command incurs a performance penalty
41 on whatever else might be trying to use the disk at the time.
44 The \fIoffset\fR, \fIlength\fR, and \fIminimum-size\fR arguments may be
45 followed by the multiplicative suffixes KiB (=1024),
46 MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB"
47 is optional, e.g., "K" has the same meaning as "KiB") or the suffixes
48 KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
50 .IP "\fB\-a, \-\-all\fP"
51 Trim all mounted filesystems on devices that support the discard operation.
52 The other supplied options, like \fB\-\-offset\fR, \fB\-\-length\fR and
53 \fB-\-minimum\fR, are applied to all these devices.
54 Errors from filesystems that do not support the discard operation are silently
56 .IP "\fB\-o, \-\-offset\fP \fIoffset\fP"
57 Byte offset in the filesystem from which to begin searching for free blocks
58 to discard. The default value is zero, starting at the beginning of the
60 .IP "\fB\-l, \-\-length\fP \fIlength\fP"
61 The number of bytes (after the starting point) to search for free blocks
62 to discard. If the specified value extends past the end of the filesystem,
64 will stop at the filesystem size boundary. The default value extends to
65 the end of the filesystem.
66 .IP "\fB\-m, \-\-minimum\fP \fIminimum-size\fP"
67 Minimum contiguous free range to discard, in bytes. (This value is internally
68 rounded up to a multiple of the filesystem block size). Free ranges smaller
69 than this will be ignored. By increasing this value, the fstrim operation
70 will complete more quickly for filesystems with badly fragmented freespace,
71 although not all blocks will be discarded. Default value is zero, discard
73 .IP "\fB\-v, \-\-verbose\fP"
74 Verbose execution. With this option
76 will output the number of bytes passed from the filesystem
77 down the block stack to the device for potential discard. This number is a
78 maximum discard amount from the storage device's perspective, because
80 ioctl called repeated will keep sending the same sectors for discard repeatedly.
83 will report the same potential discard bytes each time, but only sectors which
84 had been written to between the discards would actually be discarded by the
85 storage device. Further, the kernel block layer reserves the right to adjust
86 the discard ranges to fit raid stripe geometry, non-trim capable devices in a
87 LVM setup, etc. These reductions would not be reflected in fstrim_range.len
92 .BR \-V , " \-\-version"
93 Display version information and exit.
96 Display help text and exit.
106 some filesystem discards have succeeded, some failed
110 returns 0 (all succeeded), 32 (all failed) or 64 (some failed, some succeeded).
114 Lukas Czerner <lczerner@redhat.com>
115 Karel Zak <kzak@redhat.com>
120 The fstrim command is part of the util-linux package and is available from
121 ftp://ftp.kernel.org/pub/linux/utils/util-linux/.