manual page distributed with 4.1BSD
[unix-history] / usr / src / sbin / fsck / fsck.8
CommitLineData
2d5205c6
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)fsck.8 4.1 (Berkeley) %G%
6.\"
7.TH FSCK 8 "4/1/81"
8.UC 4
9.de us
10\\$1\l'|0\(ul'
11..
12.SH NAME
13fsck \- file system consistency check and interactive repair
14.SH SYNOPSIS
15.B /etc/fsck
16.B \-p
17[
18filesystem ...
19]
20.br
21.B /etc/fsck
22[
23.B \-y
24] [
25.B \-n
26] [
27.BR \-s X
28] [
29.BR \-S X
30] [
31.B \-t
32filename
33] [
34filesystem
35] ...
36.SH DESCRIPTION
37The first form of
38.I fsck
39preens a standard set of filesystems or the specified file systems.
40It is normally used in the script
41.B /etc/rc
42during automatic reboot.
43In this case
44.I fsck
45reads the table
46.B /etc/fstab
47to determine which file systems to check.
48It uses the information there to inspect groups of disks in parallel taking
49maximum advantage of i/o overlap to check the file systems
50as quickly as possible.
51Normally, the root file system will be checked on pass 1, other
52``root'' (``a'' partition) file systems on pass 2, other
53small file systems on separate passes (e.g. the ``d'' file systems
54on pass 3 and the ``e'' file systems on pass 4), and finally
55the large user file systems on the last pass, e.g. pass 5.
56A pass number of 0 in fstab causes a disk to not be checked; similarly
57partitions which are not shown as to be mounted ``rw'' or ``ro''
58are not checked.
59.PP
60The system takes care that only a restricted class of innocuous
61inconsistencies can happen unless hardware or software failures intervene.
62These are limited to the following:
63.IP
64Unreferenced inodes
65.ns
66.IP
67Link counts in inodes too large
68.ns
69.IP
70Missing blocks in the free list
71.ns
72.IP
73Blocks in the free list also in files
74.ns
75.IP
76Counts in the super-block wrong
77.PP
78These are the only inconsistencies which
79.I fsck
80with the
81.B \-p
82option will correct; if it encounters other inconsistencies, it exits
83with an abnormal return status and an automatic reboot will then fail.
84For each corrected inconsistency one or more lines will be printed
85identifying the file system on which the correction will take place,
86and the nature of the correction. After successfully correcting a file
87system,
88.I fsck
89will print the number of files on that file system and the number of
90used and free blocks.
91.PP
92Without the
93.B \-p
94option,
95.I fsck
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 a number of the corrective actions which are not
100fixable under the
101.B \-p
102option will result in some loss
103of data.
104The amount and severity of data lost may be determined from the diagnostic
105output.
106The default action for each consistency correction
107is to wait for the operator to respond \fByes\fP or \fBno\fP.
108If the operator does not have write permission
109.I fsck
110will default to a
111.BR "\-n " action.
112.PP
113.I Fsck
114has more consistency checks than
115its predecessors
116.IR "check, dcheck, fcheck, " "and" " icheck"
117combined.
118.PP
119The following flags are interpreted by
120.I fsck.
121.TP 6
122.B \-y
123Assume a yes response to all questions asked by
124.I fsck;
125this should be used with great caution as this is a free license
126to continue after essentially unlimited trouble has been encountered.
127.TP 6
128.B \-n
129Assume a no response to all questions asked by
130.I fsck;
131do not open the file system for writing.
132.TP 6
133.BR \-s \fIX
134Ignore the actual free list and (unconditionally) reconstruct a new
135one by rewriting the super-block of the file system.
136The file system should be unmounted while this is done; if this
137is not possible, care should be taken that the system is quiescent
138and that it is rebooted immediately afterwards.
139This precaution is necessary so that the old, bad, in-core copy
140of the superblock will not continue to be used, or written on the file system.
141.IP
142The
143.BR \-s \fIX
144option allows for creating an optimal free-list organization.
145The following forms of
146.I X
147are supported for the following devices:
148.sp
149.nf
150 \-s3 (RP03)
151 \-s4 (RP04, RP05, RP06)
152 \-sBlocks-per-cylinder\fB:\fRBlocks-to-skip (for anything else)
153.fi
154.IP "" 6
155If
156.I X
157is not given,
158the values used when the filesystem was created
159are used.
160If these values were not specified, then the value
161.I 400:9
162is used.
163.TP 6
164.BR \-S \fIX
165Conditionally reconstruct the free list. This option
166is like
167.BR \-s \fIX
168above except that the free list is rebuilt only
169if there were no discrepancies discovered in the
170file system. Using
171.B \-S
172will force a no response to all questions asked
173by
174.I fsck.
175This option is useful for forcing free list reorganization
176on uncontaminated file systems.
177.TP 6
178.B \-t
179If
180.I fsck
181cannot obtain enough memory to keep its tables,
182it uses a scratch file. If the \f3\-t\fP option is
183specified, the file named in the next argument
184is used as the scratch file, if needed. Without the
185.BR "\-t " flag,
186.I fsck
187will prompt the operator for the name of the
188scratch file. The file chosen should not be on the
189filesystem being checked, and if it is not
190a special file or did not already exist, it is
191removed when
192.I fsck
193completes.
194.PP
195If no filesystems are given to
196.I fsck
197then a default list of file systems is read from
198the file
199.BR /etc/fstab .
200.PP
201.ne 10
202Inconsistencies checked are as follows:
203.TP 6
2041.
205Blocks claimed by more than one inode or the free list.
206.br
207.br
208.ns
209.TP 6
2102.
211Blocks claimed by an inode or the free list outside the range of the file system.
212.br
213.br
214.ns
215.TP 6
2163.
217Incorrect link counts.
218.br
219.br
220.ns
221.TP 6
2224.
223Size checks:
224.br
225.ns
226.IP "" 12
227Directory size not 16-byte aligned.
228.br
229.br
230.ns
231.TP 6
2325.
233Bad inode format.
234.br
235.br
236.ns
237.TP 6
2386.
239Blocks not accounted for anywhere.
240.br
241.br
242.ns
243.TP 6
2447.
245Directory checks:
246.br
247.br
248.ns
249.IP "" 12
250File pointing to unallocated inode.
251.br
252Inode number out of range.
253.br
254.br
255.ns
256.TP 6
2578.
258Super Block checks:
259.br
260.br
261.ns
262.IP "" 12
263More than 65536 inodes.
264.br
265More blocks for inodes than there are in the file system.
266.br
267.br
268.ns
269.TP 6
2709.
271Bad free block list format.
272.br
273.br
274.ns
275.TP 6
27610.
277Total free block and/or free inode count incorrect.
278.PP
279Orphaned files and directories (allocated but unreferenced) are,
280with the operator's concurrence, reconnected by
281placing them in the
282.B lost+found
283directory.
284The name assigned is the inode number. The only restriction
285is that the directory
286.B lost+found
287must preexist
288in the root of the filesystem being checked and
289must have empty slots in which entries can be made.
290This is accomplished by making
291.BR lost+found ,
292copying a number of files to the directory, and then removing them
293(before
294.I
295fsck
296is executed).
297.PP
298Checking the raw device is almost always faster.
299.SH FILES
300.br
301.ns
302.TP 21
303/etc/fstab
304contains default list of file systems to check.
305.SH DIAGNOSTICS
306The diagnostics produced by
307.I fsck
308are intended to be self-explanatory.
309.SH "SEE ALSO"
310fstab(5), fs(5), crash(8), reboot(8)
311.SH BUGS
312Inode numbers for
313.BR . ""
314and
315.BR .. ""
316in each directory should be checked for validity.
317.PP
318\f3\-g\fP and \f3\-b\fP options from
319.I check
320should be available in
321.I fsck.
322.PP
323There should be some way to start a \fBfsck \-p\fR at pass \fIn\fR.