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