xref: /freebsd/sbin/fsck/fsck.8 (revision fcb560670601b2a4d87bb31d7531c8dcc37ee71b)
1.\"	$NetBSD: fsck.8,v 1.19 1999/03/10 00:08:33 erh Exp $
2.\"
3.\" Copyright (c) 1996 Christos Zoulas.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\"    must display the following acknowledgement:
15.\"	This product includes software developed by Christos Zoulas.
16.\" 4. The name of the author may not be used to endorse or promote products
17.\"    derived from this software without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" $FreeBSD$
31.\"
32.Dd May 23, 2014
33.Dt FSCK 8
34.Os
35.Sh NAME
36.Nm fsck
37.Nd file system consistency check and interactive repair
38.Sh SYNOPSIS
39.Nm
40.Op Fl Cdfnpvy
41.Op Fl B | F
42.Op Fl T Ar fstype : Ns Ar fsoptions
43.Op Fl t Ar fstype
44.Op Fl c Ar fstab
45.Oo Ar special | node Oc ...
46.Sh DESCRIPTION
47The
48.Nm
49utility invokes file system-specific programs to check
50the special devices listed in the
51.Xr fstab 5
52file or in the command line for consistency.
53.Pp
54It is normally used in the script
55.Pa /etc/rc
56during automatic reboot.
57Traditionally,
58.Nm
59is invoked before the file systems are mounted
60and all checks are done to completion at that time.
61If background checking is available,
62.Nm
63is invoked twice.
64It is first invoked at the traditional time,
65before the file systems are mounted, with the
66.Fl F
67flag to do checking on all the file systems
68that cannot do background checking.
69It is then invoked a second time,
70after the system has completed going multiuser, with the
71.Fl B
72flag to do checking on all the file systems
73that can do background checking.
74Unlike the foreground checking,
75the background checking is started asynchronously
76so that other system activity can proceed
77even on the file systems that are being checked.
78.Pp
79If no file systems are specified,
80.Nm
81reads the table
82.Pa /etc/fstab
83to determine which file systems to check.
84Only partitions in
85.Pa /etc/fstab
86that are mounted
87.Dq rw ,
88.Dq rq
89or
90.Dq ro
91and that have non-zero pass number are checked.
92File systems with pass number 1 (normally just the root file system)
93are always checked one at a time.
94.Pp
95If not in preen mode, the remaining entries are checked in order of
96increasing pass number one at a time.
97This is needed when interaction with
98.Nm
99is required.
100.Pp
101In preen mode, after pass 1 completes, all remaining file systems are checked,
102in pass number order running one process per disk drive in parallel for each
103pass number in increasing order.
104.Pp
105In other words: In preen mode all pass 1 partitions are checked sequentially.
106Next all pass 2 partitions are checked in parallel, one process per disk drive.
107Next all pass 3 partitions are checked in parallel, one process per disk drive.
108etc.
109.Pp
110The disk drive containing each file system is inferred from the shortest prefix
111of the device name that ends in a digit; the remaining characters are assumed
112to be the partition and slice designators.
113.Pp
114If the
115.Fl t
116or
117.Fl T
118flags are not specified,
119.Nm
120will attempt to determine the file system type and call the
121appropriated file system check utility.
122Failure to detect the file system type will cause
123.Nm
124to fail with a message that the partition has an unknown file system type.
125.Pp
126The options are as follows:
127.Bl -tag -width indent
128.It Fl C
129Check if the
130.Dq clean
131flag is set in the superblock and skip file system checks if file system was
132properly dismounted and marked clean.
133.It Fl c Ar fstab
134Specify the
135.Pa fstab
136file to use.
137.It Fl d
138Debugging mode.
139Just print the commands without executing them.
140Available
141only if
142.Nm
143is compiled to support it.
144.It Fl f
145Force checking of file systems, even when they are marked clean (for file systems
146that support this).
147.It Fl n
148Causes
149.Nm
150to assume no as the answer to all operator questions, except "CONTINUE?".
151.It Fl p
152Enter preen mode.
153In preen mode, only a restricted class of innocuous
154file system inconsistencies will be corrected.
155If unexpected inconsistencies caused by hardware or
156software failures are encountered, the check program
157will exit with a failure.
158See the manual pages for the individual check programs
159for a list of the sorts of failures that they correct
160when running in preen mode.
161.It Fl F
162Run in foreground mode.
163The check program for each file system is invoked with the
164.Fl F
165flag to determine whether it wishes to run as part of
166the boot up sequence,
167or if it is able to do its job in background after the
168system is up and running.
169A non-zero exit code indicates that it wants to run in foreground
170and the check program is invoked.
171A zero exit code indicates that it is able to run later in background
172and just a deferred message is printed.
173.It Fl B
174Run in background mode.
175The check program for each file system is invoked with the
176.Fl F
177flag to determine whether it wishes to run as part of
178the boot up sequence,
179or if it is able to do its job in background after the
180system is up and running.
181A non-zero exit code indicates that it wanted to run in foreground
182which is assumed to have been done, so the file system is skipped.
183A zero exit code indicates that it is able to run in background
184so the check program is invoked with the
185.Fl B
186flag to indicate that a check on the active file system should be done.
187When running in background mode,
188only one file system at a time will be checked.
189Note that background
190.Nm
191is limited to checking for only the most commonly occurring
192file system abnormalities.
193Under certain circumstances,
194some errors can escape background
195.Nm .
196It is recommended that you perform foreground
197.Nm
198on your systems periodically and whenever you encounter
199file-system\-related panics.
200.It Fl t Ar fstype
201Invoke
202.Nm
203only for the comma separated list of file system types.
204If the
205list starts with
206.Dq no
207then invoke
208.Nm
209for the file system types that are not specified in the list.
210.It Fl v
211Print the commands before executing them.
212.It Fl y
213Causes
214.Nm
215to assume yes
216as the answer to all operator questions.
217.It Fl T Ar fstype : Ns Ar fsoptions
218List of comma separated file system specific options for the specified
219file system type, in the same format as
220.Xr mount 8 .
221.El
222.Sh FILES
223.Bl -tag -width /etc/fstab -compact
224.It Pa /etc/fstab
225file system table
226.El
227.Sh SEE ALSO
228.Xr fstab 5 ,
229.Xr fsck_ffs 8 ,
230.Xr fsck_msdosfs 8 ,
231.Xr mount 8
232