Re: fixing a corrupt /dev/hdar .. debugfs assistance...

Theodore Ts'o
Mon, 28 Jul 2003 20:53:07 -0000

On Mon, Jul 28, 2003 at 10:42:04AM -0500, Mike Moran
wrote:
> Had a drive crash which a very critital inode.   e2fshck
> returns a stream of :
>
> Entry '..' in ... (#######) points to inode (2) located in a bad
block
>
> Pass 3:  Checking directory connectivity
> Root inode is not a directory:  aborting
> e2fsck:  aborted
>
> /dev/hda4:  ***** FILE SYSTEM WAS MODIFIED *****
> Floating point exception
>
> I'm wondering if I can use debugfs to relocate (rebuild) inode (2) a
> good block.  If so, how would I go about doing it

There is a bad block at the beginning of the inode table.
Reconstructing the root inode is easy, but the problem is that the
root inode must be at a fixed location, and you currently have a bad
block located there.

It might be possible to force the disk drive to use another block from
its spare pool, but very often one bad block is just a prelude to
another, and the value of the disk drive (< $200) is often in the
noise compared to the value of the data stored on the disk drive
(priceless).

So the safest approach would be get another disk, and use dd to copy
the filesystem to another partition:

	dd if=/dev/hda4 of=/dev/hdb4 bs=1k conf=sync,noerror

Then run e2fsck on the new disk; it will create a new root and
lost+found directory, and move all of the inodes that were in the root
directory and home them in the lost+found directory.  You should be
able to reconstruct the names of each of the directories in the
lost+found directory from their contents.

Good luck!

						- Ted