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