1.\" $NetBSD: fsck_ext2fs.8,v 1.10 2002/10/01 13:40:30 wiz 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. 58It is normally invoked from 59.Xr fsck 8 . 60.Pp 61The kernel takes care that only a restricted class of innocuous filesystem 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 filesystem on which the correction will take place, 87and the nature of the correction. 88After successfully correcting a filesystem, 89.Nm 90will print the number of files on that filesystem 91and the number of used and free blocks. 92.Pp 93If sent a 94.Dv QUIT 95signal, 96.Nm 97will finish the filesystem checks, then exit with an abnormal return status. 98.Pp 99Without the 100.Fl p 101option, 102.Nm 103audits and interactively repairs inconsistent conditions for filesystems. 104If the filesystem is inconsistent the operator is prompted for concurrence 105before each correction is attempted. 106It should be noted that some of the corrective actions which are not 107correctable under the 108.Fl p 109option will result in some loss of data. 110The amount and severity of data lost may be determined from the diagnostic 111output. 112The default action for each consistency correction 113is to wait for the operator to respond 114.Li yes 115or 116.Li no . 117If the operator does not have write permission on the filesystem 118.Nm 119will default to a 120.Fl n 121action. 122.Pp 123The following flags are interpreted by 124.Nm "" . 125.Bl -tag -width indent 126.It Fl b 127Use the block specified immediately after the flag as 128the super block for the filesystem. 129Block 8193 is usually an alternate super block. 130.It Fl d 131Print debugging output. 132.It Fl f 133Force checking of file systems. 134Normally, if a file system is cleanly unmounted, the kernel will set a 135.Dq clean flag 136in the file system superblock, and 137.Nm 138will not check the file system. 139This option forces 140.Nm 141to check the file system, regardless of the state of the clean flag. 142.It Fl m 143Use the mode specified in octal immediately after the flag as the 144permission bits to use when creating the 145.Pa lost+found 146directory rather than the default 1777. 147In particular, systems that do not wish to have lost files accessible 148by all users on the system should use a more restrictive 149set of permissions such as 700. 150.It Fl n 151Assume a no response to all questions asked by 152.Nm 153except for 154.Ql CONTINUE? , 155which is assumed to be affirmative; 156do not open the filesystem for writing. 157.It Fl p 158Specify ``preen'' mode, described above. 159.It Fl y 160Assume a yes response to all questions asked by 161.Nm "" ; 162this should be used with great caution as this is a free license 163to continue after essentially unlimited trouble has been encountered. 164.El 165.Pp 166.Bl -enum -offset indent -compact 167Inconsistencies checked are as follows: 168.It 169Blocks claimed by more than one inode or the free map. 170.It 171Blocks claimed by an inode outside the range of the filesystem. 172.It 173Incorrect link counts. 174.It 175Size checks: 176.Bl -item -offset indent -compact 177.It 178Directory size not a multiple of filesystem block size. 179.It 180Partially truncated file. 181.El 182.It 183Bad inode format. 184.It 185Blocks not accounted for anywhere. 186.It 187Directory checks: 188.Bl -item -offset indent -compact 189.It 190File pointing to unallocated inode. 191.It 192Inode number out of range. 193.It 194Dot or dot-dot not the first two entries of a directory 195or having the wrong inode number. 196.El 197.It 198Super Block checks: 199.Bl -item -offset indent -compact 200.It 201More blocks for inodes than there are in the filesystem. 202.It 203Bad free block map format. 204.It 205Total free block and/or free inode count incorrect. 206.El 207.El 208.Pp 209Orphaned files and directories (allocated but unreferenced) are, 210with the operator's concurrence, reconnected by 211placing them in the 212.Pa lost+found 213directory. 214The name assigned is the inode number. 215If the 216.Pa lost+found 217directory does not exist, it is created. 218If there is insufficient space its size is increased. 219.Pp 220Because of inconsistencies between the block device and the buffer cache, 221the raw device should always be used. 222.Sh DIAGNOSTICS 223The diagnostics produced by 224.Nm 225are fully enumerated and explained in Appendix A of 226.Rs 227.%T "Fsck \- The UNIX File System Check Program" 228.Re 229.Sh SEE ALSO 230.Xr fs 5 , 231.Xr fstab 5 , 232.Xr fsck 8 , 233.Xr fsdb 8 , 234.Xr newfs 8 , 235.Xr reboot 8 236