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