386BSD 0.1 development
[unix-history] / usr / src / sbin / fsck / fsck.8
CommitLineData
702f0073
WJ
1.\" Copyright (c) 1980, 1989 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)fsck.8 6.9 (Berkeley) 4/20/91
33.\"
34.TH FSCK 8 "April 20, 1991"
35.UC 4
36.de us
37\\$1\l'|0\(ul'
38..
39.SH NAME
40fsck \- file system consistency check and interactive repair
41.SH SYNOPSIS
42.B fsck
43.B \-p
44[
45.B \-m
46mode
47]
48.br
49.B fsck
50[
51.B \-b
52block#
53] [
54.B \-c
55] [
56.B \-y
57] [
58.B \-n
59] [
60.B \-m
61mode
62] [
63filesystem
64] ...
65.SH DESCRIPTION
66The first form of
67.I fsck
68preens a standard set of filesystems or the specified file systems.
69It is normally used in the script
70.B /etc/rc
71during automatic reboot.
72Here
73.I fsck
74reads the table
75.B /etc/fstab
76to determine which file systems to check.
77Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
78and that have non-zero pass number are checked.
79Filesystems with pass number 1 (normally just the root filesystem)
80are checked one at a time.
81When pass 1 completes, all remaining filesystems are checked,
82running one process per disk drive.
83The disk drive containing each filesystem is inferred from the longest prefix
84of the device name that ends in a digit; the remaining characters are assumed
85to be the partition designator.
86.PP
87The system takes care that only a restricted class of innocuous
88inconsistencies can happen unless hardware or software failures intervene.
89These are limited to the following:
90.IP
91Unreferenced inodes
92.ns
93.IP
94Link counts in inodes too large
95.ns
96.IP
97Missing blocks in the free map
98.ns
99.IP
100Blocks in the free map also in files
101.ns
102.IP
103Counts in the super-block wrong
104.PP
105These are the only inconsistencies that
106.I fsck
107with the
108.B \-p
109option will correct; if it encounters other inconsistencies, it exits
110with an abnormal return status and an automatic reboot will then fail.
111For each corrected inconsistency one or more lines will be printed
112identifying the file system on which the correction will take place,
113and the nature of the correction. After successfully correcting a file
114system,
115.I fsck
116will print the number of files on that file system,
117the number of used and free blocks,
118and the percentage of fragmentation.
119.PP
120If sent a QUIT signal,
121.I fsck
122will finish the file system checks, then exit with an abnormal
123return status that causes an automatic reboot to fail.
124This is useful when to finish the file system checks during an automatic reboot,
125but do not want the machine to come up multiuser after the checks complete.
126.PP
127Without the
128.B \-p
129option,
130.I fsck
131audits and interactively repairs inconsistent conditions for file systems.
132If the file system is inconsistent the operator is prompted for concurrence
133before each correction is attempted.
134It should be noted that some of the corrective actions which are not
135correctable under the
136.B \-p
137option will result in some loss of data.
138The amount and severity of data lost may be determined from the diagnostic
139output.
140The default action for each consistency correction
141is to wait for the operator to respond \fByes\fP or \fBno\fP.
142If the operator does not have write permission on the file system
143.I fsck
144will default to a
145.BR "\-n " action.
146.PP
147.I Fsck
148has more consistency checks than
149its predecessors
150.IR "check, dcheck, fcheck, " "and" " icheck"
151combined.
152.PP
153The following flags are interpreted by
154.I fsck.
155.TP 6
156.B \-b
157Use the block specified immediately after the flag as
158the super block for the file system. Block 32 is usually
159an alternate super block.
160.TP 6
161.B \-l
162Limit the number of parallel checks to the number specified in the following
163argument.
164By default, the limit is the number of disks, running one process per disk.
165If a smaller limit is given, the disks are checked round-robin, one filesystem
166at a time.
167.TP 6
168.B \-m
169Use the mode specified in octal immediately after the flag as the
170permission bits to use when creating the lost+found directory
171rather than the default 1777.
172In particular, systems that do not wish to have lost files accessible
173by all users on the system should use a more restrictive
174set of permissions such as 700.
175.TP 6
176.B \-y
177Assume a yes response to all questions asked by
178.IR fsck ;
179this should be used with great caution as this is a free license
180to continue after essentially unlimited trouble has been encountered.
181.TP 6
182.B \-n
183Assume a no response to all questions asked by
184.I fsck
185except for ``CONTINUE?'', which is assumed to be affirmative;
186do not open the file system for writing.
187.TP 6
188.B \-c
189If the file system is in the old (static table) format,
190convert it to the new (dynamic table) format.
191If the file system is in the new format,
192convert it to the old format provided the old format
193can support the filesystem configuration.
194In interactive mode,
195.I fsck
196will list the direction the conversion is to be made
197and ask whether the conversion should be done.
198If a negative answer is given,
199no further operations are done on the filesystem.
200In preen mode,
201the direction of the conversion is listed and done if
202possible without user interaction.
203Conversion in preen mode is best used when all the file systems
204are being converted at once.
205The format of a file system can be determined from the
206first line of output from
207.IR dumpfs (8).
208.PP
209If no filesystems are given to
210.I fsck
211then a default list of file systems is read from
212the file
213.BR /etc/fstab .
214.PP
215.ne 10
216Inconsistencies checked are as follows:
217.TP 6
2181.
219Blocks claimed by more than one inode or the free map.
220.br
221.br
222.ns
223.TP 6
2242.
225Blocks claimed by an inode outside the range of the file system.
226.br
227.br
228.ns
229.TP 6
2303.
231Incorrect link counts.
232.br
233.br
234.ns
235.TP 6
2364.
237Size checks:
238.br
239.ns
240.IP "" 12
241Directory size not of proper format.
242.br
243Partially truncated file.
244.br
245.br
246.ns
247.TP 6
2485.
249Bad inode format.
250.br
251.br
252.ns
253.TP 6
2546.
255Blocks not accounted for anywhere.
256.br
257.br
258.ns
259.TP 6
2607.
261Directory checks:
262.br
263.br
264.ns
265.IP "" 12
266File pointing to unallocated inode.
267.br
268Inode number out of range.
269.br
270Dot or dot-dot not the first two entries of a directory
271or having the wrong inode number.
272.br
273.br
274.ns
275.TP 6
2768.
277Super Block checks:
278.br
279.br
280.ns
281.IP "" 12
282More blocks for inodes than there are in the file system.
283.br
284.br
285.ns
286.TP 6
2879.
288Bad free block map format.
289.br
290.br
291.ns
292.TP 6
29310.
294Total free block and/or free inode count incorrect.
295.PP
296Orphaned files and directories (allocated but unreferenced) are,
297with the operator's concurrence, reconnected by
298placing them in the
299.B lost+found
300directory.
301The name assigned is the inode number.
302If the
303.I lost+found
304directory does not exist, it is created.
305If there is insufficient space its size is increased.
306.PP
307Because of inconsistencies between the block device and the buffer cache,
308the raw device should always be used.
309.SH FILES
310.br
311.ns
312.TP 21
313/etc/fstab
314contains default list of file systems to check.
315.SH DIAGNOSTICS
316The diagnostics produced by
317.I fsck
318are fully enumerated and explained in Appendix A of
319``Fsck \- The UNIX File System Check Program'' (SMM:5).
320.SH "SEE ALSO"
321fstab(5),
322fs(5),
323fsdb(8),
324newfs(8),
325mkfs(8),
326reboot(8)