xref: /original-bsd/sbin/fsck/fsck.8 (revision fac0c393)
1.\" Copyright (c) 1980, 1989, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"	@(#)fsck.8	8.3 (Berkeley) 11/29/94
7.\"
8.Dd
9.Dt FSCK 8
10.Os BSD 4
11.Sh NAME
12.Nm fsck
13.Nd filesystem consistency check and interactive repair
14.Sh SYNOPSIS
15.Nm fsck
16.Fl p
17.Op Fl m Ar mode
18.Nm fsck
19.Op Fl b Ar block#
20.Op Fl c Ar level
21.Op Fl l Ar maxparallel
22.Op Fl y
23.Op Fl n
24.Op Fl m Ar mode
25.Op Ar filesystem
26.Ar ...
27.Sh DESCRIPTION
28The first form of
29.Nm fsck
30preens a standard set of filesystems or the specified filesystems.
31It is normally used in the script
32.Pa /etc/rc
33during automatic reboot.
34Here
35.Nm fsck
36reads the table
37.Pa /etc/fstab
38to determine which filesystems to check.
39Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
40and that have non-zero pass number are checked.
41Filesystems with pass number 1 (normally just the root filesystem)
42are checked one at a time.
43When pass 1 completes, all remaining filesystems are checked,
44running one process per disk drive.
45The disk drive containing each filesystem is inferred from the longest prefix
46of the device name that ends in a digit; the remaining characters are assumed
47to be the partition designator.
48.Pp
49The kernel takes care that only a restricted class of innocuous filesystem
50inconsistencies can happen unless hardware or software failures intervene.
51These are limited to the following:
52.Bl -item -compact
53.It
54Unreferenced inodes
55.It
56Link counts in inodes too large
57.It
58Missing blocks in the free map
59.It
60Blocks in the free map also in files
61.It
62Counts in the super-block wrong
63.El
64.Pp
65These are the only inconsistencies that
66.Nm fsck
67with the
68.Fl p
69option will correct; if it encounters other inconsistencies, it exits
70with an abnormal return status and an automatic reboot will then fail.
71For each corrected inconsistency one or more lines will be printed
72identifying the filesystem on which the correction will take place,
73and the nature of the correction.  After successfully correcting a filesystem,
74.Nm fsck
75will print the number of files on that filesystem,
76the number of used and free blocks,
77and the percentage of fragmentation.
78.Pp
79If sent a
80.Dv QUIT
81signal,
82.Nm fsck
83will finish the filesystem checks, then exit with an abnormal
84return status that causes an automatic reboot to fail.
85This is useful when you want to finish the filesystem checks during an
86automatic reboot,
87but do not want the machine to come up multiuser after the checks complete.
88.Pp
89Without the
90.Fl p
91option,
92.Nm fsck
93audits and interactively repairs inconsistent conditions for filesystems.
94If the filesystem is inconsistent the operator is prompted for concurrence
95before each correction is attempted.
96It should be noted that some of the corrective actions which are not
97correctable under the
98.Fl p
99option will result in some loss of data.
100The amount and severity of data lost may be determined from the diagnostic
101output.
102The default action for each consistency correction
103is to wait for the operator to respond
104.Li yes
105or
106.Li no .
107If the operator does not have write permission on the filesystem
108.Nm fsck
109will default to a
110.Fl n
111action.
112.Pp
113.Nm Fsck
114has more consistency checks than
115its predecessors
116.Em check , dcheck , fcheck ,
117and
118.Em icheck
119combined.
120.Pp
121The following flags are interpreted by
122.Nm fsck .
123.Bl -tag -width indent
124.It Fl b
125Use the block specified immediately after the flag as
126the super block for the filesystem.  Block 32 is usually
127an alternate super block.
128.It Fl l
129Limit the number of parallel checks to the number specified in the following
130argument.
131By default, the limit is the number of disks, running one process per disk.
132If a smaller limit is given, the disks are checked round-robin, one filesystem
133at a time.
134.It Fl m
135Use the mode specified in octal immediately after the flag as the
136permission bits to use when creating the
137.Pa lost+found
138directory rather than the default 1777.
139In particular, systems that do not wish to have lost files accessible
140by all users on the system should use a more restrictive
141set of permissions such as 700.
142.It Fl y
143Assume a yes response to all questions asked by
144.Nm fsck ;
145this should be used with great caution as this is a free license
146to continue after essentially unlimited trouble has been encountered.
147.It Fl n
148Assume a no response to all questions asked by
149.Nm fsck
150except for
151.Ql CONTINUE? ,
152which is assumed to be affirmative;
153do not open the filesystem for writing.
154.It Fl c
155Convert the filesystem to the specified level.
156Note that the level of a filesystem can only be raised.
157.Bl -tag -width indent
158There are currently four levels defined:
159.It 0
160The filesystem is in the old (static table) format.
161.It 1
162The filesystem is in the new (dynamic table) format.
163.It 2
164The filesystem supports 32-bit uid's and gid's,
165short symbolic links are stored in the inode,
166and directories have an added field showing the file type.
167.It 3
168If maxcontig is greater than one,
169build the free segment maps to aid in finding contiguous sets of blocks.
170If maxcontig is equal to one, delete any existing segment maps.
171.El
172.Pp
173In interactive mode,
174.Nm fsck
175will list the conversion to be made
176and ask whether the conversion should be done.
177If a negative answer is given,
178no further operations are done on the filesystem.
179In preen mode,
180the conversion is listed and done if
181possible without user interaction.
182Conversion in preen mode is best used when all the filesystems
183are being converted at once.
184The format of a filesystem can be determined from the
185first line of output from
186.Xr dumpfs 8 .
187.El
188.Pp
189If no filesystems are given to
190.Nm fsck
191then a default list of filesystems is read from
192the file
193.Pa /etc/fstab .
194.Pp
195.Bl -enum -indent indent -compact
196Inconsistencies checked are as follows:
197.It
198Blocks claimed by more than one inode or the free map.
199.It
200Blocks claimed by an inode outside the range of the filesystem.
201.It
202Incorrect link counts.
203.It
204Size checks:
205.Bl -item -indent indent -compact
206.It
207Directory size not a multiple of DIRBLKSIZ.
208.It
209Partially truncated file.
210.El
211.It
212Bad inode format.
213.It
214Blocks not accounted for anywhere.
215.It
216Directory checks:
217.Bl -item -indent indent -compact
218.It
219File pointing to unallocated inode.
220.It
221Inode number out of range.
222.It
223Dot or dot-dot not the first two entries of a directory
224or having the wrong inode number.
225.El
226.It
227Super Block checks:
228.Bl -item -indent indent -compact
229.It
230More blocks for inodes than there are in the filesystem.
231.It
232Bad free block map format.
233.It
234Total free block and/or free inode count incorrect.
235.El
236.El
237.Pp
238Orphaned files and directories (allocated but unreferenced) are,
239with the operator's concurrence, reconnected by
240placing them in the
241.Pa lost+found
242directory.
243The name assigned is the inode number.
244If the
245.Pa lost+found
246directory does not exist, it is created.
247If there is insufficient space its size is increased.
248.Pp
249Because of inconsistencies between the block device and the buffer cache,
250the raw device should always be used.
251.Sh FILES
252.Bl -tag -width /etc/fstab -compact
253.It Pa /etc/fstab
254contains default list of filesystems to check.
255.El
256.Sh DIAGNOSTICS
257The diagnostics produced by
258.Nm fsck
259are fully enumerated and explained in Appendix A of
260.Rs
261.%T "Fsck \- The UNIX File System Check Program"
262.Re
263.Sh SEE ALSO
264.Xr fstab 5 ,
265.Xr fs 5 ,
266.Xr fsdb 8 ,
267.Xr newfs 8 ,
268.Xr mkfs 8 ,
269.Xr reboot 8
270