OSDN Git Service

f67e3691c42df3ac453bb40bc116af3eb8ed0d2b
[linuxjm/jm.git] / manual / util-linux / original / man8 / fstrim.8
1 '\" t
2 .\"     Title: fstrim
3 .\"    Author: [see the "AUTHOR(S)" section]
4 .\" Generator: Asciidoctor 2.0.15
5 .\"      Date: 2022-02-14
6 .\"    Manual: System Administration
7 .\"    Source: util-linux 2.37.4
8 .\"  Language: English
9 .\"
10 .TH "FSTRIM" "8" "2022-02-14" "util\-linux 2.37.4" "System Administration"
11 .ie \n(.g .ds Aq \(aq
12 .el       .ds Aq '
13 .ss \n[.ss] 0
14 .nh
15 .ad l
16 .de URL
17 \fI\\$2\fP <\\$1>\\$3
18 ..
19 .als MTO URL
20 .if \n[.g] \{\
21 .  mso www.tmac
22 .  am URL
23 .    ad l
24 .  .
25 .  am MTO
26 .    ad l
27 .  .
28 .  LINKSTYLE blue R < >
29 .\}
30 .SH "NAME"
31 fstrim \- discard unused blocks on a mounted filesystem
32 .SH "SYNOPSIS"
33 .sp
34 \fBfstrim\fP [\fB\-Aa\fP] [\fB\-o\fP \fIoffset\fP] [\fB\-l\fP \fIlength\fP] [\fB\-m\fP \fIminimum\-size\fP] [\fB\-v\fP \fImountpoint\fP]
35 .SH "DESCRIPTION"
36 .sp
37 \fBfstrim\fP is used on a mounted filesystem to discard (or "trim") blocks which are not in use by the filesystem. This is useful for solid\-state drives (SSDs) and thinly\-provisioned storage.
38 .sp
39 By default, \fBfstrim\fP will discard all unused blocks in the filesystem. Options may be used to modify this behavior based on range or size, as explained below.
40 .sp
41 The \fImountpoint\fP argument is the pathname of the directory where the filesystem is mounted.
42 .sp
43 Running \fBfstrim\fP frequently, or even using \fBmount \-o discard\fP, might negatively affect the lifetime of poor\-quality SSD devices. For most desktop and server systems a sufficient trimming frequency is once a week. Note that not all devices support a queued trim, so each trim command incurs a performance penalty on whatever else might be trying to use the disk at the time.
44 .SH "OPTIONS"
45 .sp
46 The \fIoffset\fP, \fIlength\fP, and \fIminimum\-size\fP arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
47 .sp
48 \fB\-A, \-\-fstab\fP
49 .RS 4
50 Trim all mounted filesystems mentioned in \fI/etc/fstab\fP on devices that support the discard operation. The root filesystem is determined from kernel command line if missing in the file. The other supplied options, like \fB\-\-offset\fP, \fB\-\-length\fP and \fB\-\-minimum\fP, are applied to all these devices. Errors from filesystems that do not support the discard operation, read\-only devices and read\-only filesystems are silently ignored.
51 .RE
52 .sp
53 \fB\-a, \-\-all\fP
54 .RS 4
55 Trim all mounted filesystems on devices that support the discard operation. The other supplied options, like \fB\-\-offset\fP, \fB\-\-length\fP and \fB\-\-minimum\fP, are applied to all these devices. Errors from filesystems that do not support the discard operation, read\-only devices and read\-only filesystems are silently ignored.
56 .RE
57 .sp
58 \fB\-n, \-\-dry\-run\fP
59 .RS 4
60 This option does everything apart from actually call \fBFITRIM\fP ioctl.
61 .RE
62 .sp
63 \fB\-o, \-\-offset\fP \fIoffset\fP
64 .RS 4
65 Byte offset in the filesystem from which to begin searching for free blocks to discard. The default value is zero, starting at the beginning of the filesystem.
66 .RE
67 .sp
68 \fB\-l, \-\-length\fP \fIlength\fP
69 .RS 4
70 The number of bytes (after the starting point) to search for free blocks to discard. If the specified value extends past the end of the filesystem, \fBfstrim\fP will stop at the filesystem size boundary. The default value extends to the end of the filesystem.
71 .RE
72 .sp
73 \fB\-I, \-\-listed\-in\fP \fIlist\fP
74 .RS 4
75 Specifies a colon\-separated list of files in fstab or kernel mountinfo format. All missing or empty files are silently ignored. The evaluation of the \fIlist\fP stops after first non\-empty file. For example:
76 .sp
77 \fB\-\-listed\-in /etc/fstab:/proc/self/mountinfo\fP.
78 .RE
79 .sp
80 \fB\-m, \-\-minimum\fP \fIminimum\-size\fP
81 .RS 4
82 Minimum contiguous free range to discard, in bytes. (This value is internally rounded up to a multiple of the filesystem block size.) Free ranges smaller than this will be ignored and fstrim will adjust the minimum if it\(cqs smaller than the device\(cqs minimum, and report that (fstrim_range.minlen) back to userspace. By increasing this value, the fstrim operation will complete more quickly for filesystems with badly fragmented freespace, although not all blocks will be discarded. The default value is zero, discarding every free block.
83 .RE
84 .sp
85 \fB\-v, \-\-verbose\fP
86 .RS 4
87 Verbose execution. With this option \fBfstrim\fP will output the number of bytes passed from the filesystem down the block stack to the device for potential discard. This number is a maximum discard amount from the storage device\(cqs perspective, because \fIFITRIM\fP ioctl called repeated will keep sending the same sectors for discard repeatedly.
88 .sp
89 \fBfstrim\fP will report the same potential discard bytes each time, but only sectors which had been written to between the discards would actually be discarded by the storage device. Further, the kernel block layer reserves the right to adjust the discard ranges to fit raid stripe geometry, non\-trim capable devices in a LVM setup, etc. These reductions would not be reflected in fstrim_range.len (the \fB\-\-length\fP option).
90 .RE
91 .sp
92 \fB\-\-quiet\-unsupported\fP
93 .RS 4
94 Suppress error messages if trim operation (ioctl) is unsupported. This option is meant to be used in systemd service file or in cron scripts to hide warnings that are result of known problems, such as NTFS driver reporting \fIBad file descriptor\fP when device is mounted read\-only, or lack of file system support for ioctl FITRIM call. This option also cleans exit status when unsupported filesystem specified on fstrim command line.
95 .RE
96 .sp
97 \fB\-V\fP, \fB\-\-version\fP
98 .RS 4
99 Display version information and exit.
100 .RE
101 .sp
102 \fB\-h\fP, \fB\-\-help\fP
103 .RS 4
104 Display help text and exit.
105 .RE
106 .SH "EXIT STATUS"
107 .sp
108 0
109 .RS 4
110 success
111 .RE
112 .sp
113 1
114 .RS 4
115 failure
116 .RE
117 .sp
118 32
119 .RS 4
120 all failed
121 .RE
122 .sp
123 64
124 .RS 4
125 some filesystem discards have succeeded, some failed
126 .RE
127 .sp
128 The command \fBfstrim \-\-all\fP returns 0 (all succeeded), 32 (all failed) or 64 (some failed, some succeeded).
129 .SH "AUTHORS"
130 .sp
131 .MTO "lczerner\(atredhat.com" "Lukas Czerner" ","
132 .MTO "kzak\(atredhat.com" "Karel Zak" ""
133 .SH "SEE ALSO"
134 .sp
135 \fBblkdiscard\fP(8),
136 \fBmount\fP(8)
137 .SH "REPORTING BUGS"
138 .sp
139 For bug reports, use the issue tracker at \c
140 .URL "https://github.com/karelzak/util\-linux/issues" "" "."
141 .SH "AVAILABILITY"
142 .sp
143 The \fBfstrim\fP command is part of the util\-linux package which can be downloaded from \c
144 .URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."