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