xref: /freebsd/sbin/fsck/fsck.8 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
19a317438SAdrian Chadd.\"	$NetBSD: fsck.8,v 1.19 1999/03/10 00:08:33 erh Exp $
29a317438SAdrian Chadd.\"
39a317438SAdrian Chadd.\" Copyright (c) 1996 Christos Zoulas.  All rights reserved.
49a317438SAdrian Chadd.\"
59a317438SAdrian Chadd.\" Redistribution and use in source and binary forms, with or without
69a317438SAdrian Chadd.\" modification, are permitted provided that the following conditions
79a317438SAdrian Chadd.\" are met:
89a317438SAdrian Chadd.\" 1. Redistributions of source code must retain the above copyright
99a317438SAdrian Chadd.\"    notice, this list of conditions and the following disclaimer.
109a317438SAdrian Chadd.\" 2. Redistributions in binary form must reproduce the above copyright
119a317438SAdrian Chadd.\"    notice, this list of conditions and the following disclaimer in the
129a317438SAdrian Chadd.\"    documentation and/or other materials provided with the distribution.
139a317438SAdrian Chadd.\" 3. All advertising materials mentioning features or use of this software
149a317438SAdrian Chadd.\"    must display the following acknowledgement:
159a317438SAdrian Chadd.\"	This product includes software developed by Christos Zoulas.
169a317438SAdrian Chadd.\" 4. The name of the author may not be used to endorse or promote products
179a317438SAdrian Chadd.\"    derived from this software without specific prior written permission.
189a317438SAdrian Chadd.\"
199a317438SAdrian Chadd.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
209a317438SAdrian Chadd.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
219a317438SAdrian Chadd.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
229a317438SAdrian Chadd.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
239a317438SAdrian Chadd.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
249a317438SAdrian Chadd.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
259a317438SAdrian Chadd.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
269a317438SAdrian Chadd.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
279a317438SAdrian Chadd.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
289a317438SAdrian Chadd.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
299a317438SAdrian Chadd.\"
30e7ff892fSWolfram Schneider.Dd March 5, 2019
319a317438SAdrian Chadd.Dt FSCK 8
321252c1bbSRuslan Ermilov.Os
339a317438SAdrian Chadd.Sh NAME
349a317438SAdrian Chadd.Nm fsck
359a317438SAdrian Chadd.Nd file system consistency check and interactive repair
369a317438SAdrian Chadd.Sh SYNOPSIS
377c7fb079SRuslan Ermilov.Nm
38111a5220SDavid E. O'Brien.Op Fl Cdfnpvy
39a02a0079SKirk McKusick.Op Fl B | F
40d0353b83SRuslan Ermilov.Op Fl T Ar fstype : Ns Ar fsoptions
418d646af5SRuslan Ermilov.Op Fl t Ar fstype
42f2104fc0SMaxim Sobolev.Op Fl c Ar fstab
438d646af5SRuslan Ermilov.Oo Ar special | node Oc ...
449a317438SAdrian Chadd.Sh DESCRIPTION
459a317438SAdrian ChaddThe
469a317438SAdrian Chadd.Nm
47e1205e80SPhilippe Charnierutility invokes file system-specific programs to check
489a317438SAdrian Chaddthe special devices listed in the
499a317438SAdrian Chadd.Xr fstab 5
509a317438SAdrian Chaddfile or in the command line for consistency.
519a317438SAdrian Chadd.Pp
529a317438SAdrian ChaddIt is normally used in the script
539a317438SAdrian Chadd.Pa /etc/rc
549a317438SAdrian Chaddduring automatic reboot.
55a02a0079SKirk McKusickTraditionally,
56a02a0079SKirk McKusick.Nm
57a02a0079SKirk McKusickis invoked before the file systems are mounted
58a02a0079SKirk McKusickand all checks are done to completion at that time.
59a02a0079SKirk McKusickIf background checking is available,
60a02a0079SKirk McKusick.Nm
61a02a0079SKirk McKusickis invoked twice.
62a02a0079SKirk McKusickIt is first invoked at the traditional time,
63a02a0079SKirk McKusickbefore the file systems are mounted, with the
64a02a0079SKirk McKusick.Fl F
65a02a0079SKirk McKusickflag to do checking on all the file systems
66a02a0079SKirk McKusickthat cannot do background checking.
67a02a0079SKirk McKusickIt is then invoked a second time,
68a02a0079SKirk McKusickafter the system has completed going multiuser, with the
69a02a0079SKirk McKusick.Fl B
70a02a0079SKirk McKusickflag to do checking on all the file systems
71a02a0079SKirk McKusickthat can do background checking.
72a02a0079SKirk McKusickUnlike the foreground checking,
7357bd0fc6SJens Schweikhardtthe background checking is started asynchronously
74a02a0079SKirk McKusickso that other system activity can proceed
75a02a0079SKirk McKusickeven on the file systems that are being checked.
76a02a0079SKirk McKusick.Pp
77fa0379c1SRuslan ErmilovIf no file systems are specified,
789a317438SAdrian Chadd.Nm
799a317438SAdrian Chaddreads the table
809a317438SAdrian Chadd.Pa /etc/fstab
819a317438SAdrian Chaddto determine which file systems to check.
82fa0379c1SRuslan ErmilovOnly partitions in
83fa0379c1SRuslan Ermilov.Pa /etc/fstab
84fa0379c1SRuslan Ermilovthat are mounted
85fa0379c1SRuslan Ermilov.Dq rw ,
86fa0379c1SRuslan Ermilov.Dq rq
87fa0379c1SRuslan Ermilovor
88fa0379c1SRuslan Ermilov.Dq ro
899a317438SAdrian Chaddand that have non-zero pass number are checked.
909a317438SAdrian ChaddFile systems with pass number 1 (normally just the root file system)
910af7bca2SPoul-Henning Kampare always checked one at a time.
920af7bca2SPoul-Henning Kamp.Pp
930af7bca2SPoul-Henning KampIf not in preen mode, the remaining entries are checked in order of
940af7bca2SPoul-Henning Kampincreasing pass number one at a time.
9518841862SRuslan ErmilovThis is needed when interaction with
9618841862SRuslan Ermilov.Nm
9718841862SRuslan Ermilovis required.
980af7bca2SPoul-Henning Kamp.Pp
990af7bca2SPoul-Henning KampIn preen mode, after pass 1 completes, all remaining file systems are checked,
1000af7bca2SPoul-Henning Kampin pass number order running one process per disk drive in parallel for each
1010af7bca2SPoul-Henning Kamppass number in increasing order.
1020af7bca2SPoul-Henning Kamp.Pp
1030af7bca2SPoul-Henning KampIn other words: In preen mode all pass 1 partitions are checked sequentially.
1040af7bca2SPoul-Henning KampNext all pass 2 partitions are checked in parallel, one process per disk drive.
1050af7bca2SPoul-Henning KampNext all pass 3 partitions are checked in parallel, one process per disk drive.
1060af7bca2SPoul-Henning Kampetc.
1070af7bca2SPoul-Henning Kamp.Pp
10828b66787SPoul-Henning KampThe disk drive containing each file system is inferred from the shortest prefix
1099a317438SAdrian Chaddof the device name that ends in a digit; the remaining characters are assumed
1100af7bca2SPoul-Henning Kampto be the partition and slice designators.
1119a317438SAdrian Chadd.Pp
112aedb7289STom RhodesIf the
113aedb7289STom Rhodes.Fl t
114aedb7289STom Rhodesor
115aedb7289STom Rhodes.Fl T
116aedb7289STom Rhodesflags are not specified,
117aedb7289STom Rhodes.Nm
118aedb7289STom Rhodeswill attempt to determine the file system type and call the
119*6853ef66SLi-Wen Hsuappropriate file system check utility.
120aedb7289STom RhodesFailure to detect the file system type will cause
121aedb7289STom Rhodes.Nm
122aedb7289STom Rhodesto fail with a message that the partition has an unknown file system type.
123aedb7289STom Rhodes.Pp
1249a317438SAdrian ChaddThe options are as follows:
1259a317438SAdrian Chadd.Bl -tag -width indent
126111a5220SDavid E. O'Brien.It Fl C
127111a5220SDavid E. O'BrienCheck if the
128111a5220SDavid E. O'Brien.Dq clean
129111a5220SDavid E. O'Brienflag is set in the superblock and skip file system checks if file system was
130111a5220SDavid E. O'Brienproperly dismounted and marked clean.
131f2104fc0SMaxim Sobolev.It Fl c Ar fstab
132f2104fc0SMaxim SobolevSpecify the
133f2104fc0SMaxim Sobolev.Pa fstab
134f2104fc0SMaxim Sobolevfile to use.
1359a317438SAdrian Chadd.It Fl d
1369806e231SRuslan ErmilovDebugging mode.
1379806e231SRuslan ErmilovJust print the commands without executing them.
1389806e231SRuslan ErmilovAvailable
1399a317438SAdrian Chaddonly if
1409a317438SAdrian Chadd.Nm
1419a317438SAdrian Chaddis compiled to support it.
1429a317438SAdrian Chadd.It Fl f
143e7ff892fSWolfram SchneiderForce checking of file systems.
144e7ff892fSWolfram SchneiderRunning
145e7ff892fSWolfram Schneider.Dq Li fsck -f
146e7ff892fSWolfram Schneiderignores the journal and does a full
147e7ff892fSWolfram Schneiderconsistency check of the disk so will find and fix the errors about which the
148e7ff892fSWolfram Schneiderjournal is unaware.
1499a317438SAdrian Chadd.It Fl n
1509a317438SAdrian ChaddCauses
1519a317438SAdrian Chadd.Nm
1529a317438SAdrian Chaddto assume no as the answer to all operator questions, except "CONTINUE?".
1539a317438SAdrian Chadd.It Fl p
1549a317438SAdrian ChaddEnter preen mode.
155a02a0079SKirk McKusickIn preen mode, only a restricted class of innocuous
156a02a0079SKirk McKusickfile system inconsistencies will be corrected.
157a02a0079SKirk McKusickIf unexpected inconsistencies caused by hardware or
15857bd0fc6SJens Schweikhardtsoftware failures are encountered, the check program
159a02a0079SKirk McKusickwill exit with a failure.
160a02a0079SKirk McKusickSee the manual pages for the individual check programs
161a02a0079SKirk McKusickfor a list of the sorts of failures that they correct
162a02a0079SKirk McKusickwhen running in preen mode.
163a02a0079SKirk McKusick.It Fl F
164a02a0079SKirk McKusickRun in foreground mode.
165a02a0079SKirk McKusickThe check program for each file system is invoked with the
166a02a0079SKirk McKusick.Fl F
167a02a0079SKirk McKusickflag to determine whether it wishes to run as part of
168a02a0079SKirk McKusickthe boot up sequence,
169a02a0079SKirk McKusickor if it is able to do its job in background after the
170a02a0079SKirk McKusicksystem is up and running.
171a02a0079SKirk McKusickA non-zero exit code indicates that it wants to run in foreground
172a02a0079SKirk McKusickand the check program is invoked.
173a02a0079SKirk McKusickA zero exit code indicates that it is able to run later in background
174a02a0079SKirk McKusickand just a deferred message is printed.
175a02a0079SKirk McKusick.It Fl B
176a02a0079SKirk McKusickRun in background mode.
177a02a0079SKirk McKusickThe check program for each file system is invoked with the
178a02a0079SKirk McKusick.Fl F
179a02a0079SKirk McKusickflag to determine whether it wishes to run as part of
180a02a0079SKirk McKusickthe boot up sequence,
181a02a0079SKirk McKusickor if it is able to do its job in background after the
182a02a0079SKirk McKusicksystem is up and running.
183a02a0079SKirk McKusickA non-zero exit code indicates that it wanted to run in foreground
184a02a0079SKirk McKusickwhich is assumed to have been done, so the file system is skipped.
185a02a0079SKirk McKusickA zero exit code indicates that it is able to run in background
186a02a0079SKirk McKusickso the check program is invoked with the
187a02a0079SKirk McKusick.Fl B
188a02a0079SKirk McKusickflag to indicate that a check on the active file system should be done.
189a02a0079SKirk McKusickWhen running in background mode,
190a02a0079SKirk McKusickonly one file system at a time will be checked.
19190104f54SKirk McKusickNote that background
19290104f54SKirk McKusick.Nm
193f6ac2391SJoel Dahlis limited to checking for only the most commonly occurring
19490104f54SKirk McKusickfile system abnormalities.
19590104f54SKirk McKusickUnder certain circumstances,
19690104f54SKirk McKusicksome errors can escape background
19790104f54SKirk McKusick.Nm .
19890104f54SKirk McKusickIt is recommended that you perform foreground
19990104f54SKirk McKusick.Nm
20090104f54SKirk McKusickon your systems periodically and whenever you encounter
20190104f54SKirk McKusickfile-system\-related panics.
2029a317438SAdrian Chadd.It Fl t Ar fstype
2039a317438SAdrian ChaddInvoke
2049a317438SAdrian Chadd.Nm
2059806e231SRuslan Ermilovonly for the comma separated list of file system types.
2069806e231SRuslan ErmilovIf the
2079a317438SAdrian Chaddlist starts with
2089a317438SAdrian Chadd.Dq no
2099a317438SAdrian Chaddthen invoke
2109a317438SAdrian Chadd.Nm
2119a317438SAdrian Chaddfor the file system types that are not specified in the list.
2129a317438SAdrian Chadd.It Fl v
2139a317438SAdrian ChaddPrint the commands before executing them.
2149a317438SAdrian Chadd.It Fl y
2159a317438SAdrian ChaddCauses
2169a317438SAdrian Chadd.Nm
2179a317438SAdrian Chaddto assume yes
2189a317438SAdrian Chaddas the answer to all operator questions.
219d0353b83SRuslan Ermilov.It Fl T Ar fstype : Ns Ar fsoptions
2209a317438SAdrian ChaddList of comma separated file system specific options for the specified
2219a317438SAdrian Chaddfile system type, in the same format as
2229a317438SAdrian Chadd.Xr mount 8 .
2239a317438SAdrian Chadd.El
2249a317438SAdrian Chadd.Sh FILES
2259a317438SAdrian Chadd.Bl -tag -width /etc/fstab -compact
2269a317438SAdrian Chadd.It Pa /etc/fstab
2279a317438SAdrian Chaddfile system table
2289a317438SAdrian Chadd.El
2299a317438SAdrian Chadd.Sh SEE ALSO
2309a317438SAdrian Chadd.Xr fstab 5 ,
231fa0379c1SRuslan Ermilov.Xr fsck_ffs 8 ,
232265c01dfSRuslan Ermilov.Xr fsck_msdosfs 8 ,
233fa0379c1SRuslan Ermilov.Xr mount 8
234775f689cSSevan Janiyan.Sh HISTORY
235775f689cSSevan JaniyanA
236775f689cSSevan Janiyan.Nm
237775f689cSSevan Janiyanutility appeared in
238775f689cSSevan Janiyan.Bx 4.0 .
239775f689cSSevan JaniyanIt was reimplemented as a filesystem independent wrapper in
240775f689cSSevan Janiyan.Nx 1.3
241775f689cSSevan Janiyanand first appeared in
242775f689cSSevan Janiyan.Fx 5.0 .
243775f689cSSevan JaniyanThe original filesystem specific utility became
244775f689cSSevan Janiyan.Xr fsck_ffs 8
245775f689cSSevan Janiyanat this point.
246