1FSTRIM(8)                    System Administration                   FSTRIM(8)
2
3
4

NAME

6       fstrim - discard unused blocks on a mounted filesystem
7

SYNOPSIS

9       fstrim [-Aa] [-o offset] [-l length] [-m minimum-size] [-v mountpoint]
10

DESCRIPTION

12       fstrim is used on a mounted filesystem to discard (or "trim") blocks
13       which are not in use by the filesystem. This is useful for solid-state
14       drives (SSDs) and thinly-provisioned storage.
15
16       By default, fstrim will discard all unused blocks in the filesystem.
17       Options may be used to modify this behavior based on range or size, as
18       explained below.
19
20       The mountpoint argument is the pathname of the directory where the
21       filesystem is mounted.
22
23       Running fstrim frequently, or even using mount -o discard, might
24       negatively affect the lifetime of poor-quality SSD devices. For most
25       desktop and server systems a sufficient trimming frequency is once a
26       week. Note that not all devices support a queued trim, so each trim
27       command incurs a performance penalty on whatever else might be trying
28       to use the disk at the time.
29

OPTIONS

31       The offset, length, and minimum-size arguments may be followed by the
32       multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for
33       GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has
34       the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000),
35       and so on for GB, TB, PB, EB, ZB and YB.
36
37       -A, --fstab
38           Trim all mounted filesystems mentioned in /etc/fstab on devices
39           that support the discard operation. The root filesystem is
40           determined from kernel command line if missing in the file. The
41           other supplied options, like --offset, --length and --minimum, are
42           applied to all these devices. Errors from filesystems that do not
43           support the discard operation, read-only devices, autofs and
44           read-only filesystems are silently ignored. Filesystems with
45           "X-fstrim.notrim" mount option are skipped.
46
47       -a, --all
48           Trim all mounted filesystems on devices that support the discard
49           operation. The other supplied options, like --offset, --length and
50           --minimum, are applied to all these devices. Errors from
51           filesystems that do not support the discard operation, read-only
52           devices and read-only filesystems are silently ignored.
53
54       -n, --dry-run
55           This option does everything apart from actually call FITRIM ioctl.
56
57       -o, --offset offset
58           Byte offset in the filesystem from which to begin searching for
59           free blocks to discard. The default value is zero, starting at the
60           beginning of the filesystem.
61
62       -l, --length length
63           The number of bytes (after the starting point) to search for free
64           blocks to discard. If the specified value extends past the end of
65           the filesystem, fstrim will stop at the filesystem size boundary.
66           The default value extends to the end of the filesystem.
67
68       -I, --listed-in list
69           Specifies a colon-separated list of files in fstab or kernel
70           mountinfo format. All missing or empty files are silently ignored.
71           The evaluation of the list stops after first non-empty file. For
72           example:
73
74           --listed-in /etc/fstab:/proc/self/mountinfo.
75
76           Filesystems with "X-fstrim.notrim" mount option in fstab are
77           skipped.
78
79       -m, --minimum minimum-size
80           Minimum contiguous free range to discard, in bytes. (This value is
81           internally rounded up to a multiple of the filesystem block size.)
82           Free ranges smaller than this will be ignored and fstrim will
83           adjust the minimum if it’s smaller than the device’s minimum, and
84           report that (fstrim_range.minlen) back to userspace. By increasing
85           this value, the fstrim operation will complete more quickly for
86           filesystems with badly fragmented freespace, although not all
87           blocks will be discarded. The default value is zero, discarding
88           every free block.
89
90       -v, --verbose
91           Verbose execution. With this option fstrim will output the number
92           of bytes passed from the filesystem down the block stack to the
93           device for potential discard. This number is a maximum discard
94           amount from the storage device’s perspective, because FITRIM ioctl
95           called repeated will keep sending the same sectors for discard
96           repeatedly.
97
98           fstrim will report the same potential discard bytes each time, but
99           only sectors which had been written to between the discards would
100           actually be discarded by the storage device. Further, the kernel
101           block layer reserves the right to adjust the discard ranges to fit
102           raid stripe geometry, non-trim capable devices in a LVM setup, etc.
103           These reductions would not be reflected in fstrim_range.len (the
104           --length option).
105
106       --quiet-unsupported
107           Suppress error messages if trim operation (ioctl) is unsupported.
108           This option is meant to be used in systemd service file or in
109           cron(8) scripts to hide warnings that are result of known problems,
110           such as NTFS driver reporting Bad file descriptor when device is
111           mounted read-only, or lack of file system support for ioctl FITRIM
112           call. This option also cleans exit status when unsupported
113           filesystem specified on fstrim command line.
114
115       -h, --help
116           Display help text and exit.
117
118       -V, --version
119           Print version and exit.
120

EXIT STATUS

122       0
123           success
124
125       1
126           failure
127
128       32
129           all failed
130
131       64
132           some filesystem discards have succeeded, some failed
133
134       The command fstrim --all returns 0 (all succeeded), 32 (all failed) or
135       64 (some failed, some succeeded).
136

AUTHORS

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

SEE ALSO

141       blkdiscard(8), mount(8)
142

REPORTING BUGS

144       For bug reports, use the issue tracker at
145       https://github.com/util-linux/util-linux/issues.
146

AVAILABILITY

148       The fstrim command is part of the util-linux package which can be
149       downloaded from Linux Kernel Archive
150       <https://www.kernel.org/pub/linux/utils/util-linux/>.
151
152
153
154util-linux 2.38.1                 2022-05-11                         FSTRIM(8)
Impressum