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*69320Smckusick.\" @(#)fsck.8 8.4 (Berkeley) 05/09/95 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. 48*69320SmckusickIn preening mode, 49*69320Smckusickfilesystems that are marked clean are skipped. 50*69320SmckusickFilesystems are marked clean when they are unmounted, 51*69320Smckusickwhen they have been mounted read-only, or when 52*69320Smckusick.Nm fsck 53*69320Smckusickruns on them successfully. 5455006Scael.Pp 5560015SmckusickThe kernel takes care that only a restricted class of innocuous filesystem 5618871Smckusickinconsistencies can happen unless hardware or software failures intervene. 5718871SmckusickThese are limited to the following: 5860015Smckusick.Bl -item -compact 5960015Smckusick.It 6060015SmckusickUnreferenced inodes 6160015Smckusick.It 6260015SmckusickLink counts in inodes too large 6360015Smckusick.It 6460015SmckusickMissing blocks in the free map 6560015Smckusick.It 6660015SmckusickBlocks in the free map also in files 6760015Smckusick.It 6860015SmckusickCounts in the super-block wrong 6955006Scael.El 7055006Scael.Pp 7128345SmckusickThese are the only inconsistencies that 7255006Scael.Nm fsck 7318871Smckusickwith the 7455006Scael.Fl p 7518871Smckusickoption will correct; if it encounters other inconsistencies, it exits 7618871Smckusickwith an abnormal return status and an automatic reboot will then fail. 7718871SmckusickFor each corrected inconsistency one or more lines will be printed 7860015Smckusickidentifying the filesystem on which the correction will take place, 7960015Smckusickand the nature of the correction. After successfully correcting a filesystem, 8055006Scael.Nm fsck 8160015Smckusickwill print the number of files on that filesystem, 8228345Smckusickthe number of used and free blocks, 8328345Smckusickand the percentage of fragmentation. 8455006Scael.Pp 8555006ScaelIf sent a 8655006Scael.Dv QUIT 8755006Scaelsignal, 8855006Scael.Nm fsck 8960015Smckusickwill finish the filesystem checks, then exit with an abnormal 9037216Skarelsreturn status that causes an automatic reboot to fail. 9160015SmckusickThis is useful when you want to finish the filesystem checks during an 9260015Smckusickautomatic reboot, 9337216Skarelsbut do not want the machine to come up multiuser after the checks complete. 9455006Scael.Pp 9518871SmckusickWithout the 9655006Scael.Fl p 9718871Smckusickoption, 9855006Scael.Nm fsck 9960015Smckusickaudits and interactively repairs inconsistent conditions for filesystems. 10060015SmckusickIf the filesystem is inconsistent the operator is prompted for concurrence 10118871Smckusickbefore each correction is attempted. 10228345SmckusickIt should be noted that some of the corrective actions which are not 10328345Smckusickcorrectable under the 10455006Scael.Fl p 10528345Smckusickoption will result in some loss of data. 10618871SmckusickThe amount and severity of data lost may be determined from the diagnostic 10718871Smckusickoutput. 10818871SmckusickThe default action for each consistency correction 10955006Scaelis to wait for the operator to respond 11055006Scael.Li yes 11155006Scaelor 11255006Scael.Li no . 11360015SmckusickIf the operator does not have write permission on the filesystem 11455006Scael.Nm fsck 11518871Smckusickwill default to a 11655006Scael.Fl n 11755006Scaelaction. 11855006Scael.Pp 11955006Scael.Nm Fsck 12018871Smckusickhas more consistency checks than 12118871Smckusickits predecessors 12255006Scael.Em check , dcheck , fcheck , 12355006Scaeland 12455006Scael.Em icheck 12518871Smckusickcombined. 12655006Scael.Pp 12718871SmckusickThe following flags are interpreted by 12855006Scael.Nm fsck . 12955006Scael.Bl -tag -width indent 13055006Scael.It Fl b 13118872SmckusickUse the block specified immediately after the flag as 13260015Smckusickthe super block for the filesystem. Block 32 is usually 13318872Smckusickan alternate super block. 13455006Scael.It Fl l 13537216SkarelsLimit the number of parallel checks to the number specified in the following 13637216Skarelsargument. 13737216SkarelsBy default, the limit is the number of disks, running one process per disk. 13837216SkarelsIf a smaller limit is given, the disks are checked round-robin, one filesystem 13937216Skarelsat a time. 14055006Scael.It Fl m 14136827SmckusickUse the mode specified in octal immediately after the flag as the 14255006Scaelpermission bits to use when creating the 14355006Scael.Pa lost+found 14455006Scaeldirectory rather than the default 1777. 14536827SmckusickIn particular, systems that do not wish to have lost files accessible 14636827Smckusickby all users on the system should use a more restrictive 14736827Smckusickset of permissions such as 700. 14855006Scael.It Fl y 14918871SmckusickAssume a yes response to all questions asked by 15055006Scael.Nm fsck ; 15118871Smckusickthis should be used with great caution as this is a free license 15218871Smckusickto continue after essentially unlimited trouble has been encountered. 15355006Scael.It Fl n 15418871SmckusickAssume a no response to all questions asked by 15555006Scael.Nm fsck 15655006Scaelexcept for 15755006Scael.Ql CONTINUE? , 15855006Scaelwhich is assumed to be affirmative; 15960015Smckusickdo not open the filesystem for writing. 16055006Scael.It Fl c 16160015SmckusickConvert the filesystem to the specified level. 16260015SmckusickNote that the level of a filesystem can only be raised. 16360015Smckusick.Bl -tag -width indent 16468008SmckusickThere are currently four levels defined: 16560015Smckusick.It 0 16660015SmckusickThe filesystem is in the old (static table) format. 16760015Smckusick.It 1 16860015SmckusickThe filesystem is in the new (dynamic table) format. 16960015Smckusick.It 2 17060015SmckusickThe filesystem supports 32-bit uid's and gid's, 17160015Smckusickshort symbolic links are stored in the inode, 17260015Smckusickand directories have an added field showing the file type. 17368008Smckusick.It 3 17468008SmckusickIf maxcontig is greater than one, 17568008Smckusickbuild the free segment maps to aid in finding contiguous sets of blocks. 17668008SmckusickIf maxcontig is equal to one, delete any existing segment maps. 17760015Smckusick.El 17860015Smckusick.Pp 17934157SmckusickIn interactive mode, 18055006Scael.Nm fsck 18160015Smckusickwill list the conversion to be made 18234157Smckusickand ask whether the conversion should be done. 18334157SmckusickIf a negative answer is given, 18434157Smckusickno further operations are done on the filesystem. 18534157SmckusickIn preen mode, 18660015Smckusickthe conversion is listed and done if 18734157Smckusickpossible without user interaction. 18860015SmckusickConversion in preen mode is best used when all the filesystems 18934157Smckusickare being converted at once. 19060015SmckusickThe format of a filesystem can be determined from the 19134157Smckusickfirst line of output from 19255006Scael.Xr dumpfs 8 . 19355006Scael.El 19455006Scael.Pp 19518871SmckusickIf no filesystems are given to 19655006Scael.Nm fsck 19760015Smckusickthen a default list of filesystems is read from 19818871Smckusickthe file 19955006Scael.Pa /etc/fstab . 20055006Scael.Pp 20155006Scael.Bl -enum -indent indent -compact 20218871SmckusickInconsistencies checked are as follows: 20355006Scael.It 20434157SmckusickBlocks claimed by more than one inode or the free map. 20555006Scael.It 20660015SmckusickBlocks claimed by an inode outside the range of the filesystem. 20755006Scael.It 20818871SmckusickIncorrect link counts. 20955006Scael.It 21018871SmckusickSize checks: 21155006Scael.Bl -item -indent indent -compact 21255006Scael.It 21360015SmckusickDirectory size not a multiple of DIRBLKSIZ. 21455006Scael.It 21534157SmckusickPartially truncated file. 21655006Scael.El 21755006Scael.It 21818871SmckusickBad inode format. 21955006Scael.It 22018871SmckusickBlocks not accounted for anywhere. 22155006Scael.It 22218871SmckusickDirectory checks: 22355006Scael.Bl -item -indent indent -compact 22455006Scael.It 22518871SmckusickFile pointing to unallocated inode. 22655006Scael.It 22718871SmckusickInode number out of range. 22855006Scael.It 22939977SmckusickDot or dot-dot not the first two entries of a directory 23039977Smckusickor having the wrong inode number. 23155006Scael.El 23255006Scael.It 23318871SmckusickSuper Block checks: 23460015Smckusick.Bl -item -indent indent -compact 23555006Scael.It 23660015SmckusickMore blocks for inodes than there are in the filesystem. 23755006Scael.It 23834157SmckusickBad free block map format. 23955006Scael.It 24018871SmckusickTotal free block and/or free inode count incorrect. 24155006Scael.El 24260015Smckusick.El 24355006Scael.Pp 24418871SmckusickOrphaned files and directories (allocated but unreferenced) are, 24518871Smckusickwith the operator's concurrence, reconnected by 24618871Smckusickplacing them in the 24755006Scael.Pa lost+found 24818871Smckusickdirectory. 24928345SmckusickThe name assigned is the inode number. 25028345SmckusickIf the 25155006Scael.Pa lost+found 25228345Smckusickdirectory does not exist, it is created. 25328345SmckusickIf there is insufficient space its size is increased. 25455006Scael.Pp 25539977SmckusickBecause of inconsistencies between the block device and the buffer cache, 25639977Smckusickthe raw device should always be used. 25755006Scael.Sh FILES 25855006Scael.Bl -tag -width /etc/fstab -compact 25955006Scael.It Pa /etc/fstab 26060015Smckusickcontains default list of filesystems to check. 26155006Scael.El 26255006Scael.Sh DIAGNOSTICS 26318871SmckusickThe diagnostics produced by 26455006Scael.Nm fsck 26528345Smckusickare fully enumerated and explained in Appendix A of 26655006Scael.Rs 26755006Scael.%T "Fsck \- The UNIX File System Check Program" 26855006Scael.Re 26955006Scael.Sh SEE ALSO 27055006Scael.Xr fstab 5 , 27155006Scael.Xr fs 5 , 27255006Scael.Xr fsdb 8 , 27355006Scael.Xr newfs 8 , 27455006Scael.Xr mkfs 8 , 27555006Scael.Xr reboot 8 276