1FSTRIM(8) System Administration FSTRIM(8)
2
3
4
6 fstrim - discard unused blocks on a mounted filesystem
7
9 fstrim [-Aa] [-o offset] [-l length] [-m minimum-size] [-v] mountpoint
10
11
13 fstrim is used on a mounted filesystem to discard (or "trim") blocks
14 which are not in use by the filesystem. This is useful for solid-state
15 drives (SSDs) and thinly-provisioned storage.
16
17 By default, fstrim will discard all unused blocks in the filesystem.
18 Options may be used to modify this behavior based on range or size, as
19 explained below.
20
21 The mountpoint argument is the pathname of the directory where the
22 filesystem is mounted.
23
24 Running fstrim frequently, or even using mount -o discard, might nega‐
25 tively affect the lifetime of poor-quality SSD devices. For most desk‐
26 top and server systems a sufficient trimming frequency is once a week.
27 Note that not all devices support a queued trim, so each trim command
28 incurs a performance penalty on whatever else might be trying to use
29 the disk at the time.
30
31
33 The offset, length, and minimum-size arguments may be followed by the
34 multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for
35 GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has
36 the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000),
37 and so on for GB, TB, PB, EB, ZB and YB.
38
39
40 -A, --fstab
41 Trim all mounted filesystems mentioned in /etc/fstab on devices
42 that support the discard operation. The other supplied options,
43 like --offset, --length and --minimum, are applied to all these
44 devices. Errors from filesystems that do not support the dis‐
45 card operation are silently ignored.
46
47
48 -a, --all
49 Trim all mounted filesystems on devices that support the discard
50 operation. The other supplied options, like --offset, --length
51 and --minimum, are applied to all these devices. Errors from
52 filesystems that do not support the discard operation are
53 silently ignored.
54
55 -n, --dry-run
56 This option does everything apart from actually call FITRIM
57 ioctl.
58
59 -o, --offset offset
60 Byte offset in the filesystem from which to begin searching for
61 free blocks to discard. The default value is zero, starting at
62 the beginning of the filesystem.
63
64 -l, --length length
65 The number of bytes (after the starting point) to search for
66 free blocks to discard. If the specified value extends past the
67 end of the filesystem, fstrim will stop at the filesystem size
68 boundary. The default value extends to the end of the filesys‐
69 tem.
70
71 -m, --minimum minimum-size
72 Minimum contiguous free range to discard, in bytes. (This value
73 is internally rounded up to a multiple of the filesystem block
74 size.) Free ranges smaller than this will be ignored. By
75 increasing this value, the fstrim operation will complete more
76 quickly for filesystems with badly fragmented freespace,
77 although not all blocks will be discarded. The default value is
78 zero, discarding every free block.
79
80 -v, --verbose
81 Verbose execution. With this option fstrim will output the num‐
82 ber of bytes passed from the filesystem down the block stack to
83 the device for potential discard. This number is a maximum dis‐
84 card amount from the storage device's perspective, because
85 FITRIM ioctl called repeated will keep sending the same sectors
86 for discard repeatedly.
87
88 fstrim will report the same potential discard bytes each time,
89 but only sectors which had been written to between the discards
90 would actually be discarded by the storage device. Further, the
91 kernel block layer reserves the right to adjust the discard
92 ranges to fit raid stripe geometry, non-trim capable devices in
93 a LVM setup, etc. These reductions would not be reflected in
94 fstrim_range.len (the --length option).
95
96 -V, --version
97 Display version information and exit.
98
99 -h, --help
100 Display help text and exit.
101
102
104 0 success
105
106 1 failure
107
108 32 all failed
109
110 64 some filesystem discards have succeeded, some failed
111
112 The command fstrim --all returns 0 (all succeeded), 32 (all failed) or
113 64 (some failed, some succeeded).
114
115
117 Lukas Czerner <lczerner@redhat.com>
118 Karel Zak <kzak@redhat.com>
119
121 blkdiscard(8), mount(8)
122
124 The fstrim command is part of the util-linux package and is available
125 from https://www.kernel.org/pub/linux/utils/util-linux/.
126
127
128
129util-linux July 2014 FSTRIM(8)