[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 2

fsck Command


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 ... ]


Attention: Always run the fsck command on file systems after a system malfunction. Corrective actions may result in some loss of data. The default action for each consistency correction is to wait for the operator to enter yes or no. If you do not have write permission for an affected file system, the fsck command defaults to a no response in spite of your actual response.

  1. The fsck command does not make corrections to a mounted file system.
  2. The fsck command can be run on a mounted file system for reasons other than repairs. However, inaccurate error messages may be returned when the file system is mounted.

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 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:


The fsck command can perform simultaneous checks on multiple file systems. This procedure can reduce the time required to check a large number of file systems. Use a - (minus sign) to separate the file systems when specified as part of the argument.

You can also perform simultaneous checks on multiple file systems by grouping the file systems in the /etc/filesystems file. To do so, change the check attribute in the /etc/filesystems file as follows:


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. Each group is checked in a separate parallel process. File systems are checked, one at a time, 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:

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.

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.

If the fsck command successfully runs on /, /usr, /var, and /tmp, normal system initialization continues. During normal system initialization, the fsck command specified with the -f and -p flags runs from the /etc/rc file. This command sequence checks all file systems in which the check attribute is set to True (check=true). If the fsck command executed from the /etc/rc file is unable to guarantee the consistency of any file system, system initialization continues. However, the mount of any inconsistent file systems may fail. A mount failure may cause incomplete system initialization.

Note: By default, the /, /usr, /var, and /tmp file systems have the check attribute set to False (check=false) in their /etc/filesystem stanzas. The attribute is set to False for the following reasons:
  1. The boot process explicitly runs the fsck command on the /, /usr, /var, and /tmp file systems.
  2. The /, /usr, /var, and /tmp file systems are mounted when the /etc/rc file is executed. The fsck command will not modify a mounted file system. Furthermore, the fsck command run on a mounted file system produces unreliable results.

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.


-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. This flag is not supported for JFS2 filesystems.
-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. This flag is not supported for JFS2 filesystems.
-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. These options are assumed to be file system implementation-specific, except that the following are currently supported for all file systems:

Causes the fsck command to exit with success, returning a value of 0, if the file system in question is mountable (clean). If the file system is not mountable, the fsck command exits returning with a value of 8.

Causes the fsck command to exit with success (0) if the file system in question is of the same type as either specified in the /etc/filesystems file or by the -V flag on the command line. Otherwise, 8 is returned. For example, fsck -o mytype -V jfs / exits with a value of 0 if / (the root file system) is a journaled file system.
-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. Also allows parallel checks by group. 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.


  1. To check all the default file systems, enter:


    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.

  2. To fix minor problems with the default file systems automatically, enter:

    fsck -p
  3. To check a specific file system, enter:

    fsck /dev/hd1

    This command checks the unmounted file system located on the /dev/hd1 device.


/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.

Related Information

The dfsck command, fsdb command, istat command, mkfs command, ncheck command, rc command, shutdown command.

The filesystems file, filsys.h file.

The File Systems Overview for System Management in AIX 5L Version 5.1 System Management Concepts: Operating System and Devices explains file system types, management, structure, and maintenance.

For information on installing the Web-based System Manager, see Chapter 2: Installation and System Requirements in AIX 5L Version 5.1 Web-based System Manager Administration Guide.

The System Management Interface Tool (SMIT): Overview in AIX 5L Version 5.1 System Management Concepts: Operating System and Devices explains the SMIT structure, main menus, and tasks.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]