How To Recover A Superblock

April 9th, 2009

If fsck or mount commands give errors then pretty good chances are there that the superblock is corrupt. The dd command comes to rescue. We know that the superblock resides in 31st block also. So, to recover that we use the following command:

# dd count=1 bs=4k skip=31 seek=1 if=/dev/my_lv  of=/dev/my_lv

count: How many blocks to copy.

bs: Block size(which is taken 4k by default).

skip: Skip number of  blocks.

seek: Get 1st record.

So, the above command will copy the 31st block to the 1st block.

Running fsck command is recommended after restoring the superblock.

Recovering Superblock In Linux

In case of Linux, the superblock is copied to 8193, 32768, 98304, 163840, 229376 and 294912 blocks. So, simply running:

#e2fsck -b 32768 /dev/hda5

Should do the trick. Superblock is started to be backed up at 32768 position in the most current systems. So, 32768 is safe option for almost all systems.

Tags: , , , , , , , , , , , , ,
Posted in Tips and Tricks | No Comments »

Comments

Leave a Reply

 Comment Form 

 



More articles from the category: Tips and Tricks


What is The Difference Between exec and xargs

There are very small things in linux based systems which often consfuse the users. Here in this article I’m going to discuss the specific use of find command and difference between exec and xargs.

Understanding The diff Command In Unix

It’s not an uncommon requirement for Unix system administrators to know the difference between two files. The diff command in Unix serves the purpose. Here I am going to discuss the diff command. It’s quite common but little understood command. I hope after reading this article, the Unix visitors will be able to understand the usage properly and benefit from it. Here you go…

How To Find Common Lines Between Two Text Files In Unix

Those working in Unix environment must be aware of the requirement to find common
lines between two Unix files. In this article I’m gonna introduce you to solve this problem.

How To Join Two Files Vertically

In Unix, sometimes we come across situations where we need to join two files’ output side by side vertically. This is also referred to as vertical joining of files. In such situations, paste command comes handy. With the help of this command you not only can vertically join the files, but insert some delimiter as well….

How To Recover A Superblock

If fsck or mount commands give errors then pretty good chances are there that the superblock is corrupt. The dd command comes to rescue. We know that the superblock resides in 31st block also. So, to recover that we use the following command: # dd count=1 bs=4k skip=31 seek=1 if=/dev/my_lv  of=/dev/my_lv count: How many blocks […]

Ways To Zip The Directory Structure of Unix

Often its the requirement of system administrators to move the directories in between the servers. Also the confusion arises which utility to use for the best results. Normally zip, tar, cpio utilities are used the most. I’m writing a short introduction of zip and tar.

How To Split or Cut A File Vertically(Column wise)

In Unix environment it’s often required to print specific columns from a file. If the rows of file are having some proper delimiters then other Unix command like awk come into picture and quite handy. But if say you want to print out the 5th character and then 7th to 16th character, then other commands fail and in such situations the cut command comes to rescue. Here is short primer of cut command.