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