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