eliminate last vestages of AT&T code
[unix-history] / usr / src / sbin / fsck / fsck.8
CommitLineData
922de9ec 1.\" Copyright (c) 1980, 1989 Regents of the University of California.
2d5205c6
KM
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5eeaeb24 5.\" @(#)fsck.8 6.7 (Berkeley) %G%
2d5205c6 6.\"
96cc60b3 7.TH FSCK 8 ""
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
922de9ec 15.B fsck
2d5205c6
KM
16.B \-p
17[
c689da7b
KM
18.B \-m
19mode
2d5205c6
KM
20]
21.br
922de9ec 22.B fsck
2d5205c6 23[
0e46db50
KM
24.B \-b
25block#
26] [
6209594a
KM
27.B \-c
28] [
2d5205c6
KM
29.B \-y
30] [
31.B \-n
32] [
c689da7b
KM
33.B \-m
34mode
35] [
2d5205c6
KM
36filesystem
37] ...
38.SH DESCRIPTION
39The first form of
40.I fsck
41preens a standard set of filesystems or the specified file systems.
42It is normally used in the script
43.B /etc/rc
44during automatic reboot.
45In this case
46.I fsck
47reads the table
48.B /etc/fstab
49to determine which file systems to check.
922de9ec 50It uses the information there to inspect groups of disks in parallel, taking
2d5205c6
KM
51maximum advantage of i/o overlap to check the file systems
52as quickly as possible.
922de9ec 53Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
c27eea89 54and that have non-zero pass number are checked.
5eeaeb24
MK
55Filesystems with pass number 1 (normally just the root filesystem)
56are checked one at a time.
57When pass 1 completes, all remaining filesystems are checked,
58running one process per disk drive.
59The disk drive containing each filesystem is inferred from the longest prefix
60of the device name that ends in a digit; the remaining characters are assumed
61to be the partition designator.
2d5205c6
KM
62.PP
63The system takes care that only a restricted class of innocuous
64inconsistencies can happen unless hardware or software failures intervene.
65These are limited to the following:
66.IP
67Unreferenced inodes
68.ns
69.IP
70Link counts in inodes too large
71.ns
72.IP
6209594a 73Missing blocks in the free map
2d5205c6
KM
74.ns
75.IP
6209594a 76Blocks in the free map also in files
2d5205c6
KM
77.ns
78.IP
79Counts in the super-block wrong
80.PP
c27eea89 81These are the only inconsistencies that
2d5205c6
KM
82.I fsck
83with the
84.B \-p
85option will correct; if it encounters other inconsistencies, it exits
86with an abnormal return status and an automatic reboot will then fail.
87For each corrected inconsistency one or more lines will be printed
88identifying the file system on which the correction will take place,
89and the nature of the correction. After successfully correcting a file
90system,
91.I fsck
c27eea89
KM
92will print the number of files on that file system,
93the number of used and free blocks,
94and the percentage of fragmentation.
95.PP
96If sent a QUIT signal,
97.I fsck
98will finish the file system checks, then exit with an abnormal
5eeaeb24
MK
99return status that causes an automatic reboot to fail.
100This is useful when to finish the file system checks during an automatic reboot,
101but do not want the machine to come up multiuser after the checks complete.
2d5205c6
KM
102.PP
103Without the
104.B \-p
105option,
106.I fsck
107audits and interactively repairs inconsistent conditions for file systems.
108If the file system is inconsistent the operator is prompted for concurrence
109before each correction is attempted.
c27eea89
KM
110It should be noted that some of the corrective actions which are not
111correctable under the
2d5205c6 112.B \-p
c27eea89 113option will result in some loss of data.
2d5205c6
KM
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 \fByes\fP or \fBno\fP.
c27eea89 118If the operator does not have write permission on the file system
2d5205c6
KM
119.I fsck
120will default to a
121.BR "\-n " action.
122.PP
123.I Fsck
124has more consistency checks than
125its predecessors
126.IR "check, dcheck, fcheck, " "and" " icheck"
127combined.
128.PP
129The following flags are interpreted by
130.I fsck.
131.TP 6
0e46db50
KM
132.B \-b
133Use the block specified immediately after the flag as
6209594a 134the super block for the file system. Block 32 is usually
0e46db50
KM
135an alternate super block.
136.TP 6
5eeaeb24
MK
137.B \-l
138Limit the number of parallel checks to the number specified in the following
139argument.
140By default, the limit is the number of disks, running one process per disk.
141If a smaller limit is given, the disks are checked round-robin, one filesystem
142at a time.
143.TP 6
c689da7b
KM
144.B \-m
145Use the mode specified in octal immediately after the flag as the
146permission bits to use when creating the lost+found directory
147rather than the default 1777.
148In particular, systems that do not wish to have lost files accessible
149by all users on the system should use a more restrictive
150set of permissions such as 700.
151.TP 6
2d5205c6
KM
152.B \-y
153Assume a yes response to all questions asked by
922de9ec 154.IR fsck ;
2d5205c6
KM
155this should be used with great caution as this is a free license
156to continue after essentially unlimited trouble has been encountered.
157.TP 6
158.B \-n
159Assume a no response to all questions asked by
922de9ec
MK
160.I fsck
161except for ``CONTINUE?'', which is assumed to be affirmative;
2d5205c6 162do not open the file system for writing.
6209594a
KM
163.TP 6
164.B \-c
165If the file system is in the old (static table) format,
166convert it to the new (dynamic table) format.
167If the file system is in the new format,
168convert it to the old format provided the old format
169can support the filesystem configuration.
170In interactive mode,
171.I fsck
172will list the direction the conversion is to be made
173and ask whether the conversion should be done.
174If a negative answer is given,
175no further operations are done on the filesystem.
176In preen mode,
177the direction of the conversion is listed and done if
178possible without user interaction.
179Conversion in preen mode is best used when all the file systems
180are being converted at once.
181The format of a file system can be determined from the
182first line of output from
183.IR dumpfs (8).
2d5205c6
KM
184.PP
185If no filesystems are given to
186.I fsck
187then a default list of file systems is read from
188the file
189.BR /etc/fstab .
190.PP
191.ne 10
192Inconsistencies checked are as follows:
193.TP 6
1941.
6209594a 195Blocks claimed by more than one inode or the free map.
2d5205c6
KM
196.br
197.br
198.ns
199.TP 6
2002.
6209594a 201Blocks claimed by an inode outside the range of the file system.
2d5205c6
KM
202.br
203.br
204.ns
205.TP 6
2063.
207Incorrect link counts.
208.br
209.br
210.ns
211.TP 6
2124.
213Size checks:
214.br
215.ns
216.IP "" 12
0e46db50 217Directory size not of proper format.
2d5205c6 218.br
6209594a
KM
219Partially truncated file.
220.br
2d5205c6
KM
221.br
222.ns
223.TP 6
2245.
225Bad inode format.
226.br
227.br
228.ns
229.TP 6
2306.
231Blocks not accounted for anywhere.
232.br
233.br
234.ns
235.TP 6
2367.
237Directory checks:
238.br
239.br
240.ns
241.IP "" 12
242File pointing to unallocated inode.
243.br
244Inode number out of range.
245.br
246.br
247.ns
248.TP 6
2498.
250Super Block checks:
251.br
252.br
253.ns
254.IP "" 12
2d5205c6
KM
255More blocks for inodes than there are in the file system.
256.br
257.br
258.ns
259.TP 6
2609.
6209594a 261Bad free block map format.
2d5205c6
KM
262.br
263.br
264.ns
265.TP 6
26610.
267Total free block and/or free inode count incorrect.
268.PP
269Orphaned files and directories (allocated but unreferenced) are,
270with the operator's concurrence, reconnected by
271placing them in the
272.B lost+found
273directory.
c27eea89
KM
274The name assigned is the inode number.
275If the
276.I lost+found
277directory does not exist, it is created.
278If there is insufficient space its size is increased.
2d5205c6
KM
279.PP
280Checking the raw device is almost always faster.
281.SH FILES
282.br
283.ns
284.TP 21
285/etc/fstab
286contains default list of file systems to check.
287.SH DIAGNOSTICS
288The diagnostics produced by
289.I fsck
c27eea89
KM
290are fully enumerated and explained in Appendix A of
291``Fsck \- The UNIX File System Check Program'' (SMM:5).
2d5205c6 292.SH "SEE ALSO"
0e46db50
KM
293fstab(5),
294fs(5),
8ad6dcc6 295fsdb(8),
0e46db50
KM
296newfs(8),
297mkfs(8),
298crash(8V),
299reboot(8)
2d5205c6 300.SH BUGS
2d5205c6 301There should be some way to start a \fBfsck \-p\fR at pass \fIn\fR.