xref: /csrg-svn/sbin/fsck/fsck.8 (revision 65103)
161492Sbostic.\" Copyright (c) 1980, 1989, 1991, 1993
261492Sbostic.\"	The Regents of the University of California.  All rights reserved.
318871Smckusick.\"
455006Scael.\" %sccs.include.redist.roff%
518871Smckusick.\"
6*65103Smckusick.\"	@(#)fsck.8	8.2 (Berkeley) 12/11/93
748394Scael.\"
855006Scael.Dd
955006Scael.Dt FSCK 8
1055006Scael.Os BSD 4
1155006Scael.Sh NAME
1255006Scael.Nm fsck
1360015Smckusick.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#
2060015Smckusick.Op Fl c Ar level
21*65103Smckusick.Op Fl l Ar maxparallel
2255006Scael.Op Fl y
2355006Scael.Op Fl n
2455006Scael.Op Fl m Ar mode
2555006Scael.Op Ar filesystem
2655006Scael.Ar ...
2755006Scael.Sh DESCRIPTION
2818871SmckusickThe first form of
2955006Scael.Nm fsck
3060015Smckusickpreens a standard set of filesystems or the specified filesystems.
3118871SmckusickIt is normally used in the script
3255006Scael.Pa /etc/rc
3318871Smckusickduring automatic reboot.
3439977SmckusickHere
3555006Scael.Nm fsck
3618871Smckusickreads the table
3755006Scael.Pa /etc/fstab
3860015Smckusickto determine which filesystems to check.
3937215SkarelsOnly partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
4028345Smckusickand that have non-zero pass number are checked.
4137216SkarelsFilesystems with pass number 1 (normally just the root filesystem)
4237216Skarelsare checked one at a time.
4337216SkarelsWhen pass 1 completes, all remaining filesystems are checked,
4437216Skarelsrunning one process per disk drive.
4537216SkarelsThe disk drive containing each filesystem is inferred from the longest prefix
4637216Skarelsof the device name that ends in a digit; the remaining characters are assumed
4737216Skarelsto be the partition designator.
4855006Scael.Pp
4960015SmckusickThe kernel takes care that only a restricted class of innocuous filesystem
5018871Smckusickinconsistencies can happen unless hardware or software failures intervene.
5118871SmckusickThese are limited to the following:
5260015Smckusick.Bl -item -compact
5360015Smckusick.It
5460015SmckusickUnreferenced inodes
5560015Smckusick.It
5660015SmckusickLink counts in inodes too large
5760015Smckusick.It
5860015SmckusickMissing blocks in the free map
5960015Smckusick.It
6060015SmckusickBlocks in the free map also in files
6160015Smckusick.It
6260015SmckusickCounts in the super-block wrong
6355006Scael.El
6455006Scael.Pp
6528345SmckusickThese are the only inconsistencies that
6655006Scael.Nm fsck
6718871Smckusickwith the
6855006Scael.Fl p
6918871Smckusickoption will correct; if it encounters other inconsistencies, it exits
7018871Smckusickwith an abnormal return status and an automatic reboot will then fail.
7118871SmckusickFor each corrected inconsistency one or more lines will be printed
7260015Smckusickidentifying the filesystem on which the correction will take place,
7360015Smckusickand the nature of the correction.  After successfully correcting a filesystem,
7455006Scael.Nm fsck
7560015Smckusickwill print the number of files on that filesystem,
7628345Smckusickthe number of used and free blocks,
7728345Smckusickand the percentage of fragmentation.
7855006Scael.Pp
7955006ScaelIf sent a
8055006Scael.Dv QUIT
8155006Scaelsignal,
8255006Scael.Nm fsck
8360015Smckusickwill finish the filesystem checks, then exit with an abnormal
8437216Skarelsreturn status that causes an automatic reboot to fail.
8560015SmckusickThis is useful when you want to finish the filesystem checks during an
8660015Smckusickautomatic reboot,
8737216Skarelsbut do not want the machine to come up multiuser after the checks complete.
8855006Scael.Pp
8918871SmckusickWithout the
9055006Scael.Fl p
9118871Smckusickoption,
9255006Scael.Nm fsck
9360015Smckusickaudits and interactively repairs inconsistent conditions for filesystems.
9460015SmckusickIf the filesystem is inconsistent the operator is prompted for concurrence
9518871Smckusickbefore each correction is attempted.
9628345SmckusickIt should be noted that some of the corrective actions which are not
9728345Smckusickcorrectable under the
9855006Scael.Fl p
9928345Smckusickoption will result in some loss of data.
10018871SmckusickThe amount and severity of data lost may be determined from the diagnostic
10118871Smckusickoutput.
10218871SmckusickThe default action for each consistency correction
10355006Scaelis to wait for the operator to respond
10455006Scael.Li yes
10555006Scaelor
10655006Scael.Li no .
10760015SmckusickIf the operator does not have write permission on the filesystem
10855006Scael.Nm fsck
10918871Smckusickwill default to a
11055006Scael.Fl n
11155006Scaelaction.
11255006Scael.Pp
11355006Scael.Nm Fsck
11418871Smckusickhas more consistency checks than
11518871Smckusickits predecessors
11655006Scael.Em check , dcheck , fcheck ,
11755006Scaeland
11855006Scael.Em icheck
11918871Smckusickcombined.
12055006Scael.Pp
12118871SmckusickThe following flags are interpreted by
12255006Scael.Nm fsck .
12355006Scael.Bl -tag -width indent
12455006Scael.It Fl b
12518872SmckusickUse the block specified immediately after the flag as
12660015Smckusickthe super block for the filesystem.  Block 32 is usually
12718872Smckusickan alternate super block.
12855006Scael.It Fl l
12937216SkarelsLimit the number of parallel checks to the number specified in the following
13037216Skarelsargument.
13137216SkarelsBy default, the limit is the number of disks, running one process per disk.
13237216SkarelsIf a smaller limit is given, the disks are checked round-robin, one filesystem
13337216Skarelsat a time.
13455006Scael.It Fl m
13536827SmckusickUse the mode specified in octal immediately after the flag as the
13655006Scaelpermission bits to use when creating the
13755006Scael.Pa lost+found
13855006Scaeldirectory rather than the default 1777.
13936827SmckusickIn particular, systems that do not wish to have lost files accessible
14036827Smckusickby all users on the system should use a more restrictive
14136827Smckusickset of permissions such as 700.
14255006Scael.It Fl y
14318871SmckusickAssume a yes response to all questions asked by
14455006Scael.Nm fsck ;
14518871Smckusickthis should be used with great caution as this is a free license
14618871Smckusickto continue after essentially unlimited trouble has been encountered.
14755006Scael.It Fl n
14818871SmckusickAssume a no response to all questions asked by
14955006Scael.Nm fsck
15055006Scaelexcept for
15155006Scael.Ql CONTINUE? ,
15255006Scaelwhich is assumed to be affirmative;
15360015Smckusickdo not open the filesystem for writing.
15455006Scael.It Fl c
15560015SmckusickConvert the filesystem to the specified level.
15660015SmckusickNote that the level of a filesystem can only be raised.
15760015Smckusick.Bl -tag -width indent
15860015SmckusickThere are currently three levels defined:
15960015Smckusick.It 0
16060015SmckusickThe filesystem is in the old (static table) format.
16160015Smckusick.It 1
16260015SmckusickThe filesystem is in the new (dynamic table) format.
16360015Smckusick.It 2
16460015SmckusickThe filesystem supports 32-bit uid's and gid's,
16560015Smckusickshort symbolic links are stored in the inode,
16660015Smckusickand directories have an added field showing the file type.
16760015Smckusick.El
16860015Smckusick.Pp
16934157SmckusickIn interactive mode,
17055006Scael.Nm fsck
17160015Smckusickwill list the conversion to be made
17234157Smckusickand ask whether the conversion should be done.
17334157SmckusickIf a negative answer is given,
17434157Smckusickno further operations are done on the filesystem.
17534157SmckusickIn preen mode,
17660015Smckusickthe conversion is listed and done if
17734157Smckusickpossible without user interaction.
17860015SmckusickConversion in preen mode is best used when all the filesystems
17934157Smckusickare being converted at once.
18060015SmckusickThe format of a filesystem can be determined from the
18134157Smckusickfirst line of output from
18255006Scael.Xr dumpfs 8 .
18355006Scael.El
18455006Scael.Pp
18518871SmckusickIf no filesystems are given to
18655006Scael.Nm fsck
18760015Smckusickthen a default list of filesystems is read from
18818871Smckusickthe file
18955006Scael.Pa /etc/fstab .
19055006Scael.Pp
19155006Scael.Bl -enum -indent indent -compact
19218871SmckusickInconsistencies checked are as follows:
19355006Scael.It
19434157SmckusickBlocks claimed by more than one inode or the free map.
19555006Scael.It
19660015SmckusickBlocks claimed by an inode outside the range of the filesystem.
19755006Scael.It
19818871SmckusickIncorrect link counts.
19955006Scael.It
20018871SmckusickSize checks:
20155006Scael.Bl -item -indent indent -compact
20255006Scael.It
20360015SmckusickDirectory size not a multiple of DIRBLKSIZ.
20455006Scael.It
20534157SmckusickPartially truncated file.
20655006Scael.El
20755006Scael.It
20818871SmckusickBad inode format.
20955006Scael.It
21018871SmckusickBlocks not accounted for anywhere.
21155006Scael.It
21218871SmckusickDirectory checks:
21355006Scael.Bl -item -indent indent -compact
21455006Scael.It
21518871SmckusickFile pointing to unallocated inode.
21655006Scael.It
21718871SmckusickInode number out of range.
21855006Scael.It
21939977SmckusickDot or dot-dot not the first two entries of a directory
22039977Smckusickor having the wrong inode number.
22155006Scael.El
22255006Scael.It
22318871SmckusickSuper Block checks:
22460015Smckusick.Bl -item -indent indent -compact
22555006Scael.It
22660015SmckusickMore blocks for inodes than there are in the filesystem.
22755006Scael.It
22834157SmckusickBad free block map format.
22955006Scael.It
23018871SmckusickTotal free block and/or free inode count incorrect.
23155006Scael.El
23260015Smckusick.El
23355006Scael.Pp
23418871SmckusickOrphaned files and directories (allocated but unreferenced) are,
23518871Smckusickwith the operator's concurrence, reconnected by
23618871Smckusickplacing them in the
23755006Scael.Pa lost+found
23818871Smckusickdirectory.
23928345SmckusickThe name assigned is the inode number.
24028345SmckusickIf the
24155006Scael.Pa lost+found
24228345Smckusickdirectory does not exist, it is created.
24328345SmckusickIf there is insufficient space its size is increased.
24455006Scael.Pp
24539977SmckusickBecause of inconsistencies between the block device and the buffer cache,
24639977Smckusickthe raw device should always be used.
24755006Scael.Sh FILES
24855006Scael.Bl -tag -width /etc/fstab -compact
24955006Scael.It Pa /etc/fstab
25060015Smckusickcontains default list of filesystems to check.
25155006Scael.El
25255006Scael.Sh DIAGNOSTICS
25318871SmckusickThe diagnostics produced by
25455006Scael.Nm fsck
25528345Smckusickare fully enumerated and explained in Appendix A of
25655006Scael.Rs
25755006Scael.%T "Fsck \- The UNIX File System Check Program"
25855006Scael.Re
25955006Scael.Sh SEE ALSO
26055006Scael.Xr fstab 5 ,
26155006Scael.Xr fs 5 ,
26255006Scael.Xr fsdb 8 ,
26355006Scael.Xr newfs 8 ,
26455006Scael.Xr mkfs 8 ,
26555006Scael.Xr reboot 8
266