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*68008Smckusick.\" @(#)fsck.8 8.3 (Berkeley) 11/29/94 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 2165103Smckusick.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 158*68008SmckusickThere are currently four 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. 167*68008Smckusick.It 3 168*68008SmckusickIf maxcontig is greater than one, 169*68008Smckusickbuild the free segment maps to aid in finding contiguous sets of blocks. 170*68008SmckusickIf maxcontig is equal to one, delete any existing segment maps. 17160015Smckusick.El 17260015Smckusick.Pp 17334157SmckusickIn interactive mode, 17455006Scael.Nm fsck 17560015Smckusickwill list the conversion to be made 17634157Smckusickand ask whether the conversion should be done. 17734157SmckusickIf a negative answer is given, 17834157Smckusickno further operations are done on the filesystem. 17934157SmckusickIn preen mode, 18060015Smckusickthe conversion is listed and done if 18134157Smckusickpossible without user interaction. 18260015SmckusickConversion in preen mode is best used when all the filesystems 18334157Smckusickare being converted at once. 18460015SmckusickThe format of a filesystem can be determined from the 18534157Smckusickfirst line of output from 18655006Scael.Xr dumpfs 8 . 18755006Scael.El 18855006Scael.Pp 18918871SmckusickIf no filesystems are given to 19055006Scael.Nm fsck 19160015Smckusickthen a default list of filesystems is read from 19218871Smckusickthe file 19355006Scael.Pa /etc/fstab . 19455006Scael.Pp 19555006Scael.Bl -enum -indent indent -compact 19618871SmckusickInconsistencies checked are as follows: 19755006Scael.It 19834157SmckusickBlocks claimed by more than one inode or the free map. 19955006Scael.It 20060015SmckusickBlocks claimed by an inode outside the range of the filesystem. 20155006Scael.It 20218871SmckusickIncorrect link counts. 20355006Scael.It 20418871SmckusickSize checks: 20555006Scael.Bl -item -indent indent -compact 20655006Scael.It 20760015SmckusickDirectory size not a multiple of DIRBLKSIZ. 20855006Scael.It 20934157SmckusickPartially truncated file. 21055006Scael.El 21155006Scael.It 21218871SmckusickBad inode format. 21355006Scael.It 21418871SmckusickBlocks not accounted for anywhere. 21555006Scael.It 21618871SmckusickDirectory checks: 21755006Scael.Bl -item -indent indent -compact 21855006Scael.It 21918871SmckusickFile pointing to unallocated inode. 22055006Scael.It 22118871SmckusickInode number out of range. 22255006Scael.It 22339977SmckusickDot or dot-dot not the first two entries of a directory 22439977Smckusickor having the wrong inode number. 22555006Scael.El 22655006Scael.It 22718871SmckusickSuper Block checks: 22860015Smckusick.Bl -item -indent indent -compact 22955006Scael.It 23060015SmckusickMore blocks for inodes than there are in the filesystem. 23155006Scael.It 23234157SmckusickBad free block map format. 23355006Scael.It 23418871SmckusickTotal free block and/or free inode count incorrect. 23555006Scael.El 23660015Smckusick.El 23755006Scael.Pp 23818871SmckusickOrphaned files and directories (allocated but unreferenced) are, 23918871Smckusickwith the operator's concurrence, reconnected by 24018871Smckusickplacing them in the 24155006Scael.Pa lost+found 24218871Smckusickdirectory. 24328345SmckusickThe name assigned is the inode number. 24428345SmckusickIf the 24555006Scael.Pa lost+found 24628345Smckusickdirectory does not exist, it is created. 24728345SmckusickIf there is insufficient space its size is increased. 24855006Scael.Pp 24939977SmckusickBecause of inconsistencies between the block device and the buffer cache, 25039977Smckusickthe raw device should always be used. 25155006Scael.Sh FILES 25255006Scael.Bl -tag -width /etc/fstab -compact 25355006Scael.It Pa /etc/fstab 25460015Smckusickcontains default list of filesystems to check. 25555006Scael.El 25655006Scael.Sh DIAGNOSTICS 25718871SmckusickThe diagnostics produced by 25855006Scael.Nm fsck 25928345Smckusickare fully enumerated and explained in Appendix A of 26055006Scael.Rs 26155006Scael.%T "Fsck \- The UNIX File System Check Program" 26255006Scael.Re 26355006Scael.Sh SEE ALSO 26455006Scael.Xr fstab 5 , 26555006Scael.Xr fs 5 , 26655006Scael.Xr fsdb 8 , 26755006Scael.Xr newfs 8 , 26855006Scael.Xr mkfs 8 , 26955006Scael.Xr reboot 8 270