Wednesday, February 16, 2011

Recover Bad Superblock in RedHat / CentOS /Fedora Filesystem


If  you get a ¨Damaged Superblock¨ error message at filesystem (fsck) check in Linux Server, Usually fsck will not be able to repair the file system due to bad super block. In these situations, we can recover the damaged super block from the backup. 

Solution:


There are backups of the Superblock located on several positions and we can restore them with a simple command in a Linux server


By default in Linux, the file system creates the backup of  super block in the following locations:

193, 3276, 9804, 16840, 22976 and 29912.


Note: 193 is only on older systems  in many cases. 3276 is the most current position for the first backup

When you get this "damaged superblock or bad superblock error" and if  you get a root-prompt in a recovery console, then issue the following command:

# e2fsck -b 3276 /dev/sda5

Now the System will check the filesystem with the information stored in that backup superblock and if the check was successful it will restore the backup to position 0.

If this is not successful, then try using the other copy of Superblock backup (Refer the backup location of superblock above)


3 comments:

Mohamed said...

Very useful.. Good.. Keep it up..

kamarul said...

I have encountered an ext3 filesystem on a partition which never had fscked. Mounting and unmounting the partition is ok but creating a directory failed with input output error. An attempt to repair with fsck failed even using all superblocks. I reformat the partition and restore from backup.

kamarul said...

I have encountered an ext3 filesystem on a partition which never had fscked. Mounting and unmounting the partition is ok but creating a directory failed with input output error. An attempt to repair with fsck failed even using all superblocks. I reformat the partition and restore from backup.