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

EXIT STATUS

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

AUTHORS

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

SEE ALSO

137       blkdiscard(8), mount(8)
138

REPORTING BUGS

140       For bug reports, use the issue tracker at
141       https://github.com/karelzak/util-linux/issues.
142

AVAILABILITY

144       The fstrim command is part of the util-linux package which can be
145       downloaded from Linux Kernel Archive
146       <https://www.kernel.org/pub/linux/utils/util-linux/>.
147
148
149
150util-linux 2.37.2                 2021-07-20                         FSTRIM(8)
Impressum