xref: /freebsd/sbin/fsck/fsck.8 (revision a4e5e0106ac7145f56eb39a691e302cabb4635be)
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.Dd March 5, 2019
31.Dt FSCK 8
32.Os
33.Sh NAME
34.Nm fsck
35.Nd file system consistency check and interactive repair
36.Sh SYNOPSIS
37.Nm
38.Op Fl Cdfnpvy
39.Op Fl B | F
40.Op Fl T Ar fstype : Ns Ar fsoptions
41.Op Fl t Ar fstype
42.Op Fl c Ar fstab
43.Oo Ar special | node Oc ...
44.Sh DESCRIPTION
45The
46.Nm
47utility invokes file system-specific programs to check
48the special devices listed in the
49.Xr fstab 5
50file or in the command line for consistency.
51.Pp
52It is normally used in the script
53.Pa /etc/rc
54during automatic reboot.
55Traditionally,
56.Nm
57is invoked before the file systems are mounted
58and all checks are done to completion at that time.
59If background checking is available,
60.Nm
61is invoked twice.
62It is first invoked at the traditional time,
63before the file systems are mounted, with the
64.Fl F
65flag to do checking on all the file systems
66that cannot do background checking.
67It is then invoked a second time,
68after the system has completed going multiuser, with the
69.Fl B
70flag to do checking on all the file systems
71that can do background checking.
72Unlike the foreground checking,
73the background checking is started asynchronously
74so that other system activity can proceed
75even on the file systems that are being checked.
76.Pp
77If no file systems are specified,
78.Nm
79reads the table
80.Pa /etc/fstab
81to determine which file systems to check.
82Only partitions in
83.Pa /etc/fstab
84that are mounted
85.Dq rw ,
86.Dq rq
87or
88.Dq ro
89and that have non-zero pass number are checked.
90File systems with pass number 1 (normally just the root file system)
91are always checked one at a time.
92.Pp
93If not in preen mode, the remaining entries are checked in order of
94increasing pass number one at a time.
95This is needed when interaction with
96.Nm
97is required.
98.Pp
99In preen mode, after pass 1 completes, all remaining file systems are checked,
100in pass number order running one process per disk drive in parallel for each
101pass number in increasing order.
102.Pp
103In other words: In preen mode all pass 1 partitions are checked sequentially.
104Next all pass 2 partitions are checked in parallel, one process per disk drive.
105Next all pass 3 partitions are checked in parallel, one process per disk drive.
106etc.
107.Pp
108The disk drive containing each file system is inferred from the shortest prefix
109of the device name that ends in a digit; the remaining characters are assumed
110to be the partition and slice designators.
111.Pp
112If the
113.Fl t
114or
115.Fl T
116flags are not specified,
117.Nm
118will attempt to determine the file system type and call the
119appropriate file system check utility.
120Failure to detect the file system type will cause
121.Nm
122to fail with a message that the partition has an unknown file system type.
123.Pp
124The options are as follows:
125.Bl -tag -width indent
126.It Fl C
127Check if the
128.Dq clean
129flag is set in the superblock and skip file system checks if file system was
130properly dismounted and marked clean.
131.It Fl c Ar fstab
132Specify the
133.Pa fstab
134file to use.
135.It Fl d
136Debugging mode.
137Just print the commands without executing them.
138Available
139only if
140.Nm
141is compiled to support it.
142.It Fl f
143Force checking of file systems.
144Running
145.Dq Li fsck -f
146ignores the journal and does a full
147consistency check of the disk so will find and fix the errors about which the
148journal is unaware.
149.It Fl n
150Causes
151.Nm
152to assume no as the answer to all operator questions, except "CONTINUE?".
153.It Fl p
154Enter preen mode.
155In preen mode, only a restricted class of innocuous
156file system inconsistencies will be corrected.
157If unexpected inconsistencies caused by hardware or
158software failures are encountered, the check program
159will exit with a failure.
160See the manual pages for the individual check programs
161for a list of the sorts of failures that they correct
162when running in preen mode.
163.It Fl F
164Run in foreground mode.
165The check program for each file system is invoked with the
166.Fl F
167flag to determine whether it wishes to run as part of
168the boot up sequence,
169or if it is able to do its job in background after the
170system is up and running.
171A non-zero exit code indicates that it wants to run in foreground
172and the check program is invoked.
173A zero exit code indicates that it is able to run later in background
174and just a deferred message is printed.
175.It Fl B
176Run in background mode.
177The check program for each file system is invoked with the
178.Fl F
179flag to determine whether it wishes to run as part of
180the boot up sequence,
181or if it is able to do its job in background after the
182system is up and running.
183A non-zero exit code indicates that it wanted to run in foreground
184which is assumed to have been done, so the file system is skipped.
185A zero exit code indicates that it is able to run in background
186so the check program is invoked with the
187.Fl B
188flag to indicate that a check on the active file system should be done.
189When running in background mode,
190only one file system at a time will be checked.
191Note that background
192.Nm
193is limited to checking for only the most commonly occurring
194file system abnormalities.
195Under certain circumstances,
196some errors can escape background
197.Nm .
198It is recommended that you perform foreground
199.Nm
200on your systems periodically and whenever you encounter
201file-system\-related panics.
202.It Fl t Ar fstype
203Invoke
204.Nm
205only for the comma separated list of file system types.
206If the
207list starts with
208.Dq no
209then invoke
210.Nm
211for the file system types that are not specified in the list.
212.It Fl v
213Print the commands before executing them.
214.It Fl y
215Causes
216.Nm
217to assume yes
218as the answer to all operator questions.
219.It Fl T Ar fstype : Ns Ar fsoptions
220List of comma separated file system specific options for the specified
221file system type, in the same format as
222.Xr mount 8 .
223.El
224.Sh FILES
225.Bl -tag -width /etc/fstab -compact
226.It Pa /etc/fstab
227file system table
228.El
229.Sh SEE ALSO
230.Xr fstab 5 ,
231.Xr fsck_ffs 8 ,
232.Xr fsck_msdosfs 8 ,
233.Xr mount 8
234.Sh HISTORY
235A
236.Nm
237utility appeared in
238.Bx 4.0 .
239It was reimplemented as a filesystem independent wrapper in
240.Nx 1.3
241and first appeared in
242.Fx 5.0 .
243The original filesystem specific utility became
244.Xr fsck_ffs 8
245at this point.
246