fsck(ADM) 06 January 1993 fsck(ADM) Name fsck, dfsck - check and repair filesystems Syntax /etc/fsck [ options ] [ filesystem ] ... /etc/dfsck [ options1 ] filesys1 ... -[ options2 ] filesys2 ... Description The fsck command audits and interactively repairs inconsistent conditions for all supported filesystems. If the filesystem is consistent, the num- ber of files, number of blocks used, and number of blocks free are reported. If the filesystem is inconsistent, the operator is prompted for concurrence before each correction is attempted. It should be noted that most corrective actions result in some loss of data. The amount and severity of the loss may be determined from the diagnostic output. (An experienced operator can resolve discrepancies manually using fsdb(ADM), the filesystem debugger.) The default action for each consistency correction is to wait for the operator to respond ``yes'' or ``no''. If the operator does not have write permission fsck defaults to the action of the -n option. If you check the root filesystem manually using fsck, you should first unmount all other filesystems using the umount(ADM) command. The following flags are interpreted by fsck: -a (Autoboot.) When called with this option, fsck examines the FSCKFIX flag in the /etc/default/boot file. If FSCKFIX is set to YES, fsck behaves as if it had been called with the -y flag. -b (S51K and AFS filesystems only.) Reboot. If the file system being checked is the root file system and modifications have been made, then either remount the root file system or reboot the system. A remount is done only if there was minor damage. -C[clustersize] (S51K filesystems only.) Converts the named S51K filesystem into an AFS (Acer Fast Filesystem). The -s option must also be present. The clustersize argument must be one of 1, 2, 4, 8, or 16 (8 is the recommended and default value). The increase in speed that is pos- sible with a fast filesystem will not be immediately apparent; it will take effect only with the new files added to the filesystem. There is little or no benefit in transforming a filesystem that is nearly full; if it is within a few blocks of being full, the conversion will not work. (This option can only be used to convert an S51K filesystem.) -E Converts the named AFS filesystem to Extended Acer Fast Filesystem (EAFS), which includes support for long filenames and symbolic links. Can be combined with -C option to convert an S51K file- system to EAFS. -y Assumes a yes response to all questions asked by fsck. -n Assumes a no response to all questions asked by fsck; do not open the filesystem for writing. -s[b:c] Ignores the actual free list and (unconditionally) reconstructs a new one by rewriting the super-block of the filesystem. The file- system must be unmounted while this is done. The -s option allows for creating an optimal free-list organiza- tion. The following forms are supported: -s Uses the default values from when the filesystem was created. -sBlocks-per-cylinder:Blocks-to-skip Uses the specified values. -S Conditionally reconstructs the free list. This option is like -sb:c above except that the free list is rebuilt only if there are no discrepancies discovered in the filesystem. Using -S forces a no response to all questions asked by fsck. This option is useful for forcing free list reorganization on uncontaminated filesystems. -t If fsck cannot obtain enough memory to keep its tables, it uses a scratch file. If the -t option is specified, the file named in the next argument is used as the scratch file, if needed. Make certain you leave a space between the -t and the filename, or fsck will use the entire filesystem as a scratch file and erase the entire disk. If you created a scratch filesystem during installation then you can use /dev/scratch as the filename, provided that the filesystem being checked is no larger than the root filesystem. Without the -t flag, fsck prompts the operator for the name of the scratch file. The file chosen should not be on the filesystem being checked, and if it is not a special file or did not already exist, it is removed when fsck completes. If the system has a large hard disk there may not be enough space on another filesystem for the scratch file. In such cases, if the system has a floppy drive, use a blank, formatted floppy in the floppy drive with (for example) /dev/fd0 specified as the scratch file. -q Quiet fsck. Do not print size-check messages in Phase 1. Unrefer- enced FIFO files will selectively be removed. If fsck requires it, counts in the super-block will be automatically fixed and the free list salvaged. -D Directories are checked for bad blocks. Useful after system crashes. -f Fast check. Check block and sizes (Phase 1) and check the free list (Phase 5). The free list will be reconstructed (Phase 6) if it is necessary. -rr (XENIX filesystems only.) Recovers the root filesystem. The required filesystem argument must refer to the root filesystem, and preferably to the block device (normally /dev/root). This switch implies -y and overrides -n. If any modifications to the file- system are required, the filesystem will be automatically mounted. If no filesystems are specified, fsck reads a list of default filesystems from the file /etc/checklist. Inconsistencies checked are as follows: + blocks claimed by more than one inode or the free list + blocks claimed by an inode or the free list outside the range of the filesystem + incorrect link counts + size checks: incorrect number of blocks directory size not 16-byte aligned + bad inode format + blocks not accounted for anywhere + directory checks: file pointing to unallocated inode inode number out of range + super-block checks: more than 65536 inodes more blocks for inodes than there are in the filesystem + bad free block list format + total free block or free inode count incorrect Orphaned files and directories (allocated but unreferenced) are, with the operator's concurrence, reconnected by placing them in the lost+found directory. The name assigned is the inode number. The only restriction is that the directory lost+found must preexist in the root of the file- system being checked and must have empty slots in which entries can be made. This is accomplished by making lost+found, copying a number of files to the directory, and then removing them (before fsck is executed). dfsck allows two filesystem checks on two different drives simultane- ously. options1 and options2 are used to pass options to fsck for the two sets of filesystems. A ``-'' is the separator between filesystem groups. The dfsck program permits an operator to interact with two fsck programs at once. To help in this, dfsck displays the filesystem name for each message to the operator. When answering a question from dfsck, the operator must preface the response with a 1 or a 2 (indicating that the answer refers to the first or second filesystem group). Do not use dfsck to check the root filesystem. Files /etc/checklist contains default list of filesystems to check /etc/default/boot automatic boot control See also autoboot(ADM), checklist(F), filesystem(FP), fsdb(ADM) and init(M). Notes The directory /etc/fscmd.d/fstyp contains programs for each filesystem type; each of these programs applies some appropriate heuristic to deter- mine whether the supplied special file is of the type for which it checks. fsck will not run on a mounted non-raw filesystem unless the filesystem is the root filesystem or unless the -n option is specified and no writ- ing out of the filesystem will take place. If any such attempt is made, a warning is displayed and no further processing of the filesystem is done for the specified device. Although checking a raw device is almost always faster, there is no way to tell if the filesystem is mounted. Cleaning a mounted filesystem will almost certainly result in an inconsistent super-block. Warning Filesystems created under UNIX-86 version 3.0 are not supported under UNIX System V/386 Release 3.2 because the word ordering in type long variables has changed. fsck is capable of auditing and repairing UNIX System V/386 version 3.0 filesystems if the word ordering is correct. For the root filesystem, fsck -b /dev/root should be run. For all other filesystems, fsck /dev/?? on the unmounted block device should be used. Diagnostics Initialization phase Command syntax is checked. Before the filesystem check can be performed, fsck sets up certain tables and opens some files. The fsck terminates on initialization errors. General errors Three error messages may appear in any phase. While they seem to offer the option to continue, it is generally best to regard them as fatal, end the run, and investigate what may have caused the problem. CAN NOT SEEK: BLK B (CONTINUE?) The request to move to a specified block number B in the filesystem failed. The occurrence of this error condition indicates a serious problem (probably a hardware failure) that may require additional help. CAN NOT READ: BLK B (CONTINUE?) The request for reading a specified block number B in the file- system failed. The occurrence of this error condition indicates a serious problem (probably a hardware failure) that may require additional help. CAN NOT WRITE: BLK B (CONTINUE?) The request for writing a specified block number B in the file- system failed. The disk may be write-protected. Meaning of yes/no responses __________________________________________________ Prompt n(no) y(yes) __________________________________________________ CONTINUE? Terminates pro- Attempts to gram. continue to run (This is the filesystem check. recommended Often, however, response.) the problem persists. The error condition does not allow a complete check of the filesystem. A second run of fsck should be made to recheck this filesystem. Phase 1: check blocks and sizes This phase checks the inode list. Meaning of yes/no responses--Phase 1 __________________________________________________ Prompt n(no) y(yes) __________________________________________________ CONTINUE? Terminates the Continues with program. the program. (Recommended This error response.) condition means that a complete check of the filesystem is not possible. A second run of fsck should be made to recheck this filesystem. CLEAR? Ignores the error Deallocates i- condition. node I by zeroing A NO response is its contents. only appropriate This may invoke if the user the UNALLOCATED intends to take error condition other measures to in Phase 2 for fix the problem. each directory entry pointing to this i-node. Phase 1 error messages EMPTY SYMLINK (CLEAR?) There is no pathname associated with a symbolic link. UNKNOWN FILE TYPE I=I (CLEAR?) The mode word of the i-node I suggests that the i-node is not a pipe, special character i-node, regular i-node, or directory i-node. This is also displayed when a non-EAFS version of fsck is run on a filesystem containing symbolic links. LINK COUNT TABLE OVERFLOW (CONTINUE?) An internal table for fsck containing allocated i-nodes with a link count of zero has no more room. B BAD I=I I-node I contains block number B with a number lower than the num- ber of the first data block in the filesystem or greater than the number of the last block in the filesystem. This error condition may invoke the EXCESSIVE BAD BLKS error condition in Phase 1 if i-node I has too many block numbers outside the filesystem range. This error condition invokes the BAD/DUP error condition in Phase 2 and Phase 4. EXCESSIVE BAD BLOCKS I=I (CONTINUE?) There is more than a tolerable number (usually 10) of blocks with a number lower than the number of the first data block in the file- system or greater than the number of the last block in the file- system associated with i-node I. B DUP I=I I-node I contains block number B, which is already claimed by another i-node. This error condition may invoke the EXCESSIVE DUP BLKS error condition in Phase 1 if i-node I has too many block num- bers claimed by other i-nodes. This error condition invokes Phase 1B and the BAD/DUP error condition in Phase 2 and Phase 4. EXCESSIVE DUP BLKS I=I (CONTINUE?) There is more than a tolerable number (usually 10) of blocks claimed by other i-nodes. DUP TABLE OVERFLOW (CONTINUE?) An internal table in fsck containing duplicate block numbers has no more room. POSSIBLE FILE SIZE ERROR I=I TOO MANY BLOCKS ALLOCATED The i-node I size is smaller than the actual number of blocks used by the i-node. If the -q option is used, this message is not printed. POSSIBLE FILE SIZE ERROR I=I TOO FEW BLOCKS ALLOCATED The i-node I size is greater than the actual number of blocks used by the i-node. If the -q option is used, this message is not printed. DIRECTORY MISALIGNED I=I The size of a directory i-node is not a multiple of 16. This is only a warning. If the -q option is used, this message is not printed. PARTIALLY ALLOCATED INODE I=I (CLEAR?) I-node I is neither allocated nor unallocated. Phase 1B: rescan for more DUPS When a duplicate block is found in the filesystem, the filesystem is res- canned to find the i-node that previously claimed that block. When the duplicate block is found, the following information message is printed: B DUP I=I I-node I contains block number B, which is already claimed by another i-node. This error condition invokes the BAD/DUP error condition in Phase 2. I-nodes with overlapping blocks may be determined by examining this error condition and the DUP error con- dition in Phase 1. Phase 2: check path names This phase removes directory entries pointing to bad i-nodes found in Phase 1 and Phase 1B. Meaning of yes/no responses -- Phase 2 __________________________________________________ Prompt n(no) y(yes) __________________________________________________ FIX? Terminates the In Phase 2, a program since y(yes) response fsck will be to the FIX? unable to prompt says: continue. Change the root i-node type to ``directory.'' If the root i- node data blocks are not directory blocks, a very large number of error conditions are produced. CONTINUE? Terminates the Ignores DUPS/BAD program. error condition in root i-node and attempt to continue to run the filesystem check. If root i-node is not correct, then this may result in a large number of other error conditions. REMOVE? Ignores the error Removes duplicate condition. A NO or unallocated response is only blocks. appropriate if the user intends to take other measures to fix the problem. Phase 2 error messages ROOT INODE UNALLOCATED. TERMINATING The root i-node (always i-node number 2) has no allocate mode bits. The occurrence of this error condition indicates a serious problem. The program stops. ROOT INODE NOT DIRECTORY (FIX?) The root i-node (usually i-node number 2) is not directory i-node type. DUPS/BAD IN ROOT INODE (CONTINUE?) Phase 1 or Phase 1B found duplicate blocks or bad blocks in the root i-node (usually i-node number 2) for the filesystem. I OUT OF RANGE I=I NAME=F (REMOVE?) A directory entry F has an i-node number I that is greater than the end of the i-node list. UNALLOCATED I=I OWNER=O MODE=M SIZE=S MTIME=T NAME=F (REMOVE?) A directory entry F has an i-node I without allocate mode bits. The owner O, mode M, size S, modify time T, and filename F are printed. If the filesystem is not mounted and the -n option was not specified, the entry is removed automatically if the i-node it points to is character size 0. DUP/BAD I=I OWNER=O MODE=M SIZE=S MTIME=T DIR=F (REMOVE?) Phase 1 or Phase 1B found duplicate blocks or bad blocks associated with directory entry F, directory i-node I. The owner O, mode M, size S, modify time T, and directory name F are printed. DUP/BAD I=I OWNER=O MODE=M SIZE=S MTIME=T FILE=F (REMOVE?) Phase 1 or Phase 1B found duplicate blocks or bad blocks associated with file entry F, i-node I. The owner O, mode M, size S, modify time T, and filename F are printed. BAD BLK B IN DIR I=I OWNER=O MODE=M SIZE=S MTIME=T This message only occurs when the -D option is used. A bad block was found in DIR i-node I. Error conditions looked for in direc- tory blocks are nonzero padded entries, inconsistent ``.'' and ``.\&.'' entries, and embedded slashes in the name field. This error message means that the user should at a later time either remove the directory i-node if the entire block looks bad or change (or remove) those directory entries that look bad. Phase 3: check connectivity This phase is concerned with the directory connectivity seen in Phase 2. Meaning of yes/no responses -- Phase 3 ___________________________________________________ Prompt n(no) y(yes) ___________________________________________________ RECONNECT? Ignores the error Reconnects condition. directory i-node This invokes the I to the UNREF error filesystem in condition in directory for Phase 4. lost files A NO response is (usually only appropriate lost+found). if the user This may invoke a intends to take lost+found error other measures to condition if fix the problem. there are problems connecting directory i-node I to lost+found. This invokes CONNECTED information message if link was successful. Phase 3 error messages UNREF DIR I=I OWNER=O MODE=M SIZE=S MTIME=T (RECONNECT?) The directory i-node I was not connected to a directory entry when the filesystem was traversed. The owner O, mode M, size S, and modify time T of directory i-node I are printed. The fsck program forces the reconnection of a nonempty directory. SORRY. NO lost+found DIRECTORY There is no lost+found directory in the root directory of the file- system; fsck ignores the request to link a directory in lost+found. This invokes the UNREF error condition in Phase 4. Possible prob- lem with access modes of lost+found. SORRY. NO SPACE IN lost+found DIRECTORY There is no space to add another entry to the lost+found directory in the root directory of the filesystem; fsck ignores the request to link a directory in lost+found. This invokes the UNREF error condition in Phase 4. Clean out unnecessary entries in lost+found or make lost+found larger (see Procedure 5.2). DIR I=I1 CONNECTED. PARENT WAS I=I2 This is an advisory message indicating a directory i-node I1 was successfully connected to the lost+found directory. The parent i-node I2 of the directory i-node I1 is replaced by the i-node num- ber of the lost+found directory. Phase 4: check reference counts This phase checks the link count information seen in Phases 2 and 3. Meaning of yes/no responses -- Phase 4 ___________________________________________________ Prompt n(no) y(yes) ___________________________________________________ RECONNECT? Ignores this Reconnect i-node error condition. I to filesystem This invokes a in the directory CLEAR error for lost files condition later (usually in Phase 4. lost+found). This can cause a lost+found error condition in this phase if there are problems connecting i-node I to lost+found. CLEAR? Ignores the error Deallocates the condition. i-node by zeroing A NO response is its contents. only appropriate if the user intends to take other measures to fix the problem. ADJUST? Ignores the error Replaces link condition. count of file i- A NO response is node I with Y. only appropriate if the user intends to take other measures to fix the problem. FIX? Ignores the error Replaces count in condition. super-block by A NO response is actual count. only appropriate if the user intends to take other measures to fix the problem. Phase 4 error messages UNREF FILE I=I OWNER=O MODE=M SIZE=S MTIME=T (RECONNECT?) I-node I was not connected to a directory entry when the filesystem was traversed. The owner O, mode M, size S, and modify time T of i-node I are printed. If the -n option is omitted and the file- system is not mounted, empty files are cleared automatically. Nonempty files are not cleared. SORRY. NO lost+found DIRECTORY There is no lost+found directory in the root directory of the file- system; fsck ignores the request to link a file in lost+found. This invokes the CLEAR error condition later in Phase 4. SORRY. NO SPACE IN lost+found DIRECTORY There is no space to add another entry to the lost+found directory in the root directory of the filesystem; fsck ignores the request to link a file in lost+found. This invokes the CLEAR error condi- tion later in Phase 4. Check size and contents of lost+found. (CLEAR) The i-node mentioned in the immediately previous UNREF error condi- tion cannot be reconnected. LINK COUNT FILE I=I OWNER=O MODE=M SIZE=S MTIME=T COUNT=X SHOULDBE Y (ADJUST?) The link count for i-node I, which is a file, is X but should be Y. The owner O, mode M, size S, and modify time T are printed. LINK COUNT DIR I=I OWNER=O MODE=M SIZE=S MTIME=T COUNT=X SHOULD BE Y (ADJUST?) The link count for i-node I, which is a directory, is X but should be Y. The owner O, mode M, size S, and modify time T of directory i-node I are printed. LINK COUNT F I=I OWNER=O MODE=M SIZE=S MTIME=T COUNT=X SHOULD BE Y (ADJUST?) The link count for F i-node I is X but should be Y. The filename F, owner O, mode M, size S, and modify time T are printed. UNREF FILE I=I OWNER=O MODE=M SIZE=S MTIME=T (CLEAR?) I-node I, which is a file, was not connected to a directory entry when the filesystem was traversed. The owner O, mode M, size S, and modify time T of i-node I are printed. If the -n option is omitted and the filesystem is not mounted, empty files are cleared automatically. Nonempty directories are not cleared. UNREF DIR I=I OWNER=O MODE=M SIZE=S MTIME=T (CLEAR?) I-node I, which is a directory, was not connected to a directory entry when the filesystem was traversed. The owner O, mode M, size S, and modify time T of i-node I are printed. If the -n option is omitted and the filesystem is not mounted, empty directories are cleared automatically. Nonempty directories are not cleared. BAD/DUP FILE I=I OWNER=O MODE=M SIZE=S MTIME=T (CLEAR?) Phase 1 or Phase 1B found duplicate blocks or bad blocks associated with file i-node I. The owner O, mode M, size S, and modify time T of i-node I are printed. BAD/DUP DIR I=I OWNER=O MODE=M SIZE=S MTIME=T (CLEAR?) Phase 1 or Phase 1B found duplicate blocks or bad blocks associated with directory i-node I. The owner O, mode M, size S, and modify time T of i-node I are printed. FREE INODE COUNT WRONG IN SUPERBLK (FIX?) The actual count of the free i-nodes does not match the count in the super-block of the filesystem. If the -q option is specified, the count will be fixed automatically in the super-block. Phase 5: check free list This phase checks the free-block list. Meaning of yes/no responses -- Phase 5 __________________________________________________ Prompt n(no) y(yes) __________________________________________________ CONTINUE? Terminates the Ignores rest of program. the free-block list and continue execution of fsck. This error condition will always invoke BAD BLKS IN FREE LIST error condition later in Phase 5. FIX? Ignores the error Replaces count in condition. super-block by A NO response is actual count. only appropriate if the user intends to take other measures to fix the problem. SALVAGE? Ignores the error Replaces actual condition. free-block list A NO response is with a new free- only appropriate block list. if the user The new free- intends to take block list will other measures to be ordered fix the problem. according to the gap and cylinder specs of the -s or -S option to reduce time spent waiting for the disk to rotate into position. Phase 5 error messages EXCESSIVE BAD BLKS IN FREE LIST (CONTINUE?) The free-block list contains more than a tolerable number (usually 10) of blocks with a value less than the first data block in the filesystem or greater than the last block in the filesystem. EXCESSIVE DUP BLKS IN FREE LIST (CONTINUE?) The free-block list contains more than a tolerable number (usually 10) of blocks claimed by i-nodes or earlier parts of the free-block list. BAD FREEBLK COUNT The count of free blocks in a free-list block is greater than 50 or less than 0. This error condition will always invoke the BAD FREE LIST condition later in Phase 5. X BAD BLKS IN FREE LIST X blocks in the free-block list have a block number lower than the first data block in the filesystem or greater than the last block in the filesystem. This error condition will always invoke the BAD FREE LIST condition later in Phase 5. X DUP BLKS IN FREE LIST X blocks claimed by i-nodes or earlier parts of the free-block list were found in the free-block list. This error condition will always invoke the BAD FREE LIST condition later in Phase 5. X BLK(S) MISSING X blocks unused by the filesystem were not found in the free-block list. This error condition will always invoke the BAD FREE LIST condition later in Phase 5. FREE BLK COUNT WRONG IN SUPERBLOCK (FIX?) The actual count of free blocks does not match the count in the super-block of the filesystem. BAD FREE LIST (SALVAGE?) This message is always preceded by one or more of the Phase 5 in- formation messages. If the -q option is specified, the free-block list will be salvaged automatically. Phase 6: salvage free list This phase reconstructs the free-block list. It has one possible error condition that results from bad blocks-per-cylinder and gap values. Phase 6 error messages DEFAULT FREE-BLOCK LIST SPACING ASSUMED This is an advisory message indicating the blocks-to-skip (gap) is greater than the blocks-per-cylinder, the blocks-to-skip is less than 1, the blocks-per-cylinder is less than 1, or the blocks-per- cylinder is greater than 500. The values of 7 blocks-to-skip and 400 blocks-per-cylinder are used. Cleanup phase Once a filesystem has been checked, a few cleanup functions are per- formed. The cleanup phase displays advisory messages about the file- system and status of the filesystem. Cleanup phase messages X files Y blocks Z free This is an advisory message indicating that the filesystem checked contained X files using Y blocks leaving Z blocks free in the file- system. ***** BOOT UNIX (NO SYNC!) ***** This is an advisory message indicating that a mounted filesystem or the root filesystem has been modified by fsck. If the UNIX system is not rebooted immediately without sync, the work done by fsck may be undone by the in-core copies of tables the UNIX system keeps. If the -b option of the fsck command was specified and the file- system is root, a reboot is automatically done. ***** FILE SYSTEM WAS MODIFIED ***** This is an advisory message indicating that the current filesystem was modified by fsck.