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