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