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