xref: /openbsd/sbin/fsck_ffs/fsck_ffs.8 (revision 09467b48)
1.\"	$OpenBSD: fsck_ffs.8,v 1.26 2016/09/01 13:48:15 otto Exp $
2.\"	$NetBSD: fsck_ffs.8,v 1.12 1996/09/23 16:18:34 christos Exp $
3.\"
4.\" Copyright (c) 1980, 1989, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	@(#)fsck.8	8.3 (Berkeley) 11/29/94
32.\"
33.Dd $Mdocdate: September 1 2016 $
34.Dt FSCK_FFS 8
35.Os
36.Sh NAME
37.Nm fsck_ffs
38.Nd Fast File System consistency check and interactive repair
39.Sh SYNOPSIS
40.Nm fsck_ffs
41.Op Fl fnpy
42.Op Fl b Ar block#
43.Op Fl c Ar level
44.Op Fl m Ar mode
45.Ar filesystem
46.Sh DESCRIPTION
47.Nm
48performs interactive file system consistency checks and repairs the
49file system 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
72with the
73.Fl p
74option will correct; if it encounters other inconsistencies, it exits
75with an abnormal return status and an automatic reboot will then fail.
76For each corrected inconsistency, one or more lines will be printed
77identifying the file system on which the correction will take place
78along with the nature of the correction.
79After successfully correcting a file system,
80.Nm
81will print the number of files on that file system,
82the number of used and free blocks,
83and the percentage of fragmentation.
84.Pp
85If sent a
86.Dv QUIT
87signal,
88.Nm
89will finish the file system checks, then exit with an abnormal
90return status that causes an automatic reboot to fail.
91This is useful when you want to finish the file system checks during an
92automatic reboot,
93but do not want the machine to come up multiuser after the checks complete.
94.Pp
95If sent an
96.Dv INFO
97signal,
98.Nm
99will print a line to standard error indicating the name of the device
100currently being checked, the current phase number, and phase-specific
101progress information.
102.Pp
103Without the
104.Fl p
105option,
106.Nm
107audits and interactively repairs inconsistent conditions for the filesystem.
108If the file system is inconsistent, the operator is prompted for concurrence
109before each correction is attempted.
110It should be noted that some of the corrective actions which are not
111correctable under the
112.Fl p
113option will result in some loss of data.
114The amount and severity of data lost may be determined from the diagnostic
115output.
116The default action for each consistency correction
117is to wait for the operator to respond
118.Dq yes
119or
120.Dq no .
121If the operator does not have write permission on the file system,
122.Nm
123will default to a
124.Fl n
125action.
126.Pp
127.Nm fsck
128has more consistency checks than
129its predecessors
130.Em check , dcheck , fcheck ,
131and
132.Em icheck
133combined.
134.Pp
135The following flags are interpreted by
136.Nm fsck_ffs :
137.Bl -tag -width indent
138.It Fl b Ar block#
139Use the
140.Ar block#
141specified as
142the super block for the file system.
143If the primary superblock is corrupted
144.Nm
145tries to find a valid alternate superblock based on the
146information in the disklabel.
147If that fails, a number printed by
148.Nm newfs
149(using
150.Fl N
151combined with the original flags used to create the filesystem)
152can be used as a value to this argument.
153.It Fl c Ar level
154Convert the file system to the specified
155.Ar level .
156Note that the level of a file system can only be raised.
157There are currently four levels defined:
158.Bl -tag -width indent
159.It 0
160The file system is in the old (static table) format.
161.It 1
162The file system is in the new (dynamic table) format.
163.It 2
164The file system supports 32-bit UIDs and GIDs,
165short symbolic links are stored in the inode,
166and directories have an added field showing the file type.
167.It 3
168If
169.Va maxcontig
170is greater than one,
171build the free segment maps to aid in finding contiguous sets of blocks.
172If
173.Va maxcontig
174is equal to one, delete any existing segment maps.
175.El
176.It Fl f
177Force checking of the filesystem.
178Normally, if a file system is cleanly unmounted, the kernel will set a
179.Dq clean flag
180in the file system superblock and
181.Nm
182will not check the file system.
183This option forces
184.Nm
185to check the file system, regardless of the state of the clean flag.
186.It Fl m Ar mode
187Use the
188.Ar mode
189specified in octal as the
190permission bits to use when creating the
191.Pa lost+found
192directory rather than the default 1700.
193In particular, systems that wish to have lost files accessible
194by all users on the system should use a less restrictive
195set of permissions such as 755.
196.It Fl n
197Assume a
198.Dq no
199response to all questions asked by
200.Nm
201except for
202.Dq CONTINUE? ,
203which is assumed to be affirmative.
204The filesystem will not be opened for writing.
205This is the default for file systems to be checked that are
206concurrently mounted writable.
207.It Fl p
208Enter preen mode:
209.Nm
210will check the filesystem on the
211special (raw) device listed on the command line
212and will make minor repairs without
213human intervention.
214Any major problems will cause
215.Nm
216to exit with a non-zero exit code,
217so as to alert any invoking program or script
218that human intervention is required.
219.It Fl y
220Assume a
221.Dq yes
222response to all questions asked by
223.Nm fsck_ffs ;
224this should be used with great caution as this is a free license
225to continue after essentially unlimited trouble has been encountered.
226.El
227.Pp
228If neither of the
229.Fl y
230or
231.Fl n
232options are specified, the user may force
233.Nm
234to assume an answer of
235.Dq yes
236to all the remaining questions by replying to a question with a value of
237.Dq F .
238.Pp
239In interactive mode,
240.Nm
241will list the conversion to be made
242and ask whether the conversion should be done.
243If a negative answer is given,
244no further operations are done on the file system.
245In preen mode,
246the conversion is listed and done if
247possible without user interaction.
248Conversion in preen mode is best used when all the file systems
249are being converted at once.
250The format of a file system can be determined from the
251first line of output from
252.Xr dumpfs 8 .
253.Pp
254Inconsistencies checked are as follows:
255.Pp
256.Bl -enum -compact
257.It
258Blocks claimed more than once by inodes or the free map.
259.It
260Blocks claimed by an inode outside the range of the file system.
261.It
262Incorrect link counts.
263.It
264Size checks:
265.Bl -item -compact -offset indent
266.It
267Directory size not a multiple of
268.Dv DIRBLKSIZ .
269.It
270Partially truncated file.
271.El
272.It
273Bad inode format.
274.It
275Blocks not accounted for anywhere.
276.It
277Directory checks:
278.Bl -item -compact -offset indent
279.It
280File pointing to unallocated inode.
281.It
282Inode number out of range.
283.It
284Dot or dot-dot not the first two entries of a directory
285or having the wrong inode number.
286.El
287.It
288Super Block checks:
289.Bl -item -compact -offset indent
290.It
291More blocks for inodes than there are in the file system.
292.It
293Bad free block map format.
294.It
295Total free block and/or free inode count incorrect.
296.El
297.El
298.Pp
299Orphaned files and directories (allocated but unreferenced) are,
300with the operator's concurrence, reconnected by
301placing them in the
302.Pa lost+found
303directory.
304The name assigned is the inode number.
305If the
306.Pa lost+found
307directory does not exist, it is created.
308If there is insufficient space its size is increased.
309.Pp
310Because of inconsistencies between the block device and the buffer cache,
311the raw device should always be used.
312.Sh DIAGNOSTICS
313The diagnostics produced by
314.Nm
315are fully enumerated and explained in Appendix A of
316.Rs
317.%T "Fsck_ffs \- The UNIX File System Check Program"
318.Re
319.Sh SEE ALSO
320.Xr fs 5 ,
321.Xr fstab 5 ,
322.Xr fsck 8 ,
323.Xr fsdb 8 ,
324.Xr growfs 8 ,
325.Xr mount_ffs 8 ,
326.Xr newfs 8 ,
327.Xr rc 8 ,
328.Xr scan_ffs 8
329