1.\" $NetBSD: fsck_ffs.8,v 1.29 2002/05/06 03:17:43 lukem Exp $ 2.\" 3.\" Copyright (c) 1980, 1989, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)fsck.8 8.3 (Berkeley) 11/29/94 35.\" 36.Dd May 6, 2001 37.Dt FSCK_FFS 8 38.Os 39.Sh NAME 40.Nm fsck_ffs 41.Nd Fast File System consistency check and interactive repair 42.Sh SYNOPSIS 43.Nm "" 44.Op Fl B Ar byte order 45.Op Fl b Ar block# 46.Op Fl c Ar level 47.Op Fl d 48.Op Fl F 49.Op Fl f 50.Op Fl m Ar mode 51.Op Fl p 52.Op Fl y 53.Op Fl n 54.Ar filesystem ... 55.Sh DESCRIPTION 56.Nm 57performs interactive file system consistency checks and repair for each of 58the file systems specified on the command line. It is normally invoked from 59.Xr fsck 8 . 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 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 80in ``preen'' 81mode (with the 82.Fl p 83option) will correct; if it encounters other inconsistencies, it exits 84with an abnormal return status. 85For each corrected inconsistency one or more lines will be printed 86identifying the file system on which the correction will take place, 87and the nature of the correction. After successfully correcting a file 88system, 89.Nm 90will print the number of files on that file system, 91the number of used and free blocks, 92and the percentage of fragmentation. 93.Pp 94If sent a 95.Dv QUIT 96signal, 97.Nm 98will finish the file system checks, then exit with an abnormal return status. 99.Pp 100If 101.Nm 102receives a 103.Dv SIGINFO 104signal 105(see the 106.Sy status 107argument for 108.Xr stty 1 ) , 109a line will be written to the standard error output indicating 110the name of the device currently being checked, the current phase 111number and phase-specific progress information. 112.Pp 113Without the 114.Fl p 115option, 116.Nm 117audits and interactively repairs inconsistent conditions for file systems. 118If the file system is inconsistent the operator is prompted for concurrence 119before each correction is attempted. 120It should be noted that some of the corrective actions which are not 121correctable under the 122.Fl p 123option will result in some loss of data. 124The amount and severity of data lost may be determined from the diagnostic 125output. 126The default action for each consistency correction 127is to wait for the operator to respond 128.Li yes 129or 130.Li no . 131If the operator does not have write permission on the file system 132.Nm 133will default to a 134.Fl n 135action. 136.Pp 137.Nm 138has more consistency checks than 139its predecessors 140.Em check , dcheck , fcheck , 141and 142.Em icheck 143combined. 144.Pp 145The following flags are interpreted by 146.Nm "" . 147.Bl -tag -width indent 148.It Fl B 149Convert the file system metadata to the specified byte order if needed. 150Valid byte order are `be' and `le'. If 151.Nm "" 152is interrupted while swapping the metadata byte order, the file system cannot 153be recovered. 154.Nm "" 155will print a message in interactive mode if the file system is not in host 156byte order. 157.It Fl b 158Use the block specified immediately after the flag as 159the super block for the file system. Block 32 is usually 160an alternative super block. 161.It Fl c 162Convert the file system to the specified level. 163Note that the level of a file system can only be raised. 164.Bl -tag -width indent 165There are currently four levels defined: 166.It 0 167The file system is in the old (static table) format. 168.It 1 169The file system is in the new (dynamic table) format. 170.It 2 171The file system supports 32-bit uid's and gid's, 172short symbolic links are stored in the inode, 173and directories have an added field showing the file type. 174.It 3 175If maxcontig is greater than one, 176build the free segment maps to aid in finding contiguous sets of blocks. 177If maxcontig is equal to one, delete any existing segment maps. 178.El 179.Pp 180In interactive mode, 181.Nm 182will list the conversion to be made 183and ask whether the conversion should be done. 184If a negative answer is given, 185no further operations are done on the file system. 186In preen mode, 187the conversion is listed and done if 188possible without user interaction. 189Conversion in preen mode is best used when all the file systems 190are being converted at once. 191The format of a file system can be determined from the 192second line of output from 193.Xr dumpfs 8 . 194.It Fl d 195Print debugging output. 196.It Fl F 197Indicates that 198.Ar filesystem 199is a file system image, rather than a raw character device. 200.Ar filesystem 201will be accessed 202.Sq as-is , 203and no attempts will be made to read a disklabel. 204.It Fl f 205Force checking of file systems. Normally, if a file system is cleanly 206unmounted, the kernel will set a 207.Dq clean flag 208in the file system superblock, and 209.Nm 210will not check the file system. This option forces 211.Nm 212to check the file system, regardless of the state of the clean flag. 213.It Fl m 214Use the mode specified in octal immediately after the flag as the 215permission bits to use when creating the 216.Pa lost+found 217directory rather than the default 1700. 218In particular, systems that do not wish to have lost files accessible 219by all users on the system should use a more restrictive 220set of permissions such as 700. 221.It Fl n 222Assume a no response to all questions asked by 223.Nm 224except for 225.Ql CONTINUE? , 226which is assumed to be affirmative; 227do not open the file system for writing. 228.It Fl p 229Specify ``preen'' mode, described above. 230.It Fl y 231Assume a yes response to all questions asked by 232.Nm "" ; 233this should be used with great caution as this is a free license 234to continue after essentially unlimited trouble has been encountered. 235.El 236.Pp 237.Bl -enum -offset indent -compact 238Inconsistencies checked are as follows: 239.It 240Blocks claimed by more than one inode or the free map. 241.It 242Blocks claimed by an inode outside the range of the file system. 243.It 244Incorrect link counts. 245.It 246Size checks: 247.Bl -item -offset indent -compact 248.It 249Directory size not a multiple of DIRBLKSIZ. 250.It 251Partially truncated file. 252.El 253.It 254Bad inode format. 255.It 256Blocks not accounted for anywhere. 257.It 258Directory checks: 259.Bl -item -offset indent -compact 260.It 261File pointing to unallocated inode. 262.It 263Inode number out of range. 264.It 265Dot or dot-dot not the first two entries of a directory 266or having the wrong inode number. 267.El 268.It 269Super Block checks: 270.Bl -item -offset indent -compact 271.It 272More blocks for inodes than there are in the file system. 273.It 274Bad free block map format. 275.It 276Total free block and/or free inode count incorrect. 277.El 278.El 279.Pp 280Orphaned files and directories (allocated but unreferenced) are, 281with the operator's concurrence, reconnected by 282placing them in the 283.Pa lost+found 284directory. 285The name assigned is the inode number. 286If the 287.Pa lost+found 288directory does not exist, it is created. 289If there is insufficient space its size is increased. 290.Pp 291Because of inconsistencies between the block device and the buffer cache, 292the raw device should always be used. 293.Sh DIAGNOSTICS 294The diagnostics produced by 295.Nm 296are fully enumerated and explained in Appendix A of 297.Rs 298.%T "Fsck \- The UNIX File System Check Program" 299.Re 300.Sh SEE ALSO 301.Xr fs 5 , 302.Xr fstab 5 , 303.Xr fsck 8 , 304.Xr fsdb 8 , 305.Xr newfs 8 , 306.Xr reboot 8 307