http://www.cyberciti.biz/tips/surviving-a-linux-filesystem-failures.html
Surviving a Linux Filesystem Failures
* Mistakes by Linux/UNIX Sys admin
* Buggy device driver or utilities (especially third party utilities)
* Power outage (very rarer on production system) due to UPS failure
* Kernel bugs (that is why you don't run latest kernel on production Linux/UNIX system, most of time you need to use stable kernel release)
Due to filesystem failure:
- File system will refuse to mount
- Entire system get hangs
- Even if filesystem mount operation result into success, users may notice strange behavior when mounted such as system reboot, gibberish characters in directory listings etc
# e2fsck -f /dev/sda3
Where,
- -f : Force checking even if the file system seems clean.
- For filesystems with 1k blocksizes, a backup superblock can be found at block 8193
- For filesystems with 2k blocksizes, at block 16384
- For 4k blocksizes, at block 32768.
# mke2fs -n /dev/sda3
OR
# dumpe2fs /dev/sda3|grep -i superblock
To repair file system by alternative-superblock use command as follows:
# e2fsck -f -b 8193 /dev/sda3
However it is highly recommended that you make backup before you run fsck command on system, use dd command to create a backup (provided that you have spare space under /disk2)
# dd if=/dev/sda2 of=/disk2/backup-sda2.img
If you are using Sun Solaris UNIX, see howto: Restoring a Bad Superblock.
Please note that things started to get complicated if hard disk participates in software RAID array. Take a look at Software-RAID HOWTO - Error Recovery. This article/tip is part of Understanding UNIX/Linux file system series, Continue reading rest of the Understanding Linux file system series (this is part III):
- Part I - Understanding Linux superblock
- Part II - Understanding Linux superblock
- Part III - An example of Surviving a Linux Filesystem Failures
- Part IV - Understanding filesystem Inodes
- Part V - Understanding filesystem directories
- Part VI - Understanding UNIX/Linux symbolic (soft) and hard links
- Part VII - Why isn't it possible to create hard links across file system boundaries?