1.\" $NetBSD: fsck_ext2fs.8,v 1.9 2002/02/07 03:15:07 ross Exp $ 2.\" 3.\" Copyright (c) 1997 Manuel Bouyer. 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. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)fsck.8 8.3 (Berkeley) 11/29/94 36.\" 37.Dd November 29, 1994 38.Dt FSCK_EXT2FS 8 39.Os 40.Sh NAME 41.Nm fsck_ext2fs 42.Nd EXT2 File System consistency check and interactive repair 43.Sh SYNOPSIS 44.Nm "" 45.Op Fl b Ar block# 46.Op Fl c Ar level 47.Op Fl d 48.Op Fl f 49.Op Fl m Ar mode 50.Op Fl p 51.Op Fl y 52.Op Fl n 53.Ar filesystem ... 54.Sh DESCRIPTION 55.Nm 56performs interactive filesystem consistency checks and repair for each of 57the filesystems specified on the command line. It is normally invoked from 58.Xr fsck 8 . 59.Pp 60The kernel takes care that only a restricted class of innocuous filesystem 61inconsistencies can happen unless hardware or software failures intervene. 62These are limited to the following: 63.Pp 64.Bl -item -compact 65.It 66Unreferenced inodes 67.It 68Link counts in inodes too large 69.It 70Missing blocks in the free map 71.It 72Blocks in the free map also in files 73.It 74Counts in the super-block wrong 75.El 76.Pp 77These are the only inconsistencies that 78.Nm 79in ``preen'' 80mode (with the 81.Fl p 82option) will correct; if it encounters other inconsistencies, it exits 83with an abnormal return status. 84For each corrected inconsistency one or more lines will be printed 85identifying the filesystem on which the correction will take place, 86and the nature of the correction. After successfully correcting a filesystem, 87.Nm 88will print the number of files on that filesystem 89and the number of used and free blocks. 90.Pp 91If sent a 92.Dv QUIT 93signal, 94.Nm 95will finish the filesystem checks, then exit with an abnormal return status. 96.Pp 97Without the 98.Fl p 99option, 100.Nm 101audits and interactively repairs inconsistent conditions for filesystems. 102If the filesystem is inconsistent the operator is prompted for concurrence 103before each correction is attempted. 104It should be noted that some of the corrective actions which are not 105correctable under the 106.Fl p 107option will result in some loss of data. 108The amount and severity of data lost may be determined from the diagnostic 109output. 110The default action for each consistency correction 111is to wait for the operator to respond 112.Li yes 113or 114.Li no . 115If the operator does not have write permission on the filesystem 116.Nm 117will default to a 118.Fl n 119action. 120.Pp 121The following flags are interpreted by 122.Nm "" . 123.Bl -tag -width indent 124.It Fl b 125Use the block specified immediately after the flag as 126the super block for the filesystem. Block 8193 is usually 127an alternate super block. 128.It Fl d 129Print debugging output. 130.It Fl f 131Force checking of file systems. Normally, if a file system is cleanly 132unmounted, the kernel will set a 133.Dq clean flag 134in the file system superblock, and 135.Nm 136will not check the file system. This option forces 137.Nm 138to check the file system, regardless of the state of the clean flag. 139.It Fl m 140Use the mode specified in octal immediately after the flag as the 141permission bits to use when creating the 142.Pa lost+found 143directory rather than the default 1777. 144In particular, systems that do not wish to have lost files accessible 145by all users on the system should use a more restrictive 146set of permissions such as 700. 147.It Fl n 148Assume a no response to all questions asked by 149.Nm 150except for 151.Ql CONTINUE? , 152which is assumed to be affirmative; 153do not open the filesystem for writing. 154.It Fl p 155Specify ``preen'' mode, described above. 156.It Fl y 157Assume a yes response to all questions asked by 158.Nm "" ; 159this should be used with great caution as this is a free license 160to continue after essentially unlimited trouble has been encountered. 161.El 162.Pp 163.Bl -enum -offset indent -compact 164Inconsistencies checked are as follows: 165.It 166Blocks claimed by more than one inode or the free map. 167.It 168Blocks claimed by an inode outside the range of the filesystem. 169.It 170Incorrect link counts. 171.It 172Size checks: 173.Bl -item -offset indent -compact 174.It 175Directory size not a multiple of filesystem block size. 176.It 177Partially truncated file. 178.El 179.It 180Bad inode format. 181.It 182Blocks not accounted for anywhere. 183.It 184Directory checks: 185.Bl -item -offset indent -compact 186.It 187File pointing to unallocated inode. 188.It 189Inode number out of range. 190.It 191Dot or dot-dot not the first two entries of a directory 192or having the wrong inode number. 193.El 194.It 195Super Block checks: 196.Bl -item -offset indent -compact 197.It 198More blocks for inodes than there are in the filesystem. 199.It 200Bad free block map format. 201.It 202Total free block and/or free inode count incorrect. 203.El 204.El 205.Pp 206Orphaned files and directories (allocated but unreferenced) are, 207with the operator's concurrence, reconnected by 208placing them in the 209.Pa lost+found 210directory. 211The name assigned is the inode number. 212If the 213.Pa lost+found 214directory does not exist, it is created. 215If there is insufficient space its size is increased. 216.Pp 217Because of inconsistencies between the block device and the buffer cache, 218the raw device should always be used. 219.Sh DIAGNOSTICS 220The diagnostics produced by 221.Nm 222are fully enumerated and explained in Appendix A of 223.Rs 224.%T "Fsck \- The UNIX File System Check Program" 225.Re 226.Sh SEE ALSO 227.Xr fs 5 , 228.Xr fstab 5 , 229.Xr fsck 8 , 230.Xr fsdb 8 , 231.Xr newfs 8 , 232.Xr reboot 8 233