]> git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/fsck.8
wipefs: add --lock and LOCK_BLOCK_DEVICE
[thirdparty/util-linux.git] / disk-utils / fsck.8
1 .\" Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved.
2 .\" This file may be copied under the terms of the GNU Public License.
3 .\"
4 .TH FSCK 8 "February 2009" "util-linux" "System Administration"
5 .SH NAME
6 fsck \- check and repair a Linux filesystem
7 .SH SYNOPSIS
8 .B fsck
9 .RB [ \-lsAVRTMNP ]
10 .RB [ \-r
11 .RI [ fd ]]
12 .RB [ \-C
13 .RI [ fd ]]
14 .RB [ \-t
15 .IR fstype ]
16 .RI [ filesystem \&...\&]
17 .RB [ \-\- ]
18 .RI [ fs-specific-options ]
19 .SH DESCRIPTION
20 .B fsck
21 is used to check and optionally repair one or more Linux filesystems.
22 .I filesys
23 can be a device name (e.g.,
24 .IR /dev/hdc1 ", " /dev/sdb2 ),
25 a mount point (e.g.,
26 .IR / ", " /usr ", " /home ),
27 or an filesystem label or UUID specifier (e.g.,
28 UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root).
29 Normally, the
30 .B fsck
31 program will try to handle filesystems on different physical disk drives
32 in parallel to reduce the total amount of time needed to check all of them.
33 .PP
34 If no filesystems are specified on the command line, and the
35 .B \-A
36 option is not specified,
37 .B fsck
38 will default to checking filesystems in
39 .I /etc/fstab
40 serially. This is equivalent to the
41 .B \-As
42 options.
43 .PP
44 The exit status returned by
45 .B fsck
46 is the sum of the following conditions:
47 .PP
48 .RS
49 .PD 0
50 .TP
51 .B 0
52 No errors
53 .TP
54 .B 1
55 Filesystem errors corrected
56 .TP
57 .B 2
58 System should be rebooted
59 .TP
60 .B 4
61 Filesystem errors left uncorrected
62 .TP
63 .B 8
64 Operational error
65 .TP
66 .B 16
67 Usage or syntax error
68 .TP
69 .B 32
70 Checking canceled by user request
71 .TP
72 .B 128
73 Shared-library error
74 .PD
75 .RE
76 .PP
77 The exit status returned when multiple filesystems are checked
78 is the bit-wise OR of the exit statuses for each
79 filesystem that is checked.
80 .PP
81 In actuality,
82 .B fsck
83 is simply a front-end for the various filesystem checkers
84 (\fBfsck\fR.\fIfstype\fR) available under Linux. The
85 filesystem-specific checker is searched for in the
86 PATH environment variable. If the PATH is undefined then
87 fallback to "/sbin".
88 .PP
89 Please see the filesystem-specific checker manual pages for
90 further details.
91 .SH OPTIONS
92 .TP
93 .B \-l
94 Create an exclusive
95 .BR flock (2)
96 lock file (/run/fsck/<diskname>.lock) for whole-disk device.
97 This option can be used with one device only (this means that \fB\-A\fR and
98 \fB\-l\fR are mutually exclusive). This option is recommended when more
99 .BR fsck (8)
100 instances are executed in the same time. The option is ignored when used for
101 multiple devices or for non-rotating disks. \fBfsck\fR does not lock underlying
102 devices when executed to check stacked devices (e.g.\& MD or DM) \(en this feature is
103 not implemented yet.
104 .TP
105 .BR \-r \ [ \fIfd\fR ]
106 Report certain statistics for each fsck when it completes. These statistics
107 include the exit status, the maximum run set size (in kilobytes), the elapsed
108 all-clock time and the user and system CPU time used by the fsck run. For
109 example:
110
111 /dev/sda1: status 0, rss 92828, real 4.002804, user 2.677592, sys 0.86186
112
113 GUI front-ends may specify a file descriptor
114 .IR fd ,
115 in which case the progress bar information will be sent to that file descriptor
116 in a machine parsable format. For example:
117
118 /dev/sda1 0 92828 4.002804 2.677592 0.86186
119 .TP
120 .B \-s
121 Serialize
122 .B fsck
123 operations. This is a good idea if you are checking multiple
124 filesystems and the checkers are in an interactive mode. (Note:
125 .BR e2fsck (8)
126 runs in an interactive mode by default. To make
127 .BR e2fsck (8)
128 run in a non-interactive mode, you must either specify the
129 .B \-p
130 or
131 .B \-a
132 option, if you wish for errors to be corrected automatically, or the
133 .B \-n
134 option if you do not.)
135 .TP
136 .BI \-t " fslist"
137 Specifies the type(s) of filesystem to be checked. When the
138 .B \-A
139 flag is specified, only filesystems that match
140 .I fslist
141 are checked. The
142 .I fslist
143 parameter is a comma-separated list of filesystems and options
144 specifiers. All of the filesystems in this comma-separated list may be
145 prefixed by a negation operator
146 .RB ' no '
147 or
148 .RB ' ! ',
149 which requests that only those filesystems not listed in
150 .I fslist
151 will be checked. If none of the filesystems in
152 .I fslist
153 is prefixed by a negation operator, then only those listed filesystems
154 will be checked.
155 .sp
156 Options specifiers may be included in the comma-separated
157 .IR fslist .
158 They must have the format
159 .BI opts= fs-option\fR.
160 If an options specifier is present, then only filesystems which contain
161 .I fs-option
162 in their mount options field of
163 .I /etc/fstab
164 will be checked. If the options specifier is prefixed by a negation
165 operator, then only
166 those filesystems that do not have
167 .I fs-option
168 in their mount options field of
169 .I /etc/fstab
170 will be checked.
171 .sp
172 For example, if
173 .B opts=ro
174 appears in
175 .IR fslist ,
176 then only filesystems listed in
177 .I /etc/fstab
178 with the
179 .B ro
180 option will be checked.
181 .sp
182 For compatibility with Mandrake distributions whose boot scripts
183 depend upon an unauthorized UI change to the
184 .B fsck
185 program, if a filesystem type of
186 .B loop
187 is found in
188 .IR fslist ,
189 it is treated as if
190 .B opts=loop
191 were specified as an argument to the
192 .B \-t
193 option.
194 .sp
195 Normally, the filesystem type is deduced by searching for
196 .I filesys
197 in the
198 .I /etc/fstab
199 file and using the corresponding entry.
200 If the type cannot be deduced, and there is only a single filesystem
201 given as an argument to the
202 .B \-t
203 option,
204 .B fsck
205 will use the specified filesystem type. If this type is not
206 available, then the default filesystem type (currently ext2) is used.
207 .TP
208 .B \-A
209 Walk through the
210 .I /etc/fstab
211 file and try to check all filesystems in one run. This option is
212 typically used from the
213 .I /etc/rc
214 system initialization file, instead of multiple commands for checking
215 a single filesystem.
216 .sp
217 The root filesystem will be checked first unless the
218 .B \-P
219 option is specified (see below). After that,
220 filesystems will be checked in the order specified by the
221 .I fs_passno
222 (the sixth) field in the
223 .I /etc/fstab
224 file.
225 Filesystems with a
226 .I fs_passno
227 value of 0 are skipped and are not checked at all. Filesystems with a
228 .I fs_passno
229 value of greater than zero will be checked in order,
230 with filesystems with the lowest
231 .I fs_passno
232 number being checked first.
233 If there are multiple filesystems with the same pass number,
234 .B fsck
235 will attempt to check them in parallel, although it will avoid running
236 multiple filesystem checks on the same physical disk.
237 .sp
238 .B fsck
239 does not check stacked devices (RAIDs, dm-crypt, \&...\&) in parallel with any other
240 device. See below for FSCK_FORCE_ALL_PARALLEL setting. The /sys filesystem is
241 used to determine dependencies between devices.
242 .sp
243 Hence, a very common configuration in
244 .I /etc/fstab
245 files is to set the root filesystem to have a
246 .I fs_passno
247 value of 1
248 and to set all other filesystems to have a
249 .I fs_passno
250 value of 2. This will allow
251 .B fsck
252 to automatically run filesystem checkers in parallel if it is advantageous
253 to do so. System administrators might choose
254 not to use this configuration if they need to avoid multiple filesystem
255 checks running in parallel for some reason \(en for example, if the
256 machine in question is short on memory so that
257 excessive paging is a concern.
258 .sp
259 .B fsck
260 normally does not check whether the device actually exists before
261 calling a filesystem specific checker. Therefore non-existing
262 devices may cause the system to enter filesystem repair mode during
263 boot if the filesystem specific checker returns a fatal error. The
264 .I /etc/fstab
265 mount option
266 .B nofail
267 may be used to have
268 .B fsck
269 skip non-existing devices.
270 .B fsck
271 also skips non-existing devices that have the special filesystem type
272 .BR auto .
273 .TP
274 .BR \-C \ [ \fIfd\fR ]
275 Display completion/progress bars for those filesystem checkers (currently
276 only for ext[234]) which support them. \fBfsck\fR will manage the
277 filesystem checkers so that only one of them will display
278 a progress bar at a time. GUI front-ends may specify a file descriptor
279 .IR fd ,
280 in which case the progress bar information will be sent to that file descriptor.
281 .TP
282 .B \-M
283 Do not check mounted filesystems and return an exit status of 0
284 for mounted filesystems.
285 .TP
286 .B \-N
287 Don't execute, just show what would be done.
288 .TP
289 .B \-P
290 When the
291 .B \-A
292 flag is set, check the root filesystem in parallel with the other filesystems.
293 This is not the safest thing in the world to do,
294 since if the root filesystem is in doubt things like the
295 .BR e2fsck (8)
296 executable might be corrupted! This option is mainly provided
297 for those sysadmins who don't want to repartition the root
298 filesystem to be small and compact (which is really the right solution).
299 .TP
300 .B \-R
301 When checking all filesystems with the
302 .B \-A
303 flag, skip the root filesystem. (This is useful in case the root
304 filesystem has already been mounted read-write.)
305 .TP
306 .B \-T
307 Don't show the title on startup.
308 .TP
309 .B \-V
310 Produce verbose output, including all filesystem-specific commands
311 that are executed.
312 .TP
313 \fB\-?\fR, \fB\-\-help\fR
314 Display help text and exit.
315 .TP
316 \fB\-\-version\fR
317 Display version information and exit.
318 .SH FILESYSTEM SPECIFIC OPTIONS
319 .B Options which are not understood by fsck are passed to the filesystem-specific checker!
320 .PP
321 These options
322 .B must
323 not take arguments, as there is no
324 way for
325 .B fsck
326 to be able to properly guess which options take arguments and which
327 don't.
328 .PP
329 Options and arguments which follow the
330 .B \-\-
331 are treated as filesystem-specific options to be passed to the
332 filesystem-specific checker.
333 .PP
334 Please note that \fBfsck\fR is not
335 designed to pass arbitrarily complicated options to filesystem-specific
336 checkers. If you're doing something complicated, please just
337 execute the filesystem-specific checker directly. If you pass
338 .B fsck
339 some horribly complicated options and arguments, and it doesn't do
340 what you expect,
341 .B don't bother reporting it as a bug.
342 You're almost certainly doing something that you shouldn't be doing
343 with
344 .BR fsck .
345 Options to different filesystem-specific fsck's are not standardized.
346 .SH ENVIRONMENT
347 The
348 .B fsck
349 program's behavior is affected by the following environment variables:
350 .TP
351 .B FSCK_FORCE_ALL_PARALLEL
352 If this environment variable is set,
353 .B fsck
354 will attempt to check all of the specified filesystems in parallel, regardless of
355 whether the filesystems appear to be on the same device. (This is useful for
356 RAID systems or high-end storage systems such as those sold by companies such
357 as IBM or EMC.) Note that the fs_passno value is still used.
358 .TP
359 .B FSCK_MAX_INST
360 This environment variable will limit the maximum number of filesystem
361 checkers that can be running at one time. This allows configurations
362 which have a large number of disks to avoid
363 .B fsck
364 starting too many filesystem checkers at once, which might overload
365 CPU and memory resources available on the system. If this value is
366 zero, then an unlimited number of processes can be spawned. This is
367 currently the default, but future versions of
368 .B fsck
369 may attempt to automatically determine how many filesystem checks can
370 be run based on gathering accounting data from the operating system.
371 .TP
372 .B PATH
373 The
374 .B PATH
375 environment variable is used to find filesystem checkers.
376 .TP
377 .B FSTAB_FILE
378 This environment variable allows the system administrator
379 to override the standard location of the
380 .I /etc/fstab
381 file. It is also useful for developers who are testing
382 .BR fsck .
383 .TP
384 .B LIBBLKID_DEBUG=all
385 enables libblkid debug output.
386 .TP
387 .B LIBMOUNT_DEBUG=all
388 enables libmount debug output.
389 .SH FILES
390 .I /etc/fstab
391 .SH AUTHORS
392 .nf
393 Theodore Ts'o <tytso@mit.edu>
394 Karel Zak <kzak@redhat.com>
395 .fi
396 .SH SEE ALSO
397 .na
398 .BR fstab (5),
399 .BR mkfs (8),
400 .BR fsck.ext2 (8)
401 or
402 .BR fsck.ext3 (8)
403 or
404 .BR e2fsck (8),
405 .BR fsck.cramfs (8),
406 .BR fsck.jfs (8),
407 .BR fsck.nfs (8),
408 .BR fsck.minix (8),
409 .BR fsck.msdos (8),
410 .BR fsck.vfat (8),
411 .BR fsck.xfs (8),
412 .BR reiserfsck (8)
413 .ad
414 .SH AVAILABILITY
415 The fsck command is part of the util-linux package and is available from
416 .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
417 Linux Kernel Archive
418 .UE .