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