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