Saturday, August 14, 2010

Recover Bad Superblock in Linux 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:


8193, 32768, 98304, 163840, 229376 and 294912. 





Note: 8193 is only on older systems  in many cases. 32768 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 32768 /dev/hda5


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)