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 March 5, 2019 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 121appropriate 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. 146Running 147.Dq Li fsck -f 148ignores the journal and does a full 149consistency check of the disk so will find and fix the errors about which the 150journal is unaware. 151.It Fl n 152Causes 153.Nm 154to assume no as the answer to all operator questions, except "CONTINUE?". 155.It Fl p 156Enter preen mode. 157In preen mode, only a restricted class of innocuous 158file system inconsistencies will be corrected. 159If unexpected inconsistencies caused by hardware or 160software failures are encountered, the check program 161will exit with a failure. 162See the manual pages for the individual check programs 163for a list of the sorts of failures that they correct 164when running in preen mode. 165.It Fl F 166Run in foreground mode. 167The check program for each file system is invoked with the 168.Fl F 169flag to determine whether it wishes to run as part of 170the boot up sequence, 171or if it is able to do its job in background after the 172system is up and running. 173A non-zero exit code indicates that it wants to run in foreground 174and the check program is invoked. 175A zero exit code indicates that it is able to run later in background 176and just a deferred message is printed. 177.It Fl B 178Run in background mode. 179The check program for each file system is invoked with the 180.Fl F 181flag to determine whether it wishes to run as part of 182the boot up sequence, 183or if it is able to do its job in background after the 184system is up and running. 185A non-zero exit code indicates that it wanted to run in foreground 186which is assumed to have been done, so the file system is skipped. 187A zero exit code indicates that it is able to run in background 188so the check program is invoked with the 189.Fl B 190flag to indicate that a check on the active file system should be done. 191When running in background mode, 192only one file system at a time will be checked. 193Note that background 194.Nm 195is limited to checking for only the most commonly occurring 196file system abnormalities. 197Under certain circumstances, 198some errors can escape background 199.Nm . 200It is recommended that you perform foreground 201.Nm 202on your systems periodically and whenever you encounter 203file-system\-related panics. 204.It Fl t Ar fstype 205Invoke 206.Nm 207only for the comma separated list of file system types. 208If the 209list starts with 210.Dq no 211then invoke 212.Nm 213for the file system types that are not specified in the list. 214.It Fl v 215Print the commands before executing them. 216.It Fl y 217Causes 218.Nm 219to assume yes 220as the answer to all operator questions. 221.It Fl T Ar fstype : Ns Ar fsoptions 222List of comma separated file system specific options for the specified 223file system type, in the same format as 224.Xr mount 8 . 225.El 226.Sh FILES 227.Bl -tag -width /etc/fstab -compact 228.It Pa /etc/fstab 229file system table 230.El 231.Sh SEE ALSO 232.Xr fstab 5 , 233.Xr fsck_ffs 8 , 234.Xr fsck_msdosfs 8 , 235.Xr mount 8 236.Sh HISTORY 237A 238.Nm 239utility appeared in 240.Bx 4.0 . 241It was reimplemented as a filesystem independent wrapper in 242.Nx 1.3 243and first appeared in 244.Fx 5.0 . 245The original filesystem specific utility became 246.Xr fsck_ffs 8 247at this point. 248