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