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