Wednesday, October 18, 2006

what is superblock and how to recover it

Hello EB,

The scope of this article not covers about the basic things about file system, but its about troubleshooting of currupt file system.
So, when you create file system on hard drive it will sub devided into multiple file system blocks.
Blocks are used for -
1. To store user data
2. Some blocks used for to store file system's metadata.
(Metadata is kind of structure of your file system and it contents superblock, indoes and directories)

Superblock - Each of your filesystem has a superblock. File system like ext2. ext3 etc. Superblock contents the information about file system like -
* File system type
* Size
* Status
* Information about other metadata

Now you will guess that how important is superblock for your filesystem, if that is that currupt then you may not able to use that partition or may you will error while tring to mount that filesystem.
Following are some errors when superblock get currupts or some bad sectors
- You cant able to mount the filesystem, it will refuse to mount
- Filesystem gets hang
- Sometimes though you are able to mount that filesystem, but strange behavior occures.

These kind of errors occures because of bunch reasons. Most of the time fsck works fine for these errors -
$e2fsck -f /dev/hda3

(-f option for forcefully checking even filesystem seems clean)

Now fsck doesnt work because of lost of superblock, what you will do??
Note that Linux maintains multiple redundant copies of the superblock in every filesystem. You can find out this information with this following command -
$dumpe2fs /dev/hda6 grep -i superblock
dumpe2fs 1.32 (09-Nov-2002)
Primary superblock at 1, Group descriptors at 2-2
Backup superblock at 8193, Group descriptors at 8194-8194
Backup superblock at 24577, Group descriptors at 24578-24578
Backup superblock at 40961, Group descriptors at 40962-40962
Backup superblock at 57345, Group descriptors at 57346-57346
Backup superblock at 73729, Group descriptors at 73730-73730

To repair file system by alternative superblock
$e2fsck -f -b 8193 /dev/hda6

(Take backup using dd before doing running commands)

If you are using Sun Solaris, as My experience frequent power failure can get you hell :-( . I am using old sparc and one time in month I have run fsck using commands as per my last blog. So if your Sun Solaris lost the superblock then boot from cdrom or network, to retrive information about your filesystem's superblock give following command -
$newfs -N /dev/rdsk/devicename

Now use alternative superblock
$fsck -F ufs -o b=block-number /dev/rdsk/devicename

okie guys, hope this information helps somebody.


Shara said...

Hey Amol, Happy merry christmas.
see you soon, Amol

Amol P Kesare said...

Hey shara...
Do I know you???
Merry Christmas by the way.

Anonymous said...

Great !, eplained in a very understandable mode. thanks

Anonymous said...

Hope i read the same pos in another famous web-page... Please do not copy paste.. its worthless

Anonymous said...

Great website, looks very clean and organized. Keep up the good work! antibacterial Read a useful article about tramadol tramadol

Anonymous said...

Hi Amol
I have a case where hard disk with linux ext3 file system was overwritten ( 100gb partition was created out of original 300Gb ) and OS was reinstalled. Is there any chances to recover original data?
Thank You

Anonymous said...

Challenging money creditors provide financial problems and while it and when it can be due to be paid without penalty this article The loan approach begins with stuffing of an application form which takes only few minutes