File System Administration
검색에만이 책은
PDF로 이 문서 다운로드

Checking File System Integrity

12

This chapter contains these sections:
Understanding How the File System State Is Recordedpage 218
What fsck Checks and Tries to Repairpage 219
Error Messagespage 226
Modifying Automatic Boot Checkingpage 253
Interactively Checking and Repairing a UFS File Systempage 255
Restoring a Bad Superblockpage 258
Syntax and Options for the fsck Commandpage 260
The UFS file system relies on an internal set of tables to keep track of inodes and used and available blocks. When these internal tables are not properly synchronized with data on a disk, inconsistencies result and file systems need to be repaired.
File systems can be damaged or become inconsistent because of abrupt termination of the operating system in these ways:
  • Power failure
  • Accidental unplugging of the system
  • Turning the system off without proper shutdown procedure
  • A software error in the kernel
File system corruption, while serious, is not common. When a system is booted, a file system consistency check is automatically done. Most of the time, this file system check repairs problems it encounters.
File systems are checked with the fsck (file system check) program. This chapter describes the flags to fsck, what fsck checks and repairs, and fsck error messages. It also describes how to modify the automatic checking done during booting, how to find out if a file system needs to be checked, how to check and repair a UFS file system interactively, how to restore a bad superblock, and how to fix a UFS file system that fsck cannot repair.
The fsck command puts files and directories that are allocated but unreferenced in the lost+found directory. The inode number of each file is assigned as the name. If the lost+found directory does not exist, fsck creates it. If there is not enough space in the lost+found directory, fsck increases its size.

Understanding How the File System State Is Recorded

The Solaris 2.3 fsck command uses a state flag, which is stored in the superblock, to record the condition of the file system. This flag is used by the fsck command to determine whether or not a file system needs to be checked for consistency. The flag is used by the /etc/bcheckrc script during booting and by the fsck command when run from a command line using the -m option. If you ignore the result from the -m option to fsck, all file systems can be checked regardless of the setting of the state flag.
The possible state values are:
  • FSCLEAN - If the file system was unmounted properly, the state flag is set to FSCLEAN. Any file system with an FSCLEAN state flag is not checked when the system is booted.
  • FSSTABLE - The file system is (or was) mounted but has not changed since the last checkpoint: sync or fsflush--which normally occurs every 30 seconds. For example, the kernel periodically checks to see if a file system is idle and, if so, flushes the information in the superblock back to the disk and marks it FSSTABLE. If the system crashes, the file system structure is stable, but users may lose a small amount of data. File systems that are marked FSSTABLE can skip the checking before mounting.
  • FSACTIVE - When a file system is mounted and then modified, the state flag is set to FSACTIVE. The file system may contain inconsistencies. A file system will be marked as FSACTIVE before any modified metadata is written to the disk. When a file system is unmounted gracefully, the state flag is set to FSCLEAN. A file system with the FSACTIVE flag must be
checked by fsck because it may be inconsistent. The mount(2) system call will not mount a file system for read/write if the file system state is not FSCLEAN or FSSTABLE.
  • FSBAD - When the root file system is mounted when its state is not FSCLEAN or FSSTABLE, the state flag is set to FSBAD. The kernel will not change this file system state to FSCLEAN or FSSTABLE. If a root file system is flagged FSBAD as part of the boot process, it will be mounted read-only. You can run fsck on the raw root device. Then remount the root file system as read/write.
Table 12-1 shows when the state flag is modified.
Table 12-1 fsck
Before fsckAfter fsck

Initial StateNo ErrorsNew State All Errors CorrectedUncorrected Errors
unknownstablestableunknown
activestablestableactive
stablestablestableactive
cleancleanstableactive
badstablestablebad

What fsck Checks and Tries to Repair

This section describes what happens in the normal operation of a file system, what can go wrong, what problems fsck (the checking and repair utility) looks for, and how it corrects the inconsistencies it finds.

Why Inconsistencies May Occur

Every working day hundreds of files may be created, modified, and removed. Each time a file is modified, the operating system performs a series of file system updates. These updates, when written to the disk reliably, yield a consistent file system.
When a user program does an operation to change the file system, such as a write, the data to be written is first copied into an internal in-core buffer in the kernel. Normally, the disk update is handled asynchronously; the user process
is allowed to proceed even though the data write may not happen until long after the write system call has returned. Thus at any given time, the file system, as it resides on the disk, lags behind the state of the file system represented by the in-core information.
The disk information is updated to reflect the in-core information when the buffer is required for another use or when the kernel automatically runs the fsflush daemon (at 30-second intervals). If the system is halted without writing out the in-core information, the file system on the disk will be in an inconsistent state.
A file system can develop inconsistencies in several ways. The most common causes are operator error and hardware failures.
Problems may result from an unclean halt, if a system is shut down improperly, or when a mounted file system is taken offline improperly. To prevent unclean halts, the current state of the file systems must be written to disk (that is, "synchronized") before halting the CPU, physically taking a disk pack out of a drive, or taking a disk offline.
Inconsistencies can also result from defective hardware. Blocks can become damaged on a disk drive at any time, or a disk controller can stop functioning correctly.

The UFS Components That Are Checked for Consistency

This section describes the kinds of consistency checks applied to these UFS file system components: superblock, cylinder group blocks, inodes, indirect blocks, and data blocks.

Superblock

The superblock stores summary information, which is the most commonly corrupted item in a UFS file system. Each change to the file system data blocks or inodes also modifies the superblock. If the CPU is halted and the last command is not a sync command, the superblock will almost certainly be corrupted.
The superblock is checked for inconsistencies in:
  • File system size
  • Number of inodes
  • Free-block count
  • Free-inode count
File System and Inode List Size The file system size must be larger than the number of blocks used by the superblock and the number of blocks used by the list of inodes. The number of inodes must be less than the maximum number allowed for the file system. The file system size and layout information are the most critical pieces of information for fsck. Although there is no way to actually check these sizes, because they are statically determined when the file system is created, fsck can check that the sizes are within reasonable bounds. All other file system checks require that these sizes be correct. If fsck detects corruption in the static parameters of the primary superblock, it requests the operator to specify the location of an alternate superblock.
Free Blocks Free blocks are stored in the cylinder group block maps. fsck checks that all the blocks marked as free are not claimed by any files. When all the blocks have been accounted for, a check is made to see if the number of free blocks plus the number of blocks claimed by the inodes equals the total number of blocks in the file system. If anything is wrong with the block allocation maps, fsck rebuilds them, leaving out blocks already allocated.
The summary information in the superblock contains a count of the total number of free blocks within the file system. The fsck program compares this count to the number of free blocks it finds within the file system. If the counts do not agree, fsck replaces the count in the superblock with the actual free-block count.
Free Inodes The summary information in the superblock contains a count of the number of free inodes within the file system. The fsck program compares this count to the number of free inodes it finds within the file system. If the counts do not agree, fsck replaces the count in the superblock with the actual free inode count.

Inodes

The list of inodes is checked sequentially starting with inode 2 (inode 0 and inode 1 are reserved). Each inode is checked for inconsistencies in:
  • Format and type
  • Link count
  • Duplicate block
  • Bad block numbers
  • Inode size
Format and Type of Inodes Each inode contains a mode word, which describes the type and state of the inode. Inodes may be one of six types:
  • Regular
  • Directory
  • Block special
  • Character special
  • FIFO (named-pipe)
  • Symbolic link
Inodes may be in one of three states:
  • Allocated
  • Unallocated
  • Partially allocated
