Checks file system consistency and interactively repairs the file system.
fsck [ -n ] [ -p ] [ -y ] [ -dBlockNumber ] [ -f ] [ -ii-NodeNumber ] [ -o Options ] [ -tFile ] [ -V VfsName ] [ FileSystem1 - FileSystem2 ... ]
The fsck command checks and interactively repairs inconsistent file systems. You should run this command before mounting any file system. You must be able to read the device file on which the file system resides (for example, the /dev/hd0 device). Normally, the file system is consistent, and the fsck command merely reports on the number of files, used blocks, and free blocks in the file system. If the file system is inconsistent, the fsck command displays information about the inconsistencies found and prompts you for permission to repair them.
The fsck command is conservative in its repair efforts and tries to avoid actions that might result in the loss of valid data. In certain cases, however, the fsck command recommends the destruction of a damaged file. If you do not allow the fsck command to perform the necessary repairs, an inconsistent file system may result. Mounting an inconsistent file system may result in a system crash.
If a JFS2 file system has snapshots, the fsck command will attempt to preserve them. If this action fails, the snapshots cannot be guaranteed to contain all of the before-images from the snapped file system. The fsck command will delete the snapshots and the snapshot logical volumes. Internal snapshots are deleted if the fsck command modifies the file system.
If you do not specify a file system with the FileSystem parameter, the fsck command checks all file systems listed in the /etc/filesystems file for which the check attribute is set to True. You can enable this type of checking by adding a line in the stanza, as follows:
check=true
check=Number
The Number parameter tells the fsck command which group contains a particular file system. File systems that use a common log device should be placed in the same group. File systems are checked, one at a time, in group order, and then in the order that they are listed in the /etc/filesystems file. All check=true file systems are in group 1. The fsck command attempts to check the root file system before any other file system regardless of the order specified on the command line or in the /etc/filesystems file.
The fsck command checks for the following inconsistencies:
Orphaned files and directories (those that cannot be reached) are, if you allow it, reconnected by placing them in the lost+found subdirectory in the root directory of the file system. The name assigned is the i-node number. If you do not allow the fsck command to reattach an orphaned file, it requests permission to destroy the file.
In addition to its messages, the fsck command records the outcome of its checks and repairs through its exit value. This exit value can be any sum of the following conditions:
Item | Description |
---|---|
0 | All checked file systems are now okay. |
2 | The fsck command was interrupted before it could complete checks or repairs. |
4 | The fsck command changed the file system; the user must restart the system immediately. |
8 | The file system contains unrepaired damage. |
The fsck command requires exclusive access to the underlying logical volume device of the file system. If fsck fails because the underlying device is unavailable, then fsck should be retried after the device is free to be opened.
When the system is booted from a disk, the boot process explicitly runs the fsck command, specified with the -f and -p flags on the /, /usr, /var, and /tmp file systems. If the fsck command is unsuccessful on any of these file systems, the system does not boot. Booting from removable media and performing maintenance work will then be required before such a system will boot.
You can use the File Systems application in Web-based System Manager (wsm) to change file system characteristics. You could also use the System Management Interface Tool (SMIT) smit fsck fast path to run this command.
Item | Description |
---|---|
-dBlockNumber | Searches for references to a specified disk block. Whenever the fsck command encounters a file that contains a specified block, it displays the i-node number and all path names that refer to it. For JFS2 filesystems, the i-node numbers referencing the specified block will be displayed but not their path names." |
-f | Performs a fast check. Under normal circumstances, the only
file systems likely to be affected by halting the system without shutting
down properly are those that are mounted when the system stops. The -f flag prompts the fsck command not to check file systems
that were unmounted successfully. The fsck command determines
this by inspecting the s_fmod flag in the file system superblock. This flag is set whenever a file system is mounted and cleared when it is unmounted successfully. If a file system is unmounted successfully, it is unlikely to have any problems. Because most file systems are unmounted successfully, not checking those file systems can reduce the checking time. |
-ii-NodeNumber | Searches for references to a specified i-node. Whenever the fsck command encounters a directory reference to a specified i-node, it displays the full path name of the reference. |
-n | Assumes a no response to all questions asked by the fsck command; does not open the specified file system for writing. |
-o Options | Passes comma-separated options to the fsck command.
The following options are currently supported for JFS (these options
are obsolete for newer file systems and can be ignored):
|
-p | Does not display messages about minor problems but fixes them automatically. This flag does not grant the wholesale license that the -y flag does and is useful for performing automatic checks when the system is started normally. You should use this flag as part of the system startup procedures, whenever the system is being run automatically. If the primary superblock is corrupt, the secondary superblock is verified and copied to the primary superblock. |
-tFile | Specifies a File parameter as a scratch file on a file system other than the one being checked, if the fsck command cannot obtain enough memory to keep its tables. If you do not specify the -t flag and the fsck command needs a scratch file, it prompts you for the name of the scratch file. However, if you have specified the -p flag, the fsck command is unsuccessful. If the scratch file is not a special file, it is removed when the fsck command ends. |
-V VfsName | Uses the description of the virtual file system specified by the VFSName variable for the file system instead of using the /etc/filesystems file to determine the description. If the -V VfsName flag is not specified on the command line, the /etc/filesystems file is checked and the vfs=Attribute of the matching stanza is assumed to be the correct file system type. |
-y | Assumes a yes response to all questions asked by the fsck command. This flag lets the fsck command take any action it considers necessary. Use this flag only on severely damaged file systems. |
fsck
This command checks all the file systems marked check=true in the /etc/filesystems file. This form of the fsck command asks you for permission before making any changes
to a file system.fsck -p
fsck /dev/hd1
This command checks the unmounted file system located on the /dev/hd1 device.Item | Description |
---|---|
/usr/sbin/fsck | Contains the fsck command. |
/etc/filesystems | Lists the known file systems and defines their characteristics. |
/etc/vfs | Contains descriptions of virtual file system types. |
/etc/rc | Contains commands (including the fsck command) that are run when the system is started. |