Fixing a damaged file system

File systems can get corrupted when the i-node or superblock information for the directory structure of the file system gets corrupted.

This corruption can be caused by a hardware-related ailment or by a program that gets corrupted that accesses the i-node or superblock information directly. (Programs written in assembler and C can bypass the operating system and write directly to the hardware.) One symptom of a corrupt file system is that the system cannot locate, read, or write data located in the particular file system.

To fix a damaged file system, you must diagnose the problem and then repair it. The fsck command performs low-level diagnosis and repairs.

The following is the procedure for fixing a damaged file system:

  1. With root authority, unmount the damaged file system using one of the following SMIT fast paths: smit unmountfs (for a file system on a fixed disk drive) or smit unmntdsk (for a file system on a removeable disk).
  2. Assess file system damage by running the fsck command. In the following example, the fsck command checks the unmounted file system located on the /dev/myfilelv device:
    fsck /dev/myfilelv
    The fsck command checks and interactively repairs inconsistent file systems. 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.
  3. If the file system cannot be repaired, restore it from backup.
    Attention: Restoring a file system from a backup destroys and replaces any file system previously stored on the disk.
    To restore the file system from backup, use the SMIT fastpath smit restfilesys or the series of commands shown in the following example:
    mkfs /dev/myfilelv
    mount /dev/myfilelv /myfilesys
    cd /myfilesys
    restore -r

    In this example, the mkfs command makes a new file system on the device named /dev/myfilelv and initializes the volume label, file system label, and startup block. The mount command establishes /dev/myfilelv as the mountpoint for myfilesys and the restore command extracts the file system from the backup.

    If your backup was made using incremental file system backups, you must restore the backups in increasing backup-level order (for example, 0, 1, 2). When using smit restfilesys to restore an entire file system, enter the target directory, restore device (other than /dev/rfd0), and number of blocks to read in a single input operation.