When the file system is created, a fixed number of inodes are set aside, but they are not allocated until they are needed. An allocated inode is one that points to a file. An unallocated inode does not point to a file and, therefore, should be empty. The partially allocated state means that the inode is incorrectly formatted. An inode can get into this state if, for example, bad data is written into the inode list because of a hardware failure. The only corrective action fsck can take is to clear the inode.
Link Count Each inode contains a count of the number of directory entries linked to it. The fsck program verifies the link count of each inode by examining the entire directory structure, starting from the root directory, and calculating an actual link count for each inode.
Discrepancies between the link count stored in the inode and the actual link count as determined by fsck may be of three types:
  • The stored count is not 0 and the actual count is 0.

    This condition can occur if no directory entry exists for the inode. In this case, fsck puts the disconnected file in the lost+found directory.

  • The stored count is not 0 and the actual count is not 0, but the counts are unequal.

    This condition can occur if a directory entry has been added or removed but the inode has not been updated. In this case, fsck replaces the stored link count with the actual link count.

  • The stored count is 0 and the actual count is not 0.

    In this case fsck changes the link count of the inode to the actual count.

Duplicate Blocks Each inode contains a list, or pointers to lists (indirect blocks), of all the blocks claimed by the inode. Because indirect blocks are owned by an inode, inconsistencies in indirect blocks directly affect the inode that owns the indirect block.
The fsck program compares each block number claimed by an inode to a list of allocated blocks. If another inode already claims a block number, the block number is put on a list of duplicate blocks. Otherwise, the list of allocated blocks is updated to include the block number.
If there are any duplicate blocks, fsck makes a second pass of the inode list to find the other inode that claims each duplicate block. (A large number of duplicate blocks in an inode may be caused by an indirect block not being written to the file system.) It is not possible to determine with certainty which inode is in error. The fsck program prompts you to choose which inode should be kept and which should be cleared.
Bad Block Numbers The fsck program checks each block number claimed by an inode to see that its value is higher than that of the first data block and lower than that of the last data block in the file system. If the block number is outside this range, it is considered a bad block number.
Bad block numbers in an inode may be caused by an indirect block not being written to the file system. The fsck program prompts you to clear the inode.
Inode Size Each inode contains a count of the number of data blocks that it references. The number of actual data blocks is the sum of the allocated data blocks and the indirect blocks. fsck computes the number of data blocks and compares that block count against the number of blocks the inode claims. If an inode contains an incorrect count, fsck prompts you to fix it.
Each inode contains a 64-bit size field. This field shows the number of characters (data bytes) in the file associated with the inode. A rough check of the consistency of the size field of an inode is done by using the number of characters shown in the size field to calculate how many blocks should be associated with the inode, and then comparing that to the actual number of blocks claimed by the inode.

Indirect Blocks

Indirect blocks are owned by an inode. Therefore, inconsistencies in an indirect block affect the inode that owns it. Inconsistencies that can be checked are:
  • Blocks already claimed by another inode
  • Block numbers outside the range of the file system
The consistency checks are also performed for indirect blocks.

Directory Data Blocks

An inode can directly or indirectly reference three kinds of data blocks. All referenced blocks must be of the same kind. The three types of data blocks are:
  • Plain data blocks
  • Symbolic-link data blocks
  • Directory data blocks
Plain data blocks contain the information stored in a file. Symbolic-link data blocks contain the path name stored in a symbolic link. Directory data blocks contain directory entries. fsck can check the validity only of directory data blocks.
Directories are distinguished from regular files by an entry in the mode field of the inode. Data blocks associated with a directory contain the directory entries. Directory data blocks are checked for inconsistencies involving:
  • Directory inode numbers pointing to unallocated inodes
  • Directory inode numbers greater than the number of inodes in the file system
  • Incorrect directory inode numbers for "." and ".." directories
  • Directories disconnected from the file system
Directory Unallocated If the inode number in a directory data block points to an unallocated inode, fsck removes the directory entry. This condition can occur if the data blocks containing the directory entries are modified and written out but the inode does not get written out. This condition can occur if the CPU is halted without warning.
Bad Inode Number If a directory entry inode number points beyond the end of the inode list, fsck removes the directory entry. This condition can occur when bad data is written into a directory data block.
Incorrect "." and ".." Entries The directory inode number entry for "." must be the first entry in the directory data block. It must reference itself; that is, its value must be equal to the inode number for the directory data block.
The directory inode number entry for ".." must be the second entry in the directory data block. Its value must be equal to the inode number of the parent directory (or the inode number of itself if the directory is the root directory).
If the directory inode numbers for "." and ".." are incorrect, fsck replaces them with the correct values. If there are multiple hard links to a directory, the first one found is considered the real parent to which ".." should point. In this case, fsck recommends you have it delete the other names.
Disconnected Directories The fsck program checks the general connectivity of the file system. If a directory is found that is not linked to the file system, fsck links the directory to the lost+found directory of the file system. (This condition can occur when inodes are written to the file system but the corresponding directory data blocks are not.)

Regular Data Blocks

Data blocks associated with a regular file hold the contents of the file. fsck does not attempt to check the validity of the contents of a regular file's data blocks.

Error Messages

Normally, fsck is run non-interactively to preen the file systems after an abrupt system halt in which the latest file system changes were not written to disk. Preening automatically fixes any basic file system inconsistencies and does not try to repair more serious errors. While preening a file system, fsck fixes the inconsistencies it expects from such an abrupt halt. For more serious conditions, the command reports the error and terminates.
When you run fsck interactively, fsck reports each inconsistency found and fixes innocuous errors. However, for more serious errors, the command reports the inconsistency and prompts you to choose a response. When you run fsck using the -y or -n options, your response is predefined as yes or no to the default response suggested by fsck for each error condition.
Some corrective actions will result in some loss of data. The amount and severity of data loss may be determined from the fsck diagnostic output.
fsck is a multipass file system check program. Each pass invokes a different phase of the fsck program with different sets of messages. After initialization, fsck performs successive passes over each file system, checking blocks and sizes, path names, connectivity, reference counts, and the map of free blocks (possibly rebuilding it), and performs some cleanup.
The phases (passes) performed by the UFS version of fsck are:
  • Initialization
  • Phase 1 - Check blocks and sizes
  • Phase 2 - Check path names
  • Phase 3 - Check connectivity
  • Phase 4 - Check reference counts
  • Phase 5 - Check cylinder groups
The next sections describe the error conditions that may be detected in each phase, the messages and prompts that result, and possible responses you can make.
Messages that may appear in more than one phase are described in "General fsck Error Messages" on page 227. Otherwise, messages are organized by the phases in which they occur. In addition, to help you look up a message, they are presented in alphabetical order.
Many of the messages include the abbreviations shown in Table 12-2:
Table 12-2 fsck
AbbreviationMeaning
BLKBlock number
DUPDuplicate block number
DIRDirectory name
CGCylinder group
MTIMETime file was last modified
UNREFUnreferenced
Many of the messages also include variable fields, such as inode numbers, which are represented in this book by an italicized term, such as inode-number. For example, this screen message:
    INCORRECT BLOCK COUNT I=2529

is shown as:
INCORRECT BLOCK COUNT I=inode-number

General fsck Error Messages

The error messages in this section may be displayed in any phase after initialization. Although they offer the option to continue, it is generally best to regard them as fatal. They reflect a serious system failure and should be
handled immediately. When confronted with such a message, terminate the program with a no response. If you cannot determine what caused the problem, contact your local service provider or another qualified person.
CANNOT SEEK: BLK block-number (CONTINUE) A request to move to a specified block number block-number in the file system failed. This message indicates a serious problem, probably a hardware failure.
If you want to continue the file system check, do a second run of fsck to recheck the file system. If the block was part of the virtual memory buffer cache, fsck will terminate with:

  Fatal I/O error  

