About nixCraft

Topics

Surviving a Linux Filesystem Failures

Posted by Vivek Gite [Last updated: November 15, 2007]

When you use term filesystem failure, you mean corrupted filesystem data structures (or objects such as inode, directories, superblock etc. This can be caused by any one of the following reason:

* 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:

So how the hell you are gonna Surviving a Filesystem Failures? Most of time fsck (front end to ext2/ext3 utility) can fix the problem, first simply run e2fsck - to check a Linux ext2/ext3 file system (assuming /home [/dev/sda3 partition] filesystem for demo purpose), first unmount /dev/sda3 then type following command :
# e2fsck -f /dev/sda3
Where,

Please note that If the superblock is not found, e2fsck will terminate with a fatal error. However Linux maintains multiple redundant copies of the superblock in every file system, so you can use -b {alternative-superblock} option to get rid of this problem. The location of the backup superblock is dependent on the filesystem's blocksize:

Tip you can also try any one of the following command(s) to determine alternative-superblock locations:
# 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):

E-mail this to a friend      Printable version

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Anonymous Says:

    I think you meant your dd command to have dd if=… of=…. (the of is missing). cheers, DrD

  2. nixcraft Says:

    Typo is corrected; Thanks for the heads up!

  3. Thomas Scott Says:

    Its easy to trash the old fs and
    create a new one , because data
    is never “hooked” to a particular
    fs !
    LiLo , LoadLin et al will still
    boot linux fine .
    Its easy cause the IDE HDD is
    much easier to figure , there
    is no need for partitions , nor
    any other “dependencies” .
    And drivers are much smaller .

    The reason we dont improve ,
    is someones paycheck is in it ,
    to keep it complicated .
    Its not unlike what Bill Gates
    did to USB …

  4. Dan Says:

    That works great IF your system will give you a terminal window. If you don’t get that far, you are SOL.

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , ,

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.