]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/fstrim.8
Merge branch 'rename' of git://github.com/kerolasa/lelux-utiliteetit
[thirdparty/util-linux.git] / sys-utils / fstrim.8
1 .\" -*- nroff -*-
2 .TH FSTRIM 8 "July 2014" "util-linux" "System Administration"
3 .SH NAME
4 fstrim \- discard unused blocks on a mounted filesystem
5 .SH SYNOPSIS
6 .B fstrim
7 .RB [ \-a ]
8 .RB [ \-o
9 .IR offset ]
10 .RB [ \-l
11 .IR length ]
12 .RB [ \-m
13 .IR minimum-size ]
14 .RB [ \-v ]
15 .I mountpoint
16
17 .SH DESCRIPTION
18 .B fstrim
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.
22 .PP
23 By default,
24 .B fstrim
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.
27 .PP
28 The
29 .I mountpoint
30 argument is the pathname of the directory where the filesystem
31 is mounted.
32 .PP
33 Running
34 .B fstrim
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.
39 Note that not all
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.
42
43 .SH OPTIONS
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.
49
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
55 ignored.
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
59 filesystem.
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,
63 .B fstrim
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
72 every free block.
73 .IP "\fB\-v, \-\-verbose\fP"
74 Verbose execution. With this option
75 .B fstrim
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
79 .I FITRIM
80 ioctl called repeated will keep sending the same sectors for discard repeatedly.
81 .sp
82 .B fstrim
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
88 (the
89 .B --length
90 option).
91 .TP
92 .BR \-V , " \-\-version"
93 Display version information and exit.
94 .TP
95 .BR \-h , " \-\-help"
96 Display help text and exit.
97
98 .SH RETURN CODES
99 .IP 0
100 success
101 .IP 1
102 failure
103 .IP 32
104 all failed
105 .IP 64
106 some filesystem discards have succeeded, some failed
107 .PP
108 The command
109 .B fstrim --all
110 returns 0 (all succeeded), 32 (all failed) or 64 (some failed, some succeeded).
111
112 .SH AUTHOR
113 .nf
114 Lukas Czerner <lczerner@redhat.com>
115 Karel Zak <kzak@redhat.com>
116 .fi
117 .SH SEE ALSO
118 .BR mount (8)
119 .SH AVAILABILITY
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/.