CANNOT READ: BLK block-number (CONTINUE)

A request to read a specified block number block-number in the file system failed. The message indicates a serious problem, probably a hardware failure. If you want to continue the file system check, fsck will retry the read and display this message:

  THE FOLLOWING SECTORS COULD NOT BE READ: sector-numbers  

where sector-numbers indicates the sectors that could not be read. If fsck tries to write back one of the blocks on which the read failed it displays this message:

  WRITING ZERO'ED BLOCK sector-numbers TO DISK  

where sector-numbers indicates the sector that was written with zeroes. If the disk is experiencing hardware problems, the problem will persist. This error condition prevents a complete check of the file system. Run fsck again to recheck the file system. If the block was part of the virtual memory buffer cache, fsck terminates and displays this error message:

  Fatal I/O error  

CANNOT WRITE: BLK block-number (CONTINUE) A request to write a specified block number block-number in the file system failed. The disk may be write-protected. Check the write-protect lock on the drive. If that is not the problem, contact your local service provider or another qualified person. If you continue the file system check, the write operation will be retried. Sectors that could not be written are shown with this message:

  THE FOLLOWING SECTORS COULD NOT BE WRITTEN: sector-numbers  

where sector-numbers indicates the sectors that could not be written. If the disk has hardware problems, the problem will persist. This error condition prevents a complete check of the file system. Run fsck a second time to recheck this file system. If the block was part of the virtual memory buffer cache, fsck terminates and displays this error message:

  Fatal I/O error  

Initialization Phase fsck Messages

In the initialization phase, command-line syntax is checked. Before the file system check can be performed, fsck sets up tables and opens files.
The messages in this section relate to error conditions resulting from command-line options, memory requests, the opening of files, the status of files, file system size checks, and the creation of the scratch file. All such initialization errors terminate fsck when it is preening the file system.
bad inode number inode-number to ginode

An internal error occurred because of a nonexistent inode inode-number. fsck exits. If this message is displayed, contact your local service provider or another qualified person.
cannot alloc size-of-block map bytes for blockmap
cannot alloc size-of-free map bytes for freemap
cannot alloc size-of-state map bytes for statemap
cannot alloc size-of-lncntp bytes for lncntp

Request for memory for its internal tables failed. fsck terminates. This message indicates a serious system failure that should be handled immediately. This condition may occur if other processes are using a very large amount of system resources. Killing other processes may solve the problem. Contact your local service provider or another qualified person.
Can't open checklist file: filename
  The file system checklist file filename (usually /etc/vfstab) cannot be
  opened for reading. fsck terminates. Check to see if the file exists and if its
  access modes permit read access.

Can't open filename
  fsck cannot open file system filename. When running interactively, fsck
  ignores this file system and continues checking the next file system given.
  Check to see if read and write access to the raw device file for the file system
  is permitted.

Can't stat root
  fsck request for statistics about the root directory failed. fsck terminates.
  This message indicates a serious system failure. Contact your local service
  provider or another qualified person.

Can't stat filename
Can't make sense out of name filename

fsck request for statistics about the file system filename failed. When running interactively, fsck ignores this file system and continues checking the next file system given. Check to see if the file system exists and check its access modes.
filename: (NO WRITE)

Either the -n option was specified or fsck could not open the file system filename for writing. When fsck is running in no-write mode, all diagnostic messages are displayed, but fsck does not attempt to fix anything.
If -n was not specified, check the type of the file specified. It may be the name of a regular file.
IMPOSSIBLE MINFREE=percent IN SUPERBLOCK (SET TO DEFAULT)

The superblock minimum space percentage is greater than 99 percent or less than 0 percent.
At the SET TO DEFAULT prompt, type:
y - To set the minfree parameter to 10 percent.
n - To ignore this error condition.
INTERNAL INCONSISTENCY: message
  fsck has had an internal error, whose message is message. If this message is
  displayed, contact your local service provider or another qualified person.

MAGIC NUMBER WRONG
NCG OUT OF RANGE
CPG OUT OF RANGE
NCYL DOES NOT JIBE WITH NCG*CPG
SIZE PREPOSTEROUSLY LARGE
TRASHED VALUES IN SUPER BLOCK

followed by
filename: BAD SUPER BLOCK: block-number
USE AN ALTERNATE SUPER-BLOCK TO SUPPLY NEEDED INFORMATION;
e.g., fsck[-f ufs] -o b=# [special ...]
where # is the alternate superblock.  See fsck_ufs(1M)

The superblock has been corrupted. Use an alternative superblock to supply needed information. Specifying block 32 is a good first choice. You can locate an alternative copy of the superblock by running the newfs -N command on the slice.

CAUTION Caution - Be sure to specify the -N option; otherwise, newfs overwrites the existing file system.

UNDEFINED OPTIMIZATION IN SUPERBLOCK (SET TO DEFAULT)

The superblock optimization parameter is neither OPT_TIME nor OPT_SPACE.
At the SET TO DEFAULT prompt, type:
y - To minimize the time to perform operations on the file system.
n - To ignore this error condition.

Phase 1: Check Blocks and Sizes Messages

This phase checks the inode list. It reports error conditions encountered while:
  • Checking inode types
  • Setting up the zero-link-count table
  • Examining inode block numbers for bad or duplicate blocks
  • Checking inode size
  • Checking inode format
All errors in this phase except INCORRECT BLOCK COUNT, PARTIALLY TRUNCATED INODE, PARTIALLY ALLOCATED INODE, and UNKNOWN FILE TYPE terminate fsck when it is preening a file system.
These messages (in alphabetical order) may occur in phase 1:
block-number BAD I=inode-number
Inode inode-number contains a block number block-number 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. This error condition may generate the EXCESSIVE BAD BLKS error message in phase 1 if inode inode-number has too many block numbers outside the file system range. This error condition generates the BAD/DUP error message in phases 2 and 4.
BAD MODE: MAKE IT A FILE?

  The status of a given inode is set to all 1s, indicating file system damage.
  This message does not indicate physical disk damage, unless it is displayed
  repeatedly after fsck -y has been run. Type y to reinitialize the inode to a
  reasonable value.

BAD STATE state-number TO BLKERR

An internal error has scrambled the fsck state map so that it shows the impossible value state-number. fsck exits immediately. If this error message is displayed, contact your local service provider or another qualified person.
block-number DUP I=inode-number

Inode inode-number contains a block number block-number, which is already claimed by the same or another inode. This error condition may generate the EXCESSIVE DUP BLKS error message in phase 1 if inode inode-number has too many block numbers claimed by the same or another inode. This error condition invokes phase 1B and generates the BAD/DUP error messages in phases 2 and 4.
DUP TABLE OVERFLOW (CONTINUE)

There is no more room in an internal table in fsck containing duplicate block numbers. If the -o p option is specified, the program terminates.
Type:
y - To continue the program. When this error occurs, a complete check of the file system is not possible. If another duplicate block is found, this error condition repeats. Increase the amount of virtual memory available (by killing some processes, increasing swap space) and run fsck again to recheck the file system.
n - To terminate the program.
EXCESSIVE BAD BLOCKS I=inode-number (CONTINUE)

Too many (usually more than 10) blocks have 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 inode inode-number. If the -o p (preen) option is specified, the program terminates.
Type:
y - To continue the program. When this error occurs, a complete check of the file system is not possible. You should run fsck again to recheck the file system.
n - To terminate the program.
EXCESSIVE DUP BLKS I=inode-number (CONTINUE)

