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