Sponsored Links

Maxabout.com > Tips

FSCK ( filesystem check )

Added on:9/3/2008 11:09:49 PM
In Linux Tips
 Rated by 1 users

    Every 20 to 30 times you boot up your computer, after an improper shutdown or power-faillure, the system will perform a filesystem check. 
    In most cases no problem, however, sometimes in rare cases it may ask you if you want to repair inconsistencies; you press "y" and "Enter" a few times and it will proceed booting. In some very rare cases it will tell you that you have to do a manual fsck and give you a prompt:
  1. ( Now you have to know what partition ( hda? ) was the critical one ! )
    CODE
    # fsck -p /dev/hda?

  2. ( Replace the "?" with the partition number ) The "-p" stands for repair automatically.
    CODE
    # e2fsck -f /dev/hda?

  3. ( Replace the "?" with the partition number ) e2fsck is a modern, more powerfull version of fsck. The "-f" option forces a more elaborate check.

  4. Sometimes the system tells you to do the check without the "-p" argument, this just means you will have to say "y" a lot of times !

  5. In some very, very rare cases an emergency console will come up, just do the above at the prompt and when done close the console with "Ctrl+d" and the system will continue booting.

  6. If you get these errors often:
    CODE
    # e2fsck -c /dev/hda?

  7. ( Replace the "?" with the partition number )
    This will mark bad blocks on your HD and no more data will be written in those blocks. 
    ( !!! fsck and e2fsck should only be performed on unmounted partitions !!!! )

  8. In very, very, very rare cases a "Super-Block" might get damaged:

  9. A super-block is the first block of each ext2 or ext3 partition. It has important data about the file system, like size, free space, etc.

  10. A partition with a damaged super-block cannot be mounted. But, ext2 and ext3 keep several super-block backup copies scattered over the partition.

  11. Boot your system with a boot disk. ( I hope you did make one ! ) The location of the super-block backup copies depends on the block size of the file system.

  12. For file systems with 1 KB block size it is at the beginning of each 8 KB (8192 bytes), for file systems with 2 KB sizes it is at the beginning of each 16 KB (16384 bytes) and so on.

  13. You can use:
    CODE
    # mke2fs -n /dev/hda?
    to find out at which byte positions the super-block copies are. With a 1 KB block size, the first backup copy is in byte number 8193 ( 8192+1 ).

  14. To restore the super-block from this copy, do:
    CODE
    # e2fsck -b 8193 /dev/hda?
    If that block also happens to be damaged, try the next one at byte number 16385, and so on until you find a good one.

  15. Reboot to activate the changes.


Sponsored Links
Tools
Bookmark/Discuss