1.\" Copyright (c) 1980, 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)fsck.8 8.2 (Berkeley) 12/11/93 33.\" 34.Dd December 11, 1993 35.Dt FSCK 8 36.Os BSD 4 37.Sh NAME 38.Nm fsck 39.Nd filesystem consistency check and interactive repair 40.Sh SYNOPSIS 41.Nm fsck 42.Fl p 43.Op Fl f 44.Op Fl m Ar mode 45.Nm fsck 46.Op Fl b Ar block# 47.Op Fl c Ar level 48.Op Fl l Ar maxparallel 49.Op Fl y 50.Op Fl n 51.Op Fl m Ar mode 52.Op Ar filesystem 53.Ar ... 54.Sh DESCRIPTION 55The first form of 56.Nm fsck 57preens a standard set of filesystems or the specified filesystems. 58It is normally used in the script 59.Pa /etc/rc 60during automatic reboot. 61Here 62.Nm fsck 63reads the table 64.Pa /etc/fstab 65to determine which filesystems to check. 66Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro'' 67and that have non-zero pass number are checked. 68Filesystems with pass number 1 (normally just the root filesystem) 69are checked one at a time. 70When pass 1 completes, all remaining filesystems are checked, 71running one process per disk drive. 72The disk drive containing each filesystem is inferred from the longest prefix 73of the device name that ends in a digit; the remaining characters are assumed 74to be the partition designator. 75.Pp 76The clean flag of each filesystem's superblock is examined and only those filesystems that 77are not marked clean are checked. If the 78.Fl f 79option is specified, the filesystems 80will be checked regardless of the state of their clean flag. 81.Pp 82The kernel takes care that only a restricted class of innocuous filesystem 83inconsistencies can happen unless hardware or software failures intervene. 84These are limited to the following: 85.Bl -item -compact 86.It 87Unreferenced inodes 88.It 89Link counts in inodes too large 90.It 91Missing blocks in the free map 92.It 93Blocks in the free map also in files 94.It 95Counts in the super-block wrong 96.El 97.Pp 98These are the only inconsistencies that 99.Nm fsck 100with the 101.Fl p 102option will correct; if it encounters other inconsistencies, it exits 103with an abnormal return status and an automatic reboot will then fail. 104For each corrected inconsistency one or more lines will be printed 105identifying the filesystem on which the correction will take place, 106and the nature of the correction. After successfully correcting a filesystem, 107.Nm fsck 108will print the number of files on that filesystem, 109the number of used and free blocks, 110and the percentage of fragmentation. 111.Pp 112If sent a 113.Dv QUIT 114signal, 115.Nm fsck 116will finish the filesystem checks, then exit with an abnormal 117return status that causes an automatic reboot to fail. 118This is useful when you want to finish the filesystem checks during an 119automatic reboot, 120but do not want the machine to come up multiuser after the checks complete. 121.Pp 122Without the 123.Fl p 124option, 125.Nm fsck 126audits and interactively repairs inconsistent conditions for filesystems. 127If the filesystem is inconsistent the operator is prompted for concurrence 128before each correction is attempted. 129It should be noted that some of the corrective actions which are not 130correctable under the 131.Fl p 132option will result in some loss of data. 133The amount and severity of data lost may be determined from the diagnostic 134output. 135The default action for each consistency correction 136is to wait for the operator to respond 137.Li yes 138or 139.Li no . 140If the operator does not have write permission on the filesystem 141.Nm fsck 142will default to a 143.Fl n 144action. 145.Pp 146.Nm Fsck 147has more consistency checks than 148its predecessors 149.Em check , dcheck , fcheck , 150and 151.Em icheck 152combined. 153.Pp 154The following flags are interpreted by 155.Nm fsck . 156.Bl -tag -width indent 157.It Fl b 158Use the block specified immediately after the flag as 159the super block for the filesystem. Block 32 is usually 160an alternate super block. 161.It Fl l 162Limit the number of parallel checks to the number specified in the following 163argument. 164By default, the limit is the number of disks, running one process per disk. 165If a smaller limit is given, the disks are checked round-robin, one filesystem 166at a time. 167.It Fl m 168Use the mode specified in octal immediately after the flag as the 169permission bits to use when creating the 170.Pa lost+found 171directory rather than the default 1777. 172In particular, systems that do not wish to have lost files accessible 173by all users on the system should use a more restrictive 174set of permissions such as 700. 175.It Fl y 176Assume a yes response to all questions asked by 177.Nm fsck ; 178this should be used with great caution as this is a free license 179to continue after essentially unlimited trouble has been encountered. 180.It Fl n 181Assume a no response to all questions asked by 182.Nm fsck 183except for 184.Ql CONTINUE? , 185which is assumed to be affirmative; 186do not open the filesystem for writing. 187.It Fl c 188Convert the filesystem to the specified level. 189Note that the level of a filesystem can only be raised. 190.Bl -tag -width indent 191There are currently three levels defined: 192.It 0 193The filesystem is in the old (static table) format. 194.It 1 195The filesystem is in the new (dynamic table) format. 196.It 2 197The filesystem supports 32-bit uid's and gid's, 198short symbolic links are stored in the inode, 199and directories have an added field showing the file type. 200.El 201.Pp 202In interactive mode, 203.Nm fsck 204will list the conversion to be made 205and ask whether the conversion should be done. 206If a negative answer is given, 207no further operations are done on the filesystem. 208In preen mode, 209the conversion is listed and done if 210possible without user interaction. 211Conversion in preen mode is best used when all the filesystems 212are being converted at once. 213The format of a filesystem can be determined from the 214first line of output from 215.Xr dumpfs 8 . 216.El 217.Pp 218If no filesystems are given to 219.Nm fsck 220then a default list of filesystems is read from 221the file 222.Pa /etc/fstab . 223.Pp 224.Bl -enum -indent indent -compact 225Inconsistencies checked are as follows: 226.It 227Blocks claimed by more than one inode or the free map. 228.It 229Blocks claimed by an inode outside the range of the filesystem. 230.It 231Incorrect link counts. 232.It 233Size checks: 234.Bl -item -indent indent -compact 235.It 236Directory size not a multiple of DIRBLKSIZ. 237.It 238Partially truncated file. 239.El 240.It 241Bad inode format. 242.It 243Blocks not accounted for anywhere. 244.It 245Directory checks: 246.Bl -item -indent indent -compact 247.It 248File pointing to unallocated inode. 249.It 250Inode number out of range. 251.It 252Dot or dot-dot not the first two entries of a directory 253or having the wrong inode number. 254.El 255.It 256Super Block checks: 257.Bl -item -indent indent -compact 258.It 259More blocks for inodes than there are in the filesystem. 260.It 261Bad free block map format. 262.It 263Total free block and/or free inode count incorrect. 264.El 265.El 266.Pp 267Orphaned files and directories (allocated but unreferenced) are, 268with the operator's concurrence, reconnected by 269placing them in the 270.Pa lost+found 271directory. 272The name assigned is the inode number. 273If the 274.Pa lost+found 275directory does not exist, it is created. 276If there is insufficient space its size is increased. 277.Pp 278Because of inconsistencies between the block device and the buffer cache, 279the raw device should always be used. 280.Sh FILES 281.Bl -tag -width /etc/fstab -compact 282.It Pa /etc/fstab 283contains default list of filesystems to check. 284.El 285.Sh DIAGNOSTICS 286The diagnostics produced by 287.Nm fsck 288are fully enumerated and explained in Appendix A of 289.Rs 290.%T "Fsck \- The UNIX File System Check Program" 291.Re 292.Sh SEE ALSO 293.Xr fstab 5 , 294.Xr fs 5 , 295.Xr newfs 8 , 296.Xr mkfs 8 , 297.Xr reboot 8 298