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