xref: /openbsd-src/sbin/fsck_ext2fs/fsck_ext2fs.8 (revision 41ce3b17e73f6b7d2d9e1a3d961e4bab2d895cb5)
1.\"	$OpenBSD: fsck_ext2fs.8,v 1.19 2022/03/31 17:27:19 naddy 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: March 31 2022 $
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
49the filesystem 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 the filesystem.
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 the filesystem.
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.
153The filesystem 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
169If neither of the
170.Fl y
171or
172.Fl n
173options are specified, the user may force
174.Nm
175to assume an answer of
176.Dq yes
177to all the remaining questions by replying to a question with a value of
178.Dq F .
179.Pp
180Inconsistencies checked are as follows:
181.Pp
182.Bl -enum -compact
183.It
184Blocks claimed more than once by inodes or the free map.
185.It
186Blocks claimed by an inode outside the range of the file system.
187.It
188Incorrect link counts.
189.It
190Size checks:
191.Bl -item -compact -offset indent
192.It
193Directory size not a multiple of file system block size.
194.It
195Partially truncated file.
196.El
197.It
198Bad inode format.
199.It
200Blocks not accounted for anywhere.
201.It
202Directory checks:
203.Bl -item -compact -offset indent
204.It
205File pointing to unallocated inode.
206.It
207Inode number out of range.
208.It
209Dot or dot-dot not the first two entries of a directory
210or having the wrong inode number.
211.El
212.It
213Super Block checks:
214.Bl -item -compact -offset indent
215.It
216More blocks for inodes than there are in the file system.
217.It
218Bad free block map format.
219.It
220Total free block and/or free inode count incorrect.
221.El
222.El
223.Pp
224Orphaned files and directories (allocated but unreferenced) are,
225with the operator's concurrence, reconnected by
226placing them in the
227.Pa lost+found
228directory.
229The name assigned is the inode number.
230If the
231.Pa lost+found
232directory does not exist, it is created.
233If there is insufficient space, its size is increased.
234.Pp
235Because of inconsistencies between the block device and the buffer cache,
236the raw device should always be used.
237.Sh DIAGNOSTICS
238The diagnostics produced by
239.Nm
240are fully enumerated and explained in Appendix A of
241.Rs
242.%T "Fsck_ffs \- The UNIX File System Check Program"
243.Re
244.Sh SEE ALSO
245.Xr fs 5 ,
246.Xr fstab 5 ,
247.Xr fsck 8 ,
248.Xr mount_ext2fs 8 ,
249.Xr rc 8
250