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