xref: /csrg-svn/sbin/fsck/fsck.8 (revision 60015)
155006Scael.\" Copyright (c) 1980, 1989, 1991 Regents of the University of California.
248394Scael.\" All rights reserved.
318871Smckusick.\"
455006Scael.\" %sccs.include.redist.roff%
518871Smckusick.\"
6*60015Smckusick.\"	@(#)fsck.8	6.11 (Berkeley) 05/14/93
748394Scael.\"
855006Scael.Dd
955006Scael.Dt FSCK 8
1055006Scael.Os BSD 4
1155006Scael.Sh NAME
1255006Scael.Nm fsck
13*60015Smckusick.Nd filesystem consistency check and interactive repair
1455006Scael.Sh SYNOPSIS
1555006Scael.Nm fsck
1655006Scael.Fl p
1755006Scael.Op Fl m Ar mode
1855006Scael.Nm fsck
1955006Scael.Op Fl b Ar block#
20*60015Smckusick.Op Fl c Ar level
2155006Scael.Op Fl y
2255006Scael.Op Fl n
2355006Scael.Op Fl m Ar mode
2455006Scael.Op Ar filesystem
2555006Scael.Ar ...
2655006Scael.Sh DESCRIPTION
2718871SmckusickThe first form of
2855006Scael.Nm fsck
29*60015Smckusickpreens a standard set of filesystems or the specified filesystems.
3018871SmckusickIt is normally used in the script
3155006Scael.Pa /etc/rc
3218871Smckusickduring automatic reboot.
3339977SmckusickHere
3455006Scael.Nm fsck
3518871Smckusickreads the table
3655006Scael.Pa /etc/fstab
37*60015Smckusickto determine which filesystems 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.
4755006Scael.Pp
48*60015SmckusickThe kernel takes care that only a restricted class of innocuous filesystem
4918871Smckusickinconsistencies can happen unless hardware or software failures intervene.
5018871SmckusickThese are limited to the following:
51*60015Smckusick.Bl -item -compact
52*60015Smckusick.It
53*60015SmckusickUnreferenced inodes
54*60015Smckusick.It
55*60015SmckusickLink counts in inodes too large
56*60015Smckusick.It
57*60015SmckusickMissing blocks in the free map
58*60015Smckusick.It
59*60015SmckusickBlocks in the free map also in files
60*60015Smckusick.It
61*60015SmckusickCounts in the super-block wrong
6255006Scael.El
6355006Scael.Pp
6428345SmckusickThese are the only inconsistencies that
6555006Scael.Nm fsck
6618871Smckusickwith the
6755006Scael.Fl p
6818871Smckusickoption will correct; if it encounters other inconsistencies, it exits
6918871Smckusickwith an abnormal return status and an automatic reboot will then fail.
7018871SmckusickFor each corrected inconsistency one or more lines will be printed
71*60015Smckusickidentifying the filesystem on which the correction will take place,
72*60015Smckusickand the nature of the correction.  After successfully correcting a filesystem,
7355006Scael.Nm fsck
74*60015Smckusickwill print the number of files on that filesystem,
7528345Smckusickthe number of used and free blocks,
7628345Smckusickand the percentage of fragmentation.
7755006Scael.Pp
7855006ScaelIf sent a
7955006Scael.Dv QUIT
8055006Scaelsignal,
8155006Scael.Nm fsck
82*60015Smckusickwill finish the filesystem checks, then exit with an abnormal
8337216Skarelsreturn status that causes an automatic reboot to fail.
84*60015SmckusickThis is useful when you want to finish the filesystem checks during an
85*60015Smckusickautomatic reboot,
8637216Skarelsbut do not want the machine to come up multiuser after the checks complete.
8755006Scael.Pp
8818871SmckusickWithout the
8955006Scael.Fl p
9018871Smckusickoption,
9155006Scael.Nm fsck
92*60015Smckusickaudits and interactively repairs inconsistent conditions for filesystems.
93*60015SmckusickIf the filesystem is inconsistent the operator is prompted for concurrence
9418871Smckusickbefore each correction is attempted.
9528345SmckusickIt should be noted that some of the corrective actions which are not
9628345Smckusickcorrectable under the
9755006Scael.Fl p
9828345Smckusickoption will result in some loss of data.
9918871SmckusickThe amount and severity of data lost may be determined from the diagnostic
10018871Smckusickoutput.
10118871SmckusickThe default action for each consistency correction
10255006Scaelis to wait for the operator to respond
10355006Scael.Li yes
10455006Scaelor
10555006Scael.Li no .
106*60015SmckusickIf the operator does not have write permission on the filesystem
10755006Scael.Nm fsck
10818871Smckusickwill default to a
10955006Scael.Fl n
11055006Scaelaction.
11155006Scael.Pp
11255006Scael.Nm Fsck
11318871Smckusickhas more consistency checks than
11418871Smckusickits predecessors
11555006Scael.Em check , dcheck , fcheck ,
11655006Scaeland
11755006Scael.Em icheck
11818871Smckusickcombined.
11955006Scael.Pp
12018871SmckusickThe following flags are interpreted by
12155006Scael.Nm fsck .
12255006Scael.Bl -tag -width indent
12355006Scael.It Fl b
12418872SmckusickUse the block specified immediately after the flag as
125*60015Smckusickthe super block for the filesystem.  Block 32 is usually
12618872Smckusickan alternate super block.
12755006Scael.It Fl l
12837216SkarelsLimit the number of parallel checks to the number specified in the following
12937216Skarelsargument.
13037216SkarelsBy default, the limit is the number of disks, running one process per disk.
13137216SkarelsIf a smaller limit is given, the disks are checked round-robin, one filesystem
13237216Skarelsat a time.
13355006Scael.It Fl m
13436827SmckusickUse the mode specified in octal immediately after the flag as the
13555006Scaelpermission bits to use when creating the
13655006Scael.Pa lost+found
13755006Scaeldirectory rather than the default 1777.
13836827SmckusickIn particular, systems that do not wish to have lost files accessible
13936827Smckusickby all users on the system should use a more restrictive
14036827Smckusickset of permissions such as 700.
14155006Scael.It Fl y
14218871SmckusickAssume a yes response to all questions asked by
14355006Scael.Nm fsck ;
14418871Smckusickthis should be used with great caution as this is a free license
14518871Smckusickto continue after essentially unlimited trouble has been encountered.
14655006Scael.It Fl n
14718871SmckusickAssume a no response to all questions asked by
14855006Scael.Nm fsck
14955006Scaelexcept for
15055006Scael.Ql CONTINUE? ,
15155006Scaelwhich is assumed to be affirmative;
152*60015Smckusickdo not open the filesystem for writing.
15355006Scael.It Fl c
154*60015SmckusickConvert the filesystem to the specified level.
155*60015SmckusickNote that the level of a filesystem can only be raised.
156*60015Smckusick.Bl -tag -width indent
157*60015SmckusickThere are currently three levels defined:
158*60015Smckusick.It 0
159*60015SmckusickThe filesystem is in the old (static table) format.
160*60015Smckusick.It 1
161*60015SmckusickThe filesystem is in the new (dynamic table) format.
162*60015Smckusick.It 2
163*60015SmckusickThe filesystem supports 32-bit uid's and gid's,
164*60015Smckusickshort symbolic links are stored in the inode,
165*60015Smckusickand directories have an added field showing the file type.
166*60015Smckusick.El
167*60015Smckusick.Pp
16834157SmckusickIn interactive mode,
16955006Scael.Nm fsck
170*60015Smckusickwill list the conversion to be made
17134157Smckusickand ask whether the conversion should be done.
17234157SmckusickIf a negative answer is given,
17334157Smckusickno further operations are done on the filesystem.
17434157SmckusickIn preen mode,
175*60015Smckusickthe conversion is listed and done if
17634157Smckusickpossible without user interaction.
177*60015SmckusickConversion in preen mode is best used when all the filesystems
17834157Smckusickare being converted at once.
179*60015SmckusickThe format of a filesystem can be determined from the
18034157Smckusickfirst line of output from
18155006Scael.Xr dumpfs 8 .
18255006Scael.El
18355006Scael.Pp
18418871SmckusickIf no filesystems are given to
18555006Scael.Nm fsck
186*60015Smckusickthen a default list of filesystems is read from
18718871Smckusickthe file
18855006Scael.Pa /etc/fstab .
18955006Scael.Pp
19055006Scael.Bl -enum -indent indent -compact
19118871SmckusickInconsistencies checked are as follows:
19255006Scael.It
19334157SmckusickBlocks claimed by more than one inode or the free map.
19455006Scael.It
195*60015SmckusickBlocks claimed by an inode outside the range of the filesystem.
19655006Scael.It
19718871SmckusickIncorrect link counts.
19855006Scael.It
19918871SmckusickSize checks:
20055006Scael.Bl -item -indent indent -compact
20155006Scael.It
202*60015SmckusickDirectory size not a multiple of DIRBLKSIZ.
20355006Scael.It
20434157SmckusickPartially truncated file.
20555006Scael.El
20655006Scael.It
20718871SmckusickBad inode format.
20855006Scael.It
20918871SmckusickBlocks not accounted for anywhere.
21055006Scael.It
21118871SmckusickDirectory checks:
21255006Scael.Bl -item -indent indent -compact
21355006Scael.It
21418871SmckusickFile pointing to unallocated inode.
21555006Scael.It
21618871SmckusickInode number out of range.
21755006Scael.It
21839977SmckusickDot or dot-dot not the first two entries of a directory
21939977Smckusickor having the wrong inode number.
22055006Scael.El
22155006Scael.It
22218871SmckusickSuper Block checks:
223*60015Smckusick.Bl -item -indent indent -compact
22455006Scael.It
225*60015SmckusickMore blocks for inodes than there are in the filesystem.
22655006Scael.It
22734157SmckusickBad free block map format.
22855006Scael.It
22918871SmckusickTotal free block and/or free inode count incorrect.
23055006Scael.El
231*60015Smckusick.El
23255006Scael.Pp
23318871SmckusickOrphaned files and directories (allocated but unreferenced) are,
23418871Smckusickwith the operator's concurrence, reconnected by
23518871Smckusickplacing them in the
23655006Scael.Pa lost+found
23718871Smckusickdirectory.
23828345SmckusickThe name assigned is the inode number.
23928345SmckusickIf the
24055006Scael.Pa lost+found
24128345Smckusickdirectory does not exist, it is created.
24228345SmckusickIf there is insufficient space its size is increased.
24355006Scael.Pp
24439977SmckusickBecause of inconsistencies between the block device and the buffer cache,
24539977Smckusickthe raw device should always be used.
24655006Scael.Sh FILES
24755006Scael.Bl -tag -width /etc/fstab -compact
24855006Scael.It Pa /etc/fstab
249*60015Smckusickcontains default list of filesystems to check.
25055006Scael.El
25155006Scael.Sh DIAGNOSTICS
25218871SmckusickThe diagnostics produced by
25355006Scael.Nm fsck
25428345Smckusickare fully enumerated and explained in Appendix A of
25555006Scael.Rs
25655006Scael.%T "Fsck \- The UNIX File System Check Program"
25755006Scael.Re
25855006Scael.Sh SEE ALSO
25955006Scael.Xr fstab 5 ,
26055006Scael.Xr fs 5 ,
26155006Scael.Xr fsdb 8 ,
26255006Scael.Xr newfs 8 ,
26355006Scael.Xr mkfs 8 ,
26455006Scael.Xr reboot 8
265