Checking the integrity of a file system (fsck command)

Use the fsck command to check and interactively repair inconsistent file systems.

It is important to run this command on every file system as part of system initialization. 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.

Attention: Always run the fsck command on file systems after a system malfunction. Corrective actions can result in some loss of data. The default action for each consistency correction is to wait for the operator to type yes or no. If you do not have write permission for an affected file, the fsck command will default to a no response.
See the following examples:
  • To check all the default file systems, type the following:
    This form of the fsck command asks you for permission before making any changes to a file system.
  • To fix minor problems automatically with the default file systems, type the following:
    fsck -p
  • To check the /dev/hd1 file system , type the following:
    fsck /dev/hd1
    This checks the unmounted file system located on the /dev/hd1 device.
Note: The fsck command does not make corrections to a mounted file system.