xref: /csrg-svn/sbin/fsck/fsck.8 (revision 55006)
1*55006Scael.\" Copyright (c) 1980, 1989, 1991 Regents of the University of California.
248394Scael.\" All rights reserved.
318871Smckusick.\"
4*55006Scael.\" %sccs.include.redist.roff%
518871Smckusick.\"
6*55006Scael.\"	@(#)fsck.8	6.10 (Berkeley) 07/12/92
748394Scael.\"
8*55006Scael.Dd
9*55006Scael.Dt FSCK 8
10*55006Scael.Os BSD 4
11*55006Scael.Sh NAME
12*55006Scael.Nm fsck
13*55006Scael.Nd file system consistency check and interactive repair
14*55006Scael.Sh SYNOPSIS
15*55006Scael.Nm fsck
16*55006Scael.Fl p
17*55006Scael.Op Fl m Ar mode
18*55006Scael.Nm fsck
19*55006Scael.Op Fl b Ar block#
20*55006Scael.Op Fl c
21*55006Scael.Op Fl y
22*55006Scael.Op Fl n
23*55006Scael.Op Fl m Ar mode
24*55006Scael.Op Ar filesystem
25*55006Scael.Ar ...
26*55006Scael.Sh DESCRIPTION
2718871SmckusickThe first form of
28*55006Scael.Nm fsck
2918871Smckusickpreens a standard set of filesystems or the specified file systems.
3018871SmckusickIt is normally used in the script
31*55006Scael.Pa /etc/rc
3218871Smckusickduring automatic reboot.
3339977SmckusickHere
34*55006Scael.Nm fsck
3518871Smckusickreads the table
36*55006Scael.Pa /etc/fstab
3718871Smckusickto determine which file systems to check.
3837215SkarelsOnly partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
3928345Smckusickand that have non-zero pass number are checked.
4037216SkarelsFilesystems with pass number 1 (normally just the root filesystem)
4137216Skarelsare checked one at a time.
4237216SkarelsWhen pass 1 completes, all remaining filesystems are checked,
4337216Skarelsrunning one process per disk drive.
4437216SkarelsThe disk drive containing each filesystem is inferred from the longest prefix
4537216Skarelsof the device name that ends in a digit; the remaining characters are assumed
4637216Skarelsto be the partition designator.
47*55006Scael.Pp
4818871SmckusickThe system takes care that only a restricted class of innocuous
4918871Smckusickinconsistencies can happen unless hardware or software failures intervene.
5018871SmckusickThese are limited to the following:
51*55006Scael.Bl -item -compact -indent indent
52*55006Scael.It Unreferenced inodes
53*55006Scael.It Link counts in inodes too large
54*55006Scael.It Missing blocks in the free map
55*55006Scael.It Blocks in the free map also in files
56*55006Scael.It Counts in the super-block wrong
57*55006Scael.El
58*55006Scael.Pp
5928345SmckusickThese are the only inconsistencies that
60*55006Scael.Nm fsck
6118871Smckusickwith the
62*55006Scael.Fl p
6318871Smckusickoption will correct; if it encounters other inconsistencies, it exits
6418871Smckusickwith an abnormal return status and an automatic reboot will then fail.
6518871SmckusickFor each corrected inconsistency one or more lines will be printed
6618871Smckusickidentifying the file system on which the correction will take place,
6718871Smckusickand the nature of the correction.  After successfully correcting a file
6818871Smckusicksystem,
69*55006Scael.Nm fsck
7028345Smckusickwill print the number of files on that file system,
7128345Smckusickthe number of used and free blocks,
7228345Smckusickand the percentage of fragmentation.
73*55006Scael.Pp
74*55006ScaelIf sent a
75*55006Scael.Dv QUIT
76*55006Scaelsignal,
77*55006Scael.Nm fsck
7828345Smckusickwill finish the file system checks, then exit with an abnormal
7937216Skarelsreturn status that causes an automatic reboot to fail.
8037216SkarelsThis is useful when to finish the file system checks during an automatic reboot,
8137216Skarelsbut do not want the machine to come up multiuser after the checks complete.
82*55006Scael.Pp
8318871SmckusickWithout the
84*55006Scael.Fl p
8518871Smckusickoption,
86*55006Scael.Nm fsck
8718871Smckusickaudits and interactively repairs inconsistent conditions for file systems.
8818871SmckusickIf the file system is inconsistent the operator is prompted for concurrence
8918871Smckusickbefore each correction is attempted.
9028345SmckusickIt should be noted that some of the corrective actions which are not
9128345Smckusickcorrectable under the
92*55006Scael.Fl p
9328345Smckusickoption will result in some loss of data.
9418871SmckusickThe amount and severity of data lost may be determined from the diagnostic
9518871Smckusickoutput.
9618871SmckusickThe default action for each consistency correction
97*55006Scaelis to wait for the operator to respond
98*55006Scael.Li yes
99*55006Scaelor
100*55006Scael.Li no .
10128345SmckusickIf the operator does not have write permission on the file system
102*55006Scael.Nm fsck
10318871Smckusickwill default to a
104*55006Scael.Fl n
105*55006Scaelaction.
106*55006Scael.Pp
107*55006Scael.Nm Fsck
10818871Smckusickhas more consistency checks than
10918871Smckusickits predecessors
110*55006Scael.Em check , dcheck , fcheck ,
111*55006Scaeland
112*55006Scael.Em icheck
11318871Smckusickcombined.
114*55006Scael.Pp
11518871SmckusickThe following flags are interpreted by
116*55006Scael.Nm fsck .
117*55006Scael.Bl -tag -width indent
118*55006Scael.It Fl b
11918872SmckusickUse the block specified immediately after the flag as
12034157Smckusickthe super block for the file system.  Block 32 is usually
12118872Smckusickan alternate super block.
122*55006Scael.It Fl l
12337216SkarelsLimit the number of parallel checks to the number specified in the following
12437216Skarelsargument.
12537216SkarelsBy default, the limit is the number of disks, running one process per disk.
12637216SkarelsIf a smaller limit is given, the disks are checked round-robin, one filesystem
12737216Skarelsat a time.
128*55006Scael.It Fl m
12936827SmckusickUse the mode specified in octal immediately after the flag as the
130*55006Scaelpermission bits to use when creating the
131*55006Scael.Pa lost+found
132*55006Scaeldirectory rather than the default 1777.
13336827SmckusickIn particular, systems that do not wish to have lost files accessible
13436827Smckusickby all users on the system should use a more restrictive
13536827Smckusickset of permissions such as 700.
136*55006Scael.It Fl y
13718871SmckusickAssume a yes response to all questions asked by
138*55006Scael.Nm fsck ;
13918871Smckusickthis should be used with great caution as this is a free license
14018871Smckusickto continue after essentially unlimited trouble has been encountered.
141*55006Scael.It Fl n
14218871SmckusickAssume a no response to all questions asked by
143*55006Scael.Nm fsck
144*55006Scaelexcept for
145*55006Scael.Ql CONTINUE? ,
146*55006Scaelwhich is assumed to be affirmative;
14718871Smckusickdo not open the file system for writing.
148*55006Scael.It Fl c
14934157SmckusickIf the file system is in the old (static table) format,
15034157Smckusickconvert it to the new (dynamic table) format.
15134157SmckusickIf the file system is in the new format,
15234157Smckusickconvert it to the old format provided the old format
15334157Smckusickcan support the filesystem configuration.
15434157SmckusickIn interactive mode,
155*55006Scael.Nm fsck
15634157Smckusickwill list the direction the conversion is to be made
15734157Smckusickand ask whether the conversion should be done.
15834157SmckusickIf a negative answer is given,
15934157Smckusickno further operations are done on the filesystem.
16034157SmckusickIn preen mode,
16134157Smckusickthe direction of the conversion is listed and done if
16234157Smckusickpossible without user interaction.
16334157SmckusickConversion in preen mode is best used when all the file systems
16434157Smckusickare being converted at once.
16534157SmckusickThe format of a file system can be determined from the
16634157Smckusickfirst line of output from
167*55006Scael.Xr dumpfs 8 .
168*55006Scael.El
169*55006Scael.Pp
17018871SmckusickIf no filesystems are given to
171*55006Scael.Nm fsck
17218871Smckusickthen a default list of file systems is read from
17318871Smckusickthe file
174*55006Scael.Pa /etc/fstab .
175*55006Scael.Pp
176*55006Scael.Bl -enum -indent indent -compact
17718871SmckusickInconsistencies checked are as follows:
178*55006Scael.It
17934157SmckusickBlocks claimed by more than one inode or the free map.
180*55006Scael.It
18134157SmckusickBlocks claimed by an inode outside the range of the file system.
182*55006Scael.It
18318871SmckusickIncorrect link counts.
184*55006Scael.It
18518871SmckusickSize checks:
186*55006Scael.Bl -item -indent indent -compact
187*55006Scael.It
18818872SmckusickDirectory size not of proper format.
189*55006Scael.It
19034157SmckusickPartially truncated file.
191*55006Scael.El
192*55006Scael.It
19318871SmckusickBad inode format.
194*55006Scael.It
19518871SmckusickBlocks not accounted for anywhere.
196*55006Scael.It
19718871SmckusickDirectory checks:
198*55006Scael.Bl -item -indent indent -compact
199*55006Scael.It
20018871SmckusickFile pointing to unallocated inode.
201*55006Scael.It
20218871SmckusickInode number out of range.
203*55006Scael.It
20439977SmckusickDot or dot-dot not the first two entries of a directory
20539977Smckusickor having the wrong inode number.
206*55006Scael.El
207*55006Scael.It
20818871SmckusickSuper Block checks:
209*55006Scael.It
21018871SmckusickMore blocks for inodes than there are in the file system.
211*55006Scael.It
21234157SmckusickBad free block map format.
213*55006Scael.It
21418871SmckusickTotal free block and/or free inode count incorrect.
215*55006Scael.El
216*55006Scael.Pp
21718871SmckusickOrphaned files and directories (allocated but unreferenced) are,
21818871Smckusickwith the operator's concurrence, reconnected by
21918871Smckusickplacing them in the
220*55006Scael.Pa lost+found
22118871Smckusickdirectory.
22228345SmckusickThe name assigned is the inode number.
22328345SmckusickIf the
224*55006Scael.Pa lost+found
22528345Smckusickdirectory does not exist, it is created.
22628345SmckusickIf there is insufficient space its size is increased.
227*55006Scael.Pp
22839977SmckusickBecause of inconsistencies between the block device and the buffer cache,
22939977Smckusickthe raw device should always be used.
230*55006Scael.Sh FILES
231*55006Scael.Bl -tag -width /etc/fstab -compact
232*55006Scael.It Pa /etc/fstab
23318871Smckusickcontains default list of file systems to check.
234*55006Scael.El
235*55006Scael.Sh DIAGNOSTICS
23618871SmckusickThe diagnostics produced by
237*55006Scael.Nm fsck
23828345Smckusickare fully enumerated and explained in Appendix A of
239*55006Scael.Rs
240*55006Scael.%T "Fsck \- The UNIX File System Check Program"
241*55006Scael.Re
242*55006Scael.Sh SEE ALSO
243*55006Scael.Xr fstab 5 ,
244*55006Scael.Xr fs 5 ,
245*55006Scael.Xr fsdb 8 ,
246*55006Scael.Xr newfs 8 ,
247*55006Scael.Xr mkfs 8 ,
248*55006Scael.Xr reboot 8
249