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 January 25, 2009 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 114The options are as follows: 115.Bl -tag -width indent 116.It Fl C 117Check if the 118.Dq clean 119flag is set in the superblock and skip file system checks if file system was 120properly dismounted and marked clean. 121.It Fl c Ar fstab 122Specify the 123.Pa fstab 124file to use. 125.It Fl d 126Debugging mode. 127Just print the commands without executing them. 128Available 129only if 130.Nm 131is compiled to support it. 132.It Fl f 133Force checking of file systems, even when they are marked clean (for file systems 134that support this). 135.It Fl n 136Causes 137.Nm 138to assume no as the answer to all operator questions, except "CONTINUE?". 139.It Fl p 140Enter preen mode. 141In preen mode, only a restricted class of innocuous 142file system inconsistencies will be corrected. 143If unexpected inconsistencies caused by hardware or 144software failures are encountered, the check program 145will exit with a failure. 146See the manual pages for the individual check programs 147for a list of the sorts of failures that they correct 148when running in preen mode. 149.It Fl F 150Run in foreground mode. 151The check program for each file system is invoked with the 152.Fl F 153flag to determine whether it wishes to run as part of 154the boot up sequence, 155or if it is able to do its job in background after the 156system is up and running. 157A non-zero exit code indicates that it wants to run in foreground 158and the check program is invoked. 159A zero exit code indicates that it is able to run later in background 160and just a deferred message is printed. 161.It Fl B 162Run in background 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 wanted to run in foreground 170which is assumed to have been done, so the file system is skipped. 171A zero exit code indicates that it is able to run in background 172so the check program is invoked with the 173.Fl B 174flag to indicate that a check on the active file system should be done. 175When running in background mode, 176only one file system at a time will be checked. 177Note that background 178.Nm 179is limited to checking for only the most commonly occurring 180file system abnormalities. 181Under certain circumstances, 182some errors can escape background 183.Nm . 184It is recommended that you perform foreground 185.Nm 186on your systems periodically and whenever you encounter 187file-system\-related panics. 188.It Fl t Ar fstype 189Invoke 190.Nm 191only for the comma separated list of file system types. 192If the 193list starts with 194.Dq no 195then invoke 196.Nm 197for the file system types that are not specified in the list. 198.It Fl v 199Print the commands before executing them. 200.It Fl y 201Causes 202.Nm 203to assume yes 204as the answer to all operator questions. 205.It Fl T Ar fstype : Ns Ar fsoptions 206List of comma separated file system specific options for the specified 207file system type, in the same format as 208.Xr mount 8 . 209.El 210.Sh FILES 211.Bl -tag -width /etc/fstab -compact 212.It Pa /etc/fstab 213file system table 214.El 215.Sh SEE ALSO 216.Xr fstab 5 , 217.Xr fsck_ffs 8 , 218.Xr fsck_msdosfs 8 , 219.Xr mount 8 220