xref: /freebsd/sbin/fsck_ffs/fsck_ffs.8 (revision 952d112864d8008aa87278a30a539d888a8493cd)
1.\" Copyright (c) 1980, 1989, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. 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.4 (Berkeley) 5/9/95
33.\"	$Id: fsck.8,v 1.9 1997/03/11 12:19:36 peter Exp $
34.\"
35.Dd May 9, 1995
36.Dt FSCK 8
37.Os BSD 4
38.Sh NAME
39.Nm fsck
40.Nd filesystem consistency check and interactive repair
41.Sh SYNOPSIS
42.Nm fsck
43.Fl p
44.Op Fl f
45.Op Fl m Ar mode
46.Nm fsck
47.Op Fl b Ar block#
48.Op Fl c Ar level
49.Op Fl l Ar maxparallel
50.Op Fl y
51.Op Fl n
52.Op Fl m Ar mode
53.Op Ar filesystem
54.Ar ...
55.Sh DESCRIPTION
56The first form of
57.Nm fsck
58preens a standard set of filesystems or the specified filesystems.
59It is normally used in the script
60.Pa /etc/rc
61during automatic reboot.
62Here
63.Nm fsck
64reads the table
65.Pa /etc/fstab
66to determine which filesystems to check.
67Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
68and that have non-zero pass number are checked.
69Filesystems with pass number 1 (normally just the root filesystem)
70are checked one at a time.
71When pass 1 completes, all remaining filesystems are checked,
72running one process per disk drive.
73The disk drive containing each filesystem is inferred from the longest prefix
74of the device name that ends in a digit; the remaining characters are assumed
75to be the partition designator.
76.Pp
77The clean flag of each filesystem's superblock is examined and only those filesystems that
78are not marked clean are checked.
79Filesystems are marked clean when they are unmounted,
80when they have been mounted read-only, or when
81.Nm fsck
82runs on them successfully.
83If the
84.Fl f
85option is specified, the filesystems
86will be checked regardless of the state of their clean flag.
87.Pp
88The kernel takes care that only a restricted class of innocuous filesystem
89inconsistencies can happen unless hardware or software failures intervene.
90These are limited to the following:
91.Bl -item -compact
92.It
93Unreferenced inodes
94.It
95Link counts in inodes too large
96.It
97Missing blocks in the free map
98.It
99Blocks in the free map also in files
100.It
101Counts in the super-block wrong
102.El
103.Pp
104These are the only inconsistencies that
105.Nm fsck
106with the
107.Fl p
108option will correct; if it encounters other inconsistencies, it exits
109with an abnormal return status and an automatic reboot will then fail.
110For each corrected inconsistency one or more lines will be printed
111identifying the filesystem on which the correction will take place,
112and the nature of the correction.  After successfully correcting a filesystem,
113.Nm fsck
114will print the number of files on that filesystem,
115the number of used and free blocks,
116and the percentage of fragmentation.
117.Pp
118If sent a
119.Dv QUIT
120signal,
121.Nm fsck
122will finish the filesystem checks, then exit with an abnormal
123return status that causes an automatic reboot to fail.
124This is useful when you want to finish the filesystem checks during an
125automatic reboot,
126but do not want the machine to come up multiuser after the checks complete.
127.Pp
128Without the
129.Fl p
130option,
131.Nm fsck
132audits and interactively repairs inconsistent conditions for filesystems.
133If the filesystem is inconsistent the operator is prompted for concurrence
134before each correction is attempted.
135It should be noted that some of the corrective actions which are not
136correctable under the
137.Fl p
138option will result in some loss of data.
139The amount and severity of data lost may be determined from the diagnostic
140output.
141The default action for each consistency correction
142is to wait for the operator to respond
143.Li yes
144or
145.Li no .
146If the operator does not have write permission on the filesystem
147.Nm fsck
148will default to a
149.Fl n
150action.
151.Pp
152.Nm Fsck
153has more consistency checks than
154its predecessors
155.Em check , dcheck , fcheck ,
156and
157.Em icheck
158combined.
159.Pp
160The following flags are interpreted by
161.Nm fsck .
162.Bl -tag -width indent
163.It Fl b
164Use the block specified immediately after the flag as
165the super block for the filesystem.  Block 32 is usually
166an alternate super block.
167.It Fl l
168Limit the number of parallel checks to the number specified in the following
169argument.
170By default, the limit is the number of disks, running one process per disk.
171If a smaller limit is given, the disks are checked round-robin, one filesystem
172at a time.
173.It Fl m
174Use the mode specified in octal immediately after the flag as the
175permission bits to use when creating the
176.Pa lost+found
177directory rather than the default 1777.
178In particular, systems that do not wish to have lost files accessible
179by all users on the system should use a more restrictive
180set of permissions such as 700.
181.It Fl y
182Assume a yes response to all questions asked by
183.Nm fsck ;
184this should be used with great caution as this is a free license
185to continue after essentially unlimited trouble has been encountered.
186.It Fl n
187Assume a no response to all questions asked by
188.Nm fsck
189except for
190.Ql CONTINUE? ,
191which is assumed to be affirmative;
192do not open the filesystem for writing.
193.It Fl c
194Convert the filesystem to the specified level.
195Note that the level of a filesystem can only be raised.
196.Bl -tag -width indent
197There are currently four levels defined:
198.It 0
199The filesystem is in the old (static table) format.
200.It 1
201The filesystem is in the new (dynamic table) format.
202.It 2
203The filesystem supports 32-bit uid's and gid's,
204short symbolic links are stored in the inode,
205and directories have an added field showing the file type.
206.It 3
207If maxcontig is greater than one,
208build the free segment maps to aid in finding contiguous sets of blocks.
209If maxcontig is equal to one, delete any existing segment maps.
210.El
211.Pp
212In interactive mode,
213.Nm fsck
214will list the conversion to be made
215and ask whether the conversion should be done.
216If a negative answer is given,
217no further operations are done on the filesystem.
218In preen mode,
219the conversion is listed and done if
220possible without user interaction.
221Conversion in preen mode is best used when all the filesystems
222are being converted at once.
223The format of a filesystem can be determined from the
224first line of output from
225.Xr dumpfs 8 .
226.El
227.Pp
228If no filesystems are given to
229.Nm fsck
230then a default list of filesystems is read from
231the file
232.Pa /etc/fstab .
233.Pp
234.Bl -enum -indent indent -compact
235Inconsistencies checked are as follows:
236.It
237Blocks claimed by more than one inode or the free map.
238.It
239Blocks claimed by an inode outside the range of the filesystem.
240.It
241Incorrect link counts.
242.It
243Size checks:
244.Bl -item -indent indent -compact
245.It
246Directory size not a multiple of DIRBLKSIZ.
247.It
248Partially truncated file.
249.El
250.It
251Bad inode format.
252.It
253Blocks not accounted for anywhere.
254.It
255Directory checks:
256.Bl -item -indent indent -compact
257.It
258File pointing to unallocated inode.
259.It
260Inode number out of range.
261.It
262Holes in directories.
263.It
264Dot or dot-dot not the first two entries of a directory
265or having the wrong inode number.
266.El
267.It
268Super Block checks:
269.Bl -item -indent indent -compact
270.It
271More blocks for inodes than there are in the filesystem.
272.It
273Bad free block map format.
274.It
275Total free block and/or free inode count incorrect.
276.El
277.El
278.Pp
279Orphaned files and directories (allocated but unreferenced) are,
280with the operator's concurrence, reconnected by
281placing them in the
282.Pa lost+found
283directory.
284The name assigned is the inode number.
285If the
286.Pa lost+found
287directory does not exist, it is created.
288If there is insufficient space its size is increased.
289.Pp
290Because of inconsistencies between the block device and the buffer cache,
291the raw device should always be used.
292.Sh FILES
293.Bl -tag -width /etc/fstab -compact
294.It Pa /etc/fstab
295contains default list of filesystems to check.
296.El
297.Sh DIAGNOSTICS
298The diagnostics produced by
299.Nm fsck
300are fully enumerated and explained in Appendix A of
301.Rs
302.%T "Fsck \- The UNIX File System Check Program"
303.Re
304.Sh SEE ALSO
305.Xr fs 5 ,
306.Xr fstab 5 ,
307.Xr fsdb 8 ,
308.Xr newfs 8 ,
309.Xr reboot 8
310