update for current program
[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.\"
cd156a5e 5.\" @(#)fsck.8 6.8 (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.
cd156a5e 45Here
2d5205c6
KM
46.I fsck
47reads the table
48.B /etc/fstab
49to determine which file systems to check.
922de9ec 50Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
c27eea89 51and that have non-zero pass number are checked.
5eeaeb24
MK
52Filesystems with pass number 1 (normally just the root filesystem)
53are checked one at a time.
54When pass 1 completes, all remaining filesystems are checked,
55running one process per disk drive.
56The disk drive containing each filesystem is inferred from the longest prefix
57of the device name that ends in a digit; the remaining characters are assumed
58to be the partition designator.
2d5205c6
KM
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
6209594a 70Missing blocks in the free map
2d5205c6
KM
71.ns
72.IP
6209594a 73Blocks in the free map also in files
2d5205c6
KM
74.ns
75.IP
76Counts in the super-block wrong
77.PP
c27eea89 78These are the only inconsistencies that
2d5205c6
KM
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
c27eea89
KM
89will print the number of files on that file system,
90the number of used and free blocks,
91and the percentage of fragmentation.
92.PP
93If sent a QUIT signal,
94.I fsck
95will finish the file system checks, then exit with an abnormal
5eeaeb24
MK
96return status that causes an automatic reboot to fail.
97This is useful when to finish the file system checks during an automatic reboot,
98but do not want the machine to come up multiuser after the checks complete.
2d5205c6
KM
99.PP
100Without the
101.B \-p
102option,
103.I fsck
104audits and interactively repairs inconsistent conditions for file systems.
105If the file system is inconsistent the operator is prompted for concurrence
106before each correction is attempted.
c27eea89
KM
107It should be noted that some of the corrective actions which are not
108correctable under the
2d5205c6 109.B \-p
c27eea89 110option will result in some loss of data.
2d5205c6
KM
111The amount and severity of data lost may be determined from the diagnostic
112output.
113The default action for each consistency correction
114is to wait for the operator to respond \fByes\fP or \fBno\fP.
c27eea89 115If the operator does not have write permission on the file system
2d5205c6
KM
116.I fsck
117will default to a
118.BR "\-n " action.
119.PP
120.I Fsck
121has more consistency checks than
122its predecessors
123.IR "check, dcheck, fcheck, " "and" " icheck"
124combined.
125.PP
126The following flags are interpreted by
127.I fsck.
128.TP 6
0e46db50
KM
129.B \-b
130Use the block specified immediately after the flag as
6209594a 131the super block for the file system. Block 32 is usually
0e46db50
KM
132an alternate super block.
133.TP 6
5eeaeb24
MK
134.B \-l
135Limit the number of parallel checks to the number specified in the following
136argument.
137By default, the limit is the number of disks, running one process per disk.
138If a smaller limit is given, the disks are checked round-robin, one filesystem
139at a time.
140.TP 6
c689da7b
KM
141.B \-m
142Use the mode specified in octal immediately after the flag as the
143permission bits to use when creating the lost+found directory
144rather than the default 1777.
145In particular, systems that do not wish to have lost files accessible
146by all users on the system should use a more restrictive
147set of permissions such as 700.
148.TP 6
2d5205c6
KM
149.B \-y
150Assume a yes response to all questions asked by
922de9ec 151.IR fsck ;
2d5205c6
KM
152this should be used with great caution as this is a free license
153to continue after essentially unlimited trouble has been encountered.
154.TP 6
155.B \-n
156Assume a no response to all questions asked by
922de9ec
MK
157.I fsck
158except for ``CONTINUE?'', which is assumed to be affirmative;
2d5205c6 159do not open the file system for writing.
6209594a
KM
160.TP 6
161.B \-c
162If the file system is in the old (static table) format,
163convert it to the new (dynamic table) format.
164If the file system is in the new format,
165convert it to the old format provided the old format
166can support the filesystem configuration.
167In interactive mode,
168.I fsck
169will list the direction the conversion is to be made
170and ask whether the conversion should be done.
171If a negative answer is given,
172no further operations are done on the filesystem.
173In preen mode,
174the direction of the conversion is listed and done if
175possible without user interaction.
176Conversion in preen mode is best used when all the file systems
177are being converted at once.
178The format of a file system can be determined from the
179first line of output from
180.IR dumpfs (8).
2d5205c6
KM
181.PP
182If no filesystems are given to
183.I fsck
184then a default list of file systems is read from
185the file
186.BR /etc/fstab .
187.PP
188.ne 10
189Inconsistencies checked are as follows:
190.TP 6
1911.
6209594a 192Blocks claimed by more than one inode or the free map.
2d5205c6
KM
193.br
194.br
195.ns
196.TP 6
1972.
6209594a 198Blocks claimed by an inode outside the range of the file system.
2d5205c6
KM
199.br
200.br
201.ns
202.TP 6
2033.
204Incorrect link counts.
205.br
206.br
207.ns
208.TP 6
2094.
210Size checks:
211.br
212.ns
213.IP "" 12
0e46db50 214Directory size not of proper format.
2d5205c6 215.br
6209594a
KM
216Partially truncated file.
217.br
2d5205c6
KM
218.br
219.ns
220.TP 6
2215.
222Bad inode format.
223.br
224.br
225.ns
226.TP 6
2276.
228Blocks not accounted for anywhere.
229.br
230.br
231.ns
232.TP 6
2337.
234Directory checks:
235.br
236.br
237.ns
238.IP "" 12
239File pointing to unallocated inode.
240.br
241Inode number out of range.
242.br
cd156a5e
KM
243Dot or dot-dot not the first two entries of a directory
244or having the wrong inode number.
245.br
2d5205c6
KM
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 279.PP
cd156a5e
KM
280Because of inconsistencies between the block device and the buffer cache,
281the raw device should always be used.
2d5205c6
KM
282.SH FILES
283.br
284.ns
285.TP 21
286/etc/fstab
287contains default list of file systems to check.
288.SH DIAGNOSTICS
289The diagnostics produced by
290.I fsck
c27eea89
KM
291are fully enumerated and explained in Appendix A of
292``Fsck \- The UNIX File System Check Program'' (SMM:5).
2d5205c6 293.SH "SEE ALSO"
0e46db50
KM
294fstab(5),
295fs(5),
8ad6dcc6 296fsdb(8),
0e46db50
KM
297newfs(8),
298mkfs(8),
0e46db50 299reboot(8)