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