Too many (usually more than 10) blocks are claimed by the same or another inode or by a free-list. If the -o p option is specified, the program terminates.
Type: y - To continue the program. When this error occurs, a complete check of the file system is not possible. A second run of fsck should be made to recheck the file system.
n - To terminate the program.
INCORRECT BLOCK COUNT I=inode-number (number-of-BAD-DUP-or-missing-blocks should be number-of-blocks-in-filesystem) (CORRECT)
The block count for inode inode-number is number-of-BAD-DUP-or-missing-blocks, but should be number-of-blocks-in-filesystem. When preening, fsck corrects the count.
At the CORRECT prompt, type:
y - To replace the block count of inode inode-number by number-of-blocks-in- filesystem.
n - To ignore this error condition.
LINK COUNT TABLE OVERFLOW (CONTINUE)

There is no more room in an internal table for fsck containing allocated inodes with a link count of zero. If the -o p (preen) option is specified, the program exits and fsck has to be completed manually.
Type:
y - To continue the program. If another allocated inode with a zero-link count is found, this error condition repeats. When this error occurs, a complete check of the file system is not possible. A second run of fsck should be made to recheck the file system. Increase the virtual memory available by killing some processes, or increasing swap space, before running fsck again.
n - To terminate the program.
PARTIALLY ALLOCATED INODE I=inode-number (CLEAR)

Inode inode-number is neither allocated nor unallocated. If the -o p (preen) option is specified, the inode is cleared.
Type:
y - To deallocate the inode inode-number by zeroing out its contents. This may generate the UNALLOCATED error condition in phase 2 for each directory entry pointing to this inode.
n - To ignore the error condition. A no response is appropriate only if you intend to take other measures to fix the problem.
PARTIALLY TRUNCATED INODE I=inode-number (SALVAGE)

fsck has found inode inode-number whose size is shorter than the number of blocks allocated to it. This condition occurs only if the system crashes while truncating a file. When preening the file system, fsck completes the truncation to the specified size.
At the SALVAGE prompt, type:
y - To complete the truncation to the size specified in the inode.
n - To ignore this error condition.
UNKNOWN FILE TYPE I=inode-number (CLEAR)

The mode word of the inode inode-number shows that the inode is not a pipe, special character inode, special block inode, regular inode, symbolic link, FIFO file, or directory inode. If the -o p option is specified, the inode is cleared.
Type:
y - To deallocate the inode inode-number by zeroing its contents, which results in the UNALLOCATED error condition in phase 2 for each directory entry pointing to this inode.
n - To ignore this error condition.

Phase 1B: Rescan for More DUPS Messages

When a duplicate block is found in the file system, this informational message is displayed:
block-number DUP I=inode-number
Inode inode-number contains a block number block-number that is already claimed by the same or another inode. This error condition generates the BAD/DUP error message in phase 2. Inodes that have overlapping blocks may be determined by examining this error condition and the DUP error condition in phase 1.
When a duplicate block is found, the file system is rescanned to find the inode that previously claimed that block.

Phase 2: Check Path Names

This phase removes directory entries pointing to bad inodes found in phases 1 and 1B. It reports error conditions resulting from:
  • Incorrect root inode mode and status
  • Directory inode pointers out of range
  • Directory entries pointing to bad inodes
  • Directory integrity checks
When the file system is being preened (-o p option), all errors in this phase terminate fsck, except those related to directories not being a multiple of the block size, duplicate and bad blocks, inodes out of range, and extraneous hard links.
BAD INODE state-number TO DESCEND
  An fsck internal error has passed an impossible state state-number to the
  routine that descends the file system directory structure. fsck exits. If this
  error message is displayed, contact your local service provider or another
  qualified person.

BAD INODE NUMBER FOR '.' I=inode-number OWNER=UID MODE=file-mode
SIZE=file-size MTIME=modification-time DIR=filename (FIX)

A directory inode-number has been found whose inode number for "." does not equal inode-number.
At the FIX prompt, type:
y - To change the inode number for "." to be equal to inode-number.
n - To leave the inode number for "." unchanged.
BAD INODE NUMBER FOR '..' I=inode-number OWNER=UID MODE=file-
mode SIZE=file-size MTIME=modification-time DIR=filename (FIX)

A directory inode-number has been found whose inode number for ".." does not equal the parent of inode-number.
At the FIX prompt, type:
y - To change the inode number for ".." to be equal to the parent of inode-number. (Note that "..'' in the root inode points to itself.)
n - To leave the inode number for ".." unchanged.
BAD RETURN STATE state-number FROM DESCEND

An fsck internal error has returned an impossible state state-number from the routine that descends the file system directory structure. fsck exits. If this message is displayed, contact your local service provider or another qualified person.
BAD STATE state-number FOR ROOT INODE
  An internal error has assigned an impossible state state-number to the root
  inode. fsck exits. If this error message is displayed, contact your local
  service provider or another qualified person.

BAD STATE state-number FOR INODE=inode-number
  An internal error has assigned an impossible state state-number to inode
  inode-number. fsck exits. If this error message is displayed, contact your
  local service provider or another qualified person.

DIRECTORY TOO SHORT I=inode-number OWNER=UID MODE=file-mode
SIZE=file-size MTIME=modification-time DIR=filename (FIX)

A directory filename has been found whose size file-size is less than the minimum directory size. The owner UID, mode file-mode, size file-size, modify time modification-time, and directory name filename are displayed.
At the FIX prompt, type:
y - To increase the size of the directory to the minimum directory size.
n - To ignore this directory.
DIRECTORY filename: LENGTH file-size NOT MULTIPLE OF block-number
(ADJUST)

A directory filename has been found with size file-size that is not a multiple of the directory block size block-number.
At the ADJUST prompt, type:
y - To round up the length to the appropriate block size. When preening the file system (-o p option), fsck only displays a warning and adjusts the directory.
n - To ignore this condition.
DIRECTORY CORRUPTED I=inode-number OWNER=UID MODE=file-mode
SIZE=file-size MTIME=modification-time DIR=filename (SALVAGE)

A directory with an inconsistent internal state has been found.
At the SALVAGE prompt, type:
y - To throw away all entries up to the next directory boundary (usually a 512-byte boundary). This drastic action can throw away up to 42 entries. Take this action only after other recovery efforts have failed.
n - To skip to the next directory boundary and resume reading, but not modify the directory.
DUP/BAD I=inode-number OWNER=O MODE=M SIZE=file-size
MTIME=modification-time TYPE=filename (REMOVE)

Phase 1 or phase 1B found duplicate blocks or bad blocks associated with directory or file entry filename, inode inode-number. The owner UID, mode file-mode, size file-size, modify time modification-time, and directory or file name filename are displayed. If the -p (preen) option is specified, the duplicate/bad blocks are removed.
At the SALVAGE prompt, type:
y - To remove the directory or file entry filename.
n - To ignore this error condition.
DUPS/BAD IN ROOT INODE (REALLOCATE)

Phase 1 or phase 1B has found duplicate blocks or bad blocks in the root inode (usually inode number 2) of the file system.
At the REALLOCATE prompt, type:
y - To clear the existing contents of the root inode and reallocate it. The files and directories usually found in the root will be recovered in phase 3 and put into the lost+found directory. If the attempt to allocate the root fails, fsck will exit with: CANNOT ALLOCATE ROOT INODE.
n - To get the CONTINUE prompt. To respond to the CONTINUE prompt, type:
y - To ignore the DUPS/BAD error condition in the root inode and continue running the file system check. If the root inode is not correct, this may generate many other error messages.
n - To terminate the program.
EXTRA '.' ENTRY I=inode-number OWNER=UID MODE=file-mode SIZE=file-
size MTIME=modification-time DIR=filename (FIX)

A directory inode-number has been found that has more than one entry for ".".
At the FIX prompt, type:
y - To remove the extra entry for "."
n - To leave the directory unchanged.
EXTRA '..' ENTRY I=inode-number OWNER=UID MODE=file-mode SIZE=file-
size MTIME=modification-time DIR=filename (FIX)

A directory inode-number has been found that has more than one entry for ".." (the parent directory).
At the FIX prompt, type:
y - To remove the extra entry for '..' (the parent directory).
n - To leave the directory unchanged.
hard-link-number IS AN EXTRANEOUS HARD LINK TO A DIRECTORY
filename (REMOVE)

fsck has found an extraneous hard link hard-link-number to a directory filename. When preening (-o p option), fsck ignores the extraneous hard links.
At the SALVAGE prompt, type:
y - To delete the extraneous entry hard-link-number.
n - To ignore the error condition.
inode-number OUT OF RANGE I=inode-number NAME=filename (REMOVE)

A directory entry filename has an inode number inode-number that is greater than the end of the inode list. If the -p (preen) option is specified, the inode will be removed automatically.
At the SALVAGE prompt, type:
y - To delete the directory entry filename.
n - To ignore the error condition.
MISSING '.' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time DIR=filename (FIX)

A directory inode-number has been found whose first entry (the entry for ".") is unallocated.
At the FIX prompt, type:
y - To build an entry for "." with inode number equal to inode-number.
n - To leave the directory unchanged.
MISSING '.' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time DIR=filename
CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS filename

A directory inode-number has been found whose first entry is filename. fsck cannot resolve this problem. Mount the file system and move entry filename elsewhere. Unmount the file system and run fsck again.
MISSING '.' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time DIR=filename
CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'

A directory inode-number has been found whose first entry is not ".". fsck cannot resolve the problem. If this error message is displayed, contact your local service provider or another qualified person.
MISSING '..' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time DIR=filename (FIX)

A directory inode-number has been found whose second entry is unallocated.
At the FIX prompt, type:
y - To build an entry for ".." with inode number equal to the parent of inode-number. (Note that "..'' in the root inode points to itself.)
n - To leave the directory unchanged.
MISSING '..' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time DIR=filename
CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS filename

A directory inode-number has been found whose second entry is filename. fsck cannot resolve this problem. Mount the file system and move entry filename elsewhere. Then unmount the file system and run fsck again.
MISSING '..' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time DIR=filename
CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'

A directory inode-number has been found whose second entry is not ".." (the parent directory). fsck cannot resolve this problem. Mount the file system and move the second entry in the directory elsewhere. Then unmount the file system and run fsck again.
NAME TOO LONG filename

An excessively long path name has been found, which usually indicates loops in the file system name space. This error can occur if a privileged user has made circular links to directories. You must remove these links.
ROOT INODE UNALLOCATED (ALLOCATE)

The root inode (usually inode number 2) has no allocate mode bits.
At the ALLOCATE prompt, type:
y - To allocate inode 2 as the root inode. The files and directories usually found in the root will be recovered in phase 3 and put into the lost+found directory. If the attempt to allocate the root fails, fsck displays this message and exits:

  CANNOT ALLOCATE ROOT INODE  

n - To terminate the program.
ROOT INODE NOT DIRECTORY (REALLOCATE)

The root inode (usually inode number 2) of the file system is not a directory inode.
At the REALLOCATE prompt, type:
y - To clear the existing contents of the root inode and reallocate it. The files and directories usually found in the root will be recovered in phase 3 and put into the lost+found directory. If the attempt to allocate the root fails, fsck displays this message and exits:

  CANNOT ALLOCATE ROOT INODE  

n - To have fsck prompt with FIX.
At the FIX prompt, type:
y - To change the type of the root inode to directory. If the root inode's data blocks are not directory blocks, many error messages will be generated.
n - To terminate the program.
UNALLOCATED I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time type=filename (REMOVE)

A directory or file entry filename points to an unallocated inode inode-number. The owner UID, mode file-mode, size file-size, modify time modification-time, and file name filename are displayed.
At the SALVAGE prompt, type:
y - To delete the directory entry filename.
n - To ignore the error condition.
ZERO LENGTH DIRECTORY I=inode-number OWNER=UID MODE=file-mode
SIZE=file-size MTIME=modification-time DIR=filename (REMOVE)

A directory entry filename has a size file-size that is zero. The owner UID, mode file-mode, size file-size, modify time modification-time, and directory name filename are displayed.
At the SALVAGE prompt, type:
y - To remove the directory entry filename; this results in the BAD/DUP error message in phase 4.
n - To ignore the error condition.

Phase 3: Check Connectivity Messages

This phase checks the directories examined in phase 2 and reports error conditions resulting from:
  • Unreferenced directories
  • Missing or full lost+found directories
BAD INODE state-number TO DESCEND

An internal error has caused an impossible state state-number to be passed to the routine that descends the file system directory structure. fsck exits. If this occurs, contact your local service provider or another qualified person.
DIR I=inode-number1 CONNECTED. PARENT WAS I=inode-number2
  This is an advisory message indicating a directory inode inode-number1 was
  successfully connected to the lost+found directory. The parent inode
  inode-number2 of the directory inode inode-number1 is replaced by the inode
  number of the lost+found directory.

DIRECTORY filename LENGTH file-size NOT MULTIPLE OF block-number
(ADJUST)

A directory filename has been found with size file-size that is not a multiple of the directory block size B. (This condition can recur in phase 3 if it is not adjusted in phase 2.)
At the ADJUST prompt, type:
y - To round up the length to the appropriate block size. When preening, fsck displays a warning and adjusts the directory.
n - To ignore this error condition.
lost+found IS NOT A DIRECTORY (REALLOCATE)

The entry for lost+found is not a directory.
At the REALLOCATE prompt, type:
y - To allocate a directory inode and change the lost+found directory to reference it. The previous inode reference by the lost+found directory is not cleared and it will either be reclaimed as an unreferenced inode or have its link count adjusted later in this phase. Inability to create a lost+found directory displays the message:

  SORRY. CANNOT CREATE lost+found DIRECTORY  

and aborts the attempt to link up the lost inode, which generates the UNREF error message in phase 4.
n - To abort the attempt to link up the lost inode, which generates the UNREF error message in phase 4.
NO lost+found DIRECTORY (CREATE)

There is no lost+found directory in the root directory of the file system. When preening, fsck tries to create a lost+found directory.
At the CREATE prompt, type:
y - To create a lost+found directory in the root of the file system. This may lead to the message NO SPACE LEFT IN / (EXPAND). See the explanation of this message below. If the lost+found directory cannot be created, fsck displays the message:

  SORRY. CANNOT CREATE lost+found DIRECTORY  

and aborts the attempt to link up the lost inode. This in turn generates the UNREF error message later in phase 4.
n - To abort the attempt to link up the lost inode. This generates the UNREF error message later in phase 4.
NO SPACE LEFT IN /lost+found (EXPAND)

Another entry cannot be added to the lost+found directory in the root directory of the file system because no space is available. When preening, fsck expands the lost+found directory.
At the EXPAND prompt, type:
y - To expand the lost+found directory to make room for the new entry. If the attempted expansion fails, fsck displays:

  SORRY. NO SPACE IN lost+found DIRECTORY  

and aborts the request to link a file to the lost+found directory. This error generates the UNREF error message later in phase 4. Delete any unnecessary entries in the lost+found directory. This error terminates fsck when preening is in effect.
n - To abort the attempt to link up the lost inode. This generates the UNREF error message in phase 4.
UNREF DIR I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time (RECONNECT)

The directory inode inode-number was not connected to a directory entry when the file system was traversed. The owner UID, mode file-mode, size file-size, and modify time modification-time of directory inode inode-number are displayed. When preening, fsck reconnects the non-empty directory inode if the directory size is non-zero. Otherwise, fsck clears the directory inode.
At the RECONNECT prompt, type:
y - To reconnect the directory inode inode-number into the lost+found directory. If the directory is successfully reconnected, a CONNECTED message is displayed. Otherwise, one of the lost+found error messages is displayed.
n - To ignore this error condition. This error causes the UNREF error condition in phase 4.

Phase 4: Check Reference Counts Messages

This phase checks the link count information obtained in phases 2 and 3. It reports error conditions resulting from:
  • Unreferenced files
  • A missing or full lost+found directory
  • Incorrect link counts for files, directories, symbolic links, or special files
  • Unreferenced files, symbolic links, and directories
  • Bad or duplicate blocks in files and directories
  • Incorrect total free-inode counts
All errors in this phase (except running out of space in the lost+found directory) are correctable when the file system is being preened.
BAD/DUP type I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time (CLEAR)

Phase 1 or phase 1B found duplicate blocks or bad blocks associated with file or directory inode inode-number. The owner UID, mode file-mode, size file-size, and modify time modification-time of inode inode-number are displayed. This error does not display in this phase when the file system is being preened because fsck would have terminated earlier.
At the CLEAR prompt, type:
y - To deallocate inode inode-number by zeroing its contents.
n - To ignore this error condition.
(CLEAR)

The inode mentioned in the UNREF error message immediately preceding cannot be reconnected. This message does not display if the file system is being preened because lack of space to reconnect files terminates fsck.
At the CLEAR prompt, type:
y - To deallocate the inode by zeroing out its contents.
n - To ignore the preceding error condition.
LINK COUNT type I=inode-number OWNER=UID MODE=file-mode SIZE=file-
size MTIME=modification-time COUNT link-count SHOULD BE corrected-link-
count (ADJUST)

The link count for directory or file inode inode-number is link-count but should be corrected-link-count. The owner UID, mode file-mode, size file-size, and modify time modification-time of inode inode-number are displayed. If the -o p option is specified, the link count is adjusted unless the number of references is increasing. This condition does not occur unless there is a hardware failure. When the number of references is increasing during preening, fsck displays this message and exits:

  LINK COUNT INCREASING  

At the ADJUST prompt, type:
y - To replace the link count of directory or file inode inode-number with corrected-link-count.
n - To ignore this error condition.
lost+found IS NOT A DIRECTORY (REALLOCATE)

The entry for lost+found is not a directory.
At the REALLOCATE prompt, type:
y - To allocate a directory inode and change the lost+found directory to reference it. The previous inode reference by the lost+found directory is not cleared. It will either be reclaimed as an unreferenced inode or have its link count adjusted later in this phase. Inability to create a lost+found directory displays this message:

  SORRY. CANNOT CREATE lost+found DIRECTORY  

and aborts the attempt to link up the lost inode. This error generates the UNREF error message later in phase 4.
n - To abort the attempt to link up the lost inode. This error generates the UNREF error message later in phase 4.
NO lost+found DIRECTORY (CREATE)

There is no lost+found directory in the root directory of the file system. When preening, fsck tries to create a lost+found directory.
At the CREATE prompt, type:
y - To create a lost+found directory in the root of the file system. If the lost+found directory cannot be created, fsck displays the message:

  SORRY. CANNOT CREATE lost+found DIRECTORY  

and aborts the attempt to link up the lost inode. This error in turn generates the UNREF error message later in phase 4.
n - To abort the attempt to link up the lost inode. This generates the UNREF error message later in phase 4.
NO SPACE LEFT IN / lost+found (EXPAND)

There is no space to add another entry to the lost+found directory in the root directory of the file system. When preening, fsck expands the lost+found directory.
At the EXPAND prompt, type:
y - To expand the lost+found directory to make room for the new entry. If the attempted expansion fails, fsck displays the message:

  SORRY. NO SPACE IN lost+found DIRECTORY  

and aborts the request to link a file to the lost+found directory. This error generates the UNREF error message later in phase 4. Delete any unnecessary entries in the lost+found directory. This error terminates fsck when preening (-o p option) is in effect.
n - To abort the attempt to link up the lost inode. This results in the UNREF error message later in phase 4.
UNREF FILE I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time (RECONNECT)

File inode inode-number, was not connected to a directory entry when the file system was traversed. The owner UID, mode file-mode, size file-size, and modify time modification-time of inode inode-number are displayed. When fsck is preening, the file is cleared if either its size or its link count is zero; otherwise, it is reconnected.
At the RECONNECT prompt, type:
y - To reconnect inode inode-number to the file system in the lost+found directory. This error may generate the lost+found error message in phase 4 if there are problems connecting inode inode-number to the lost+found directory.
n - To ignore this error condition. This error always invokes the CLEAR error condition in phase 4.
UNREF type I=inode-number OWNER=UID MODE=file-mode SIZE=file-size
MTIME=modification-time (CLEAR)

Inode inode-number (whose type is directory or file) was not connected to a directory entry when the file system was traversed. The owner UID, mode file-mode, size file-size, and modify time modification-time of inode inode-number are displayed. When fsck is preening, the file is cleared if either its size or its link count is zero; otherwise, it is reconnected.
At the CLEAR prompt, type:
y - To deallocate inode inode-number by zeroing its contents.
n - To ignore this error condition.
ZERO LENGTH DIRECTORY I=inode-number OWNER=UID MODE=file-mode
SIZE=file-size MTIME=modification-time (CLEAR)

A directory entry filename has a size file-size that is zero. The owner UID, mode file-mode, size file-size, modify time modification-time, and directory name filename are displayed.
At the CLEAR prompt, type:
y - To deallocate the directory inode inode-number by zeroing out its contents.
n - To ignore the error condition.

Phase 5: Check Cylinder Groups Messages

This phase checks the free-block and used-inode maps. It reports error conditions resulting from:
  • Allocated inodes missing from used-inode maps
  • Free blocks missing from free-block maps
  • Free inodes in the used-inode maps
  • Incorrect total free-block count
  • Incorrect total used inode count
BLK(S) MISSING IN BIT MAPS (SALVAGE)

A cylinder group block map is missing some free blocks. During preening, fsck reconstructs the maps.
At the SALVAGE prompt, type:
y - To reconstruct the free-block map.
n - To ignore this error condition.
CG character-for-command-option: BAD MAGIC NUMBER

  The magic number of cylinder group character-for-command-option is wrong.
  This error usually indicates that the cylinder group maps have been
  destroyed. When running interactively, the cylinder group is marked as
  needing reconstruction. fsck terminates if the file system is being preened.

FREE BLK COUNT(S) WRONG IN SUPERBLK (SALVAGE)

The actual count of free blocks does not match the count of free blocks in the superblock of the file system. If the -o p option was specified, the free-block count in the superblock is fixed automatically.
At the SALVAGE prompt, type:
y - To reconstruct the superblock free-block information.
n - To ignore this error condition.
SUMMARY INFORMATION BAD (SALVAGE)

The summary information is incorrect. When preening, fsck recomputes the summary information.
At the SALVAGE prompt, type:
y - To reconstruct the summary information.
n - To ignore this error condition.

Cleanup Phase Messages

Once a file system has been checked, a few cleanup functions are performed. The cleanup phase displays the following status messages.
number-of files, number-of-files used, number-of-files free (number-of
frags, number-of blocks, percent fragmentation)

This message indicates that the file system checked contains number-of files using number-of fragment-sized blocks, and that there are number-of fragment-sized blocks free in the file system. The numbers in parentheses break the free count down into number-of free fragments, number-of free full-sized blocks, and the percent fragmentation.
***** FILE SYSTEM WAS MODIFIED *****

  This message indicates that the file system was modified by fsck. If this file
  system is mounted or is the current root file system, reboot. If the file system
  is mounted, you may need to unmount it and run fsck again; otherwise,
  the work done by fsck may be undone by the in-core copies of tables.

filename FILE SYSTEM STATE SET TO OKAY

This message indicates that file system filename was marked as stable. fsck with the -m option uses this information to determine that the file system does not need checking.
filename FILE SYSTEM STATE NOT SET TO OKAY

This message indicates that file system filename was not marked as stable. fsck with the -m option uses this information to determine that the file system needs checking.

Modifying Automatic Boot Checking

During boot up, a preliminary check on each file system to be mounted from a hard disk is run using the boot script /sbin/rcS, which checks the /, /usr, /usr/kvm file systems. The other rc shell scripts then use the fsck command to check each additional file system sequentially. They do not check file systems in parallel. File systems are checked sequentially during booting even if the fsck pass numbers are greater than one.

The /etc/vfstab File

When the commands for checking and mounting file systems are run without specifying a file system directly, the commands step through the file system table (/etc/vfstab) using the information specified in the various fields. The fsck pass field specifies information for file system checking. The automount field specifies information for mounting the file system at boot time.
When you create new file systems, add entries to /etc/vfstab indicating whether they are to be checked and mounted at boot time. See Chapter 3, "Mounting and Unmounting File Systems," for more information about adding entries to the /etc/vfstab file.
Information in the /etc/vfstab file is specific for the slices and file systems for each system. Here is an example of an /etc/vfstab file:

  venus% more /etc/vfstab  
  #device         device          mount           FS                fsck    auto-   mount  
  #to mount       to fsck         point           type    pass    mount?  options#  
  #/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr          ufs     1       yes     -  
  /proc           -               /proc           proc    -       no      -  
  fd              -               /dev/fd         fd      -       no      -  
  swap            -               /tmp            tmpfs   -       yes     -  
  
  /dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 /          ufs     1       no      -  
  /dev/dsk/c0t0d0s1 -                  -          swap    -       no      -  
  /dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /usr       ufs     2       no      -  
  /dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /opt       ufs     3       yes     -  
  swsvr4-50:/export/svr4/man -    /usr/man        nfs     no      yes     -  
  venus%  

If you put a hyphen (-) in the fsck pass (the pass number) field, the generic fsck command will not check the file system regardless of the state of the file system. Use a hyphen in the fsck pass field for read-only file systems, remote file systems, or pseudo file systems, such as /proc, to which checking does not apply.
If you put a number (0 or greater) in the fsck pass field, the file system-specific fsck command is called. For UFS file systems, when the value is 0, the file system is not checked.
fsck automatically checks UFS file systems in parallel when the fsck pass value is greater than 1 and the preen option (fsck -o p) is used. The values can be any number greater than 1.
In preen mode, fsck allows only one active file system check per disk, starting a new check only after the previous one is completed. fsck automatically uses the major and minor numbers of the devices on which the file systems reside to determine how to check file systems on different disks at the same time.
When the fsck pass number is 1, file systems are checked sequentially, in the order they appear in the /etc/vfstab file. Usually, the root file system has the fsck pass set to 1.

Note - fsck does not use the fsck pass number to determine the sequence of file system checking.

· How to Modify Automatic Checking Done During Booting
  1. Become superuser.

  2. Edit /etc/vfstab entries in the fsck pass field, and save the changes. The next time the system is booted, the new values are used.

Interactively Checking and Repairing a UFS File System

You may need to interactively check file systems:
  • When they cannot be mounted
  • When they develop problems while in use
When an in-use file system develops inconsistencies, error messages may be displayed in the console window or the system may crash.
Before using fsck, you may want to refer to "Syntax and Options for the fsck Command" on page 260 and "Error Messages" on page 226 for more information.
· How to See if a File System Needs Checking
  1. Become superuser.

  2. Type fsck -m /dev/rdsk/cntndnsn and press Return. The state flag in the superblock of the file system you specify is checked to see whether the file system is clean or requires checking.

If you omit the device argument, all the UFS file systems listed in /etc/vfstab with a fsck pass value greater than 0 are checked.
In this example, the first file system needs checking; the second file system does not:

  # fsck -m /dev/rdsk/c0t0d0s6  
  ** /dev/rdsk/c0t0d0s6  
  ufs fsck: sanity check: /dev/rdsk/c0t0d0s6 needs checking  
  # fsck -m /dev/rdsk/c0t0d0s7  
  ** /dev/rdsk/c0t0d0s7  
  ufs fsck: sanity check: /dev/rdsk/c0t0d0s7 okay  
  #  

· How to Check File Systems Interactively
  1. Become superuser.

  2. Unmount the file system.

  3. Type fsck and press Return.

    All file systems in the /etc/vfstab file with entries in the fsck pass field greater than zero are checked. You can also specify the mount point directory or /dev/rdsk/cntndnsn as arguments to fsck. Any inconsistency messages are displayed. See "Error Messages" on page 226 for information about how to respond to the error message prompts to interactively check one or more UFS file systems:

In this example, /dev/rdsk/c0t0d0s6 is checked and the incorrect block count is corrected:

  # fsck /dev/rdsk/c0t0d0s6  
  checkfilesys: /dev/rdsk/c0t0d0s6  
  ** Phase 1 - Check Block and Sizes  
  INCORRECT BLOCK COUNT I=2529 (6 should be 2)  
  CORRECT? y  
  
  ** Phase 2 - Check Pathnames  
  ** Phase 3 - Check Connectivity  
  ** Phase 4 - Check Reference Counts  
  ** Phase 5 - Cylinder Groups  
  929 files, 8928 used, 2851 free (75 frags, 347 blocks, 0.6%  
  fragmentation)  


  /dev/rdsk/c0t0d0s6 FILE SYSTEM STATE SET TO OKAY  
  
  ***** FILE SYSTEM WAS MODIFIED *****  

  1. If you corrected any errors, type fsck and press Return. fsck may not be able to fix all errors in one execution. If you see the message FILE SYSTEM STATE NOT SET TO OKAY, run the command again. If that does not work, see "How to Fix a UFS File System fsck Cannot Repair" on page 260.

  2. Rename and move any files put in lost+found. Individual files put in the lost+found directory by fsck are renamed with their inode numbers. If possible, rename the files and move them where they belong. You may be able to use the grep command to match phrases with individual files and the file command to identify file types. When whole directories are dumped into lost+found, it is easier to figure out where they belong and move them back.

Preening UFS File Systems

The preen option to fsck (fsck -o p) checks UFS file systems and automatically fixes only the simple problems that normally result from an unexpected system halt. It exits immediately if it encounters a problem that requires operator intervention. The preen option also permits parallel checking of file systems.
You can run fsck with the -o p option to preen the file systems after an unclean halt. In this mode, fsck does not look at the clean flag and does a full check. While preening a file system, fsck fixes only corruptions that are expected to result from an unclean halt. These actions are a subset of the actions that fsck takes when it runs interactively.
· How to Preen UFS File Systems
  1. Become superuser.

  2. Unmount the UFS file systems.

  3. Type fsck -o p and press Return.

    All file systems in the /etc/vfstab file with entries greater than zero in the fsck pass field are checked. Files with an fsck pass number greater than 1 are checked in parallel according to their major and minor numbers. Normal inconsistencies that occur when the CPU halts without warning are repaired. If fsck encounters a more serious error, it exits immediately.

You can preen individual file systems by using mount-point or /dev/rdsk/cntndnsn as arguments to fsck. For example, to preen the /usr file system, type fsck -o p /usr and press Return.

Restoring a Bad Superblock

When the superblock of a file system becomes damaged, you must restore it. fsck tells you when a superblock is bad. Fortunately, redundant copies of the superblock are stored within a file system. You can use fsck -o b to replace the superblock with one of the copies.
· How to Restore a Bad Superblock
  1. Become superuser.

  2. Change to a directory outside the damaged file system.

  3. Type umount mount-point and press Return.


CAUTION Caution - Be sure to use the -N option with newfs in the next step. If you omit the -N option, you will create a new, empty file system.

  1. Type newfs -N /dev/rdsk/cntndnsn and press Return. The output of this command displays the block numbers that were used for the superblock copies when newfs created the file system.

  1. Type fsck -F ufs -o b=block-number /dev/rdsk/cntndnsn and press Return.

    fsck uses the alternative superblock you specify to restore the primary superblock. You can always try 32 as an alternative block, or use any of the alternative blocks show by newfs -N.

In this example, superblock copy 5264 is restored for the /files7 file system:

  # cd /  
  # umount /files7  
  # newfs -N /dev/rdsk/c0t3d0s7  
  /dev/rdsk/c0t3d0s7: 163944 sectors in 506 cylinders of 9 tracks,  
  36 sectors  
   83.9MB in 32 cyl groups (16 c/g, 2.65MB/g, 1216 i/g)  
  super-block backups (for fsck -b #) at:  
   32, 5264, 10496, 15728, 20960, 26192, 31424, 36656, 41888,  
   47120, 52352, 57584, 62816, 68048, 73280, 78512, 82976, 88208,  
   93440, 98672, 103904, 109136, 114368, 119600, 124832, 130064,  
  135296,  
   140528, 145760, 150992, 156224, 161456,  
  # fsck -F ufs -o b=5264 /dev/rdsk/c0t3d0s7  
  Alternate superblock location: 5264.  
  ** /dev/rdsk/c0t3d0s7  
  ** Last Mounted on  
  ** Phase 1 - Check Blocks and Sizes  
  ** Phase 2 - Check Pathnames  
  ** Phase 3 - Check Connectivity  
  ** Phase 4 - Check Reference Counts  
  ** Phase 5 - Check Cyl groups  
  36 files, 867 used, 75712 free (16 frags, 9462 blocks, 0.0%  
  fragmentation)  
  /dev/rdsk/c0t3d0s7 FILE SYSTEM STATE SET TO OKAY  
  
  ***** FILE SYSTEM WAS MODIFIED *****  
  #  

If the superblock in the root file system becomes damaged and you cannot boot the system, reinstall /kernel/unix and rebuild the root file system with newfs. Because a superblock is created by the newfs command, you do not need to restore it. See "Restoring Complete File Systems" on page 142 for information on how to restore / and /usr file systems.

How to Fix a UFS File System fsck Cannot Repair

Sometimes you need to run fsck a few times to fix a file system, because problems corrected on one pass may uncover other problems not found in earlier passes. fsck does not keep running until it comes up clean, so you must rerun it manually.
Pay attention to the information displayed by fsck. It may help you fix the problem. For example, the messages may point to a bad directory. If you delete the directory, you may find that fsck runs cleanly.
If fsck still cannot repair the file system, you can try to use the fsdb, ff, clri, and ncheck commands to figure out and fix what is wrong. See the fsdb(1M), ff(1M), clri(1M), and ncheck(1M) manual pages for information about how to use these commands. You may, ultimately, need to re-create the file system and restore its contents from backup media. See Chapter 8, "Restoring Files and File Systems," for information about restoring complete file systems.
If you cannot fully repair a file system but you can mount it read-only, try using cp, tar, or cpio to retrieve all or part of the data from the file system.
If hardware disk errors are causing the problem, you may need to reformat and divide the disk into slices again before re-creating and restoring file systems. Hardware errors usually display the same error again and again across different commands. The format(1M) command tries to work around bad blocks on the disk. If the disk is too severely damaged, however, the problems may persist, even after reformatting. See the format(1M) manual page for information about using the format command. See Peripherals Administration for information about installing a new disk.

Syntax and Options for the fsck Command

The fsck command checks and repairs inconsistencies in file systems. It has four options:
  • Checks only whether a file system can be mounted (fsck -m)
  • Interactively asks for confirmation before making repairs (fsck)
  • Assumes yes or no response for all repairs (fsck -y)
  • Noninteractively preens the file system, fixing all expected (innocuous) inconsistencies, but exiting when a serious problem is encountered (fsck -o p)

Generic fsck Command Syntax, Options, and Arguments

The fsck command has two components: a generic component and a component specific to each type of file system. The generic commands apply to most types of file systems, while the specific commands apply to only one type of file system. You should always use the generic command, which calls the file system-specific command, as needed.
Usually, you must be superuser to run fsck. You can run the fsck command without being superuser; but to make repairs, the file system should be unmounted and you must have read permission for the raw device file for the slice (a potential security hole).
The generic fsck command goes through /etc/vfstab to see what file systems to check. It runs the appropriate file system-specific fsck command on each file system listed, except those excluded by an fsck pass number of -or 0 (UFS only).
The generic fsck command has the following syntax:

  /usr/sbin/fsck [-F type] [-V] [-m] [special]  
  
  /usr/sbin/fsck [-F type] [-V] -[y|Y]|[n|N] [-o specific-options][special]  

The generic fsck command has the following options and arguments:
-F

Specifies the file system type (type). If type is not specified on the command line, it is obtained from /etc/vfstab by matching an entry in that file with the special device name specified. If no entry is found, the default local file system type specified in /etc/default/fs is used.
-V
  Echoes the completed command line (verbose). The echoed line includes
  additional information derived from /etc/vfstab. This option can be used
  to verify and validate the command line. It does not execute the command.

-m

Performs a preliminary ("sanity") check only. It returns a code indicating the state of the file system: 0 for "clean" and 32 for "dirty." This option is used by the startup script /etc/bcheckrc to determine whether a file system needs to be checked.
-y or -Y or -n or -N Runs the command automatically answering yes or no to all prompts.
specific-options
A comma separated list of options that follow the -o option. This list describes the options that are passed to the UFS-specific fsck command for interpretation.
p

Preens. Runs the command automatically in silent mode, correcting what it can, but exiting when it encounters a problem that requires intervention. This option also enables parallel checking of UFS file systems.
b=blocknumber
Uses the alternative (redundant) superblock, located at the specified location. This option can be used to repair a bad superblock. You can display a list of alternative superblocks using the newfs -N command.
c

Converts an old format file system with statically allocated tables to new format dynamically allocated tables. Static allocation imposes a hard maximum on table size, while dynamic allocation means space for tables can be added as needed after the initial allocation. If the file system is in the new format, convert it to the old format, unless the table allocation exceeds the fixed maximum allowed in the old format. fsck lists the direction of the conversion. In interactive mode, fsck prompts for confirmation before doing the conversion. When you use the -o p option, the conversion is attempted without asking for confirmation. This option is useful when you want to covert a number of file systems at
once. You can determine whether a file system is in the old or new format by running the fstyp(1M) command, and looking at the first line displayed.
w

Checks only file systems that permit write access.
special
Specifies the mount point or raw device name of one or more file systems. An entry for the mount point must exist in /etc/vfstab. If you omit the special argument, entries in /etc/vfstab with a specified fsck device and a fsck pass number greater than zero are checked. If preening (-o p) is in effect and more than one entry has an fsck pass number greater than 1, file systems on different disks are checked in parallel.