Thursday 14 March 2013

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 fsckcommand merely reports on the number of files, used blocks, and free blocks in the file system. If the file system is inconsistent, thefsck 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, thefsck command recommends the destruction of a damaged file. Refer to the fsck command description in AIX 5L™ Version 5.3 Commands Reference, Volume 2 for a list of inconsistences that this command checks for.
  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

No comments:

Post a Comment