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