BSD 4_3_Tahoe release
[unix-history] / usr / src / man / man8 / 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.\"
ca67e7b4 5.\" @(#)fsck.8 6.4 (Berkeley) 5/5/88
2d5205c6 6.\"
ca67e7b4 7.TH FSCK 8 "May 5, 1988"
2d5205c6
KM
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[
0e46db50
KM
23.B \-b
24block#
25] [
6209594a
KM
26.B \-c
27] [
2d5205c6
KM
28.B \-y
29] [
30.B \-n
31] [
2d5205c6
KM
32filesystem
33] ...
34.SH DESCRIPTION
35The first form of
36.I fsck
37preens a standard set of filesystems or the specified file systems.
38It is normally used in the script
39.B /etc/rc
40during automatic reboot.
41In this case
42.I fsck
43reads the table
44.B /etc/fstab
45to determine which file systems to check.
46It uses the information there to inspect groups of disks in parallel taking
47maximum advantage of i/o overlap to check the file systems
48as quickly as possible.
49Normally, the root file system will be checked on pass 1, other
50``root'' (``a'' partition) file systems on pass 2, other
51small file systems on separate passes (e.g. the ``d'' file systems
52on pass 3 and the ``e'' file systems on pass 4), and finally
53the large user file systems on the last pass, e.g. pass 5.
c27eea89
KM
54Only partitions in fstab that are mounted ``rw'' or ``rq''
55and that have non-zero pass number are checked.
2d5205c6
KM
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
6209594a 67Missing blocks in the free map
2d5205c6
KM
68.ns
69.IP
6209594a 70Blocks in the free map also in files
2d5205c6
KM
71.ns
72.IP
73Counts in the super-block wrong
74.PP
c27eea89 75These are the only inconsistencies that
2d5205c6
KM
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
c27eea89
KM
86will print the number of files on that file system,
87the number of used and free blocks,
88and the percentage of fragmentation.
89.PP
90If sent a QUIT signal,
91.I fsck
92will finish the file system checks, then exit with an abnormal
93return status that causes the automatic reboot to fail.
94This is useful when you wish to finish the file system checks,
95but do not want the machine to come up multiuser.
2d5205c6
KM
96.PP
97Without the
98.B \-p
99option,
100.I fsck
101audits and interactively repairs inconsistent conditions for file systems.
102If the file system is inconsistent the operator is prompted for concurrence
103before each correction is attempted.
c27eea89
KM
104It should be noted that some of the corrective actions which are not
105correctable under the
2d5205c6 106.B \-p
c27eea89 107option will result in some loss of data.
2d5205c6
KM
108The amount and severity of data lost may be determined from the diagnostic
109output.
110The default action for each consistency correction
111is to wait for the operator to respond \fByes\fP or \fBno\fP.
c27eea89 112If the operator does not have write permission on the file system
2d5205c6
KM
113.I fsck
114will default to a
115.BR "\-n " action.
116.PP
117.I Fsck
118has more consistency checks than
119its predecessors
120.IR "check, dcheck, fcheck, " "and" " icheck"
121combined.
122.PP
123The following flags are interpreted by
124.I fsck.
125.TP 6
0e46db50
KM
126.B \-b
127Use the block specified immediately after the flag as
6209594a 128the super block for the file system. Block 32 is usually
0e46db50
KM
129an alternate super block.
130.TP 6
2d5205c6
KM
131.B \-y
132Assume a yes response to all questions asked by
133.I fsck;
134this should be used with great caution as this is a free license
135to continue after essentially unlimited trouble has been encountered.
136.TP 6
137.B \-n
138Assume a no response to all questions asked by
139.I fsck;
140do not open the file system for writing.
6209594a
KM
141.TP 6
142.B \-c
143If the file system is in the old (static table) format,
144convert it to the new (dynamic table) format.
145If the file system is in the new format,
146convert it to the old format provided the old format
147can support the filesystem configuration.
148In interactive mode,
149.I fsck
150will list the direction the conversion is to be made
151and ask whether the conversion should be done.
152If a negative answer is given,
153no further operations are done on the filesystem.
154In preen mode,
155the direction of the conversion is listed and done if
156possible without user interaction.
157Conversion in preen mode is best used when all the file systems
158are being converted at once.
159The format of a file system can be determined from the
160first line of output from
161.IR dumpfs (8).
2d5205c6
KM
162.PP
163If no filesystems are given to
164.I fsck
165then a default list of file systems is read from
166the file
167.BR /etc/fstab .
168.PP
169.ne 10
170Inconsistencies checked are as follows:
171.TP 6
1721.
6209594a 173Blocks claimed by more than one inode or the free map.
2d5205c6
KM
174.br
175.br
176.ns
177.TP 6
1782.
6209594a 179Blocks claimed by an inode outside the range of the file system.
2d5205c6
KM
180.br
181.br
182.ns
183.TP 6
1843.
185Incorrect link counts.
186.br
187.br
188.ns
189.TP 6
1904.
191Size checks:
192.br
193.ns
194.IP "" 12
0e46db50 195Directory size not of proper format.
2d5205c6 196.br
6209594a
KM
197Partially truncated file.
198.br
2d5205c6
KM
199.br
200.ns
201.TP 6
2025.
203Bad inode format.
204.br
205.br
206.ns
207.TP 6
2086.
209Blocks not accounted for anywhere.
210.br
211.br
212.ns
213.TP 6
2147.
215Directory checks:
216.br
217.br
218.ns
219.IP "" 12
220File pointing to unallocated inode.
221.br
222Inode number out of range.
223.br
224.br
225.ns
226.TP 6
2278.
228Super Block checks:
229.br
230.br
231.ns
232.IP "" 12
2d5205c6
KM
233More blocks for inodes than there are in the file system.
234.br
235.br
236.ns
237.TP 6
2389.
6209594a 239Bad free block map format.
2d5205c6
KM
240.br
241.br
242.ns
243.TP 6
24410.
245Total free block and/or free inode count incorrect.
246.PP
247Orphaned files and directories (allocated but unreferenced) are,
248with the operator's concurrence, reconnected by
249placing them in the
250.B lost+found
251directory.
c27eea89
KM
252The name assigned is the inode number.
253If the
254.I lost+found
255directory does not exist, it is created.
256If there is insufficient space its size is increased.
2d5205c6
KM
257.PP
258Checking the raw device is almost always faster.
259.SH FILES
260.br
261.ns
262.TP 21
263/etc/fstab
264contains default list of file systems to check.
265.SH DIAGNOSTICS
266The diagnostics produced by
267.I fsck
c27eea89
KM
268are fully enumerated and explained in Appendix A of
269``Fsck \- The UNIX File System Check Program'' (SMM:5).
2d5205c6 270.SH "SEE ALSO"
0e46db50
KM
271fstab(5),
272fs(5),
8ad6dcc6 273fsdb(8),
0e46db50
KM
274newfs(8),
275mkfs(8),
276crash(8V),
277reboot(8)
2d5205c6 278.SH BUGS
2d5205c6 279There should be some way to start a \fBfsck \-p\fR at pass \fIn\fR.