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