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