# data loss?

## FGor

I think im i truble here guys. This is whats hapend:

I was moving files betwen to of my usb disks when i got this error in dmesg:

```
EXT3-fs error (device sda1): htree_dirblock_to_tree: bad entry in directory #33357825: rec_len is smaller than minimal - offset=0, inode=53691465, rec_len=0, name_len=0
```

Half the files on the disk where invisible from samba, so i unmounted the disk and ran: 

"fsck.ext3 -vy -C 0 /dev/sda1" witch found a lot of errors. at the end i got this message:

```
Error reading block 4294967295 (Invalid argument).  Ignore error? yes

Force rewrite? yes

Error writing block 4294967295 (Invalid argument).  Ignore error? yes

Restarting e2fsck from the beginning..."
```

Looking back at it i feel a bit stupid for using "-y".

And now i cant mount the system all i get is:

```
mount: 

wrong fs type, bad option, bad superblock on /dev/sdb1,

missing codepage or helper program, or other error

In some cases useful info is found in syslog - try

dmesg | tail  or so
```

```
dmesg:

EXT3-fs error (device sdb1): ext3_check_descriptors: Block bitmap for group 0 not in group (block 1025)!

EXT3-fs: group descriptors corrupted!
```

fsck wont work with me either it gives me this error:

```
fgor-server ~ # fsck.ext3 -vn -C 0 /dev/sdb1

e2fsck 1.40.9 (27-Apr-2008)

fsck.ext3: Invalid argument while trying to open /dev/sdb1

The superblock could not be read or does not describe a correct ext2

filesystem.  If the device is valid and it really contains an ext2

filesystem (and not swap or ufs or something else), then the superblock

is corrupt, and you might try running e2fsck with an alternate superblock:

    e2fsck -b 8193 <device>
```

When trying to find a valid superblock i get this:

```
fgor-server ~ # dumpe2fs /dev/sda1

dumpe2fs 1.40.9 (27-Apr-2008)

dumpe2fs: Invalid argument while trying to open /dev/sda1

Couldn't find valid filesystem superblock.
```

Am i losing my data here or what? 

Using dd (if its even posible) feels like a pain sins there is ca 800gb of data on the disk and i dont realy have eny place to store it.

Running "mke2fs -n /dev/sda1" gives me the position where the superblocks would be. Taking the first of the backup superblocks from that list

and runing it with: "dumpe2fs -o superblock=32768 /dev/sda1" gives me:

```
Group 1: (Blocks 32768-65535)

Backup superblock at 32768, Group descriptors at 32769-32827

Reserved GDT blocks at 32828-33792

Block bitmap at 33793 (+1025), Inode bitmap at 33794 (+1026)

Inode table at 33795-34306 (+1027)

29650 free blocks, 8192 free inodes, 0 directories

Free blocks:

Free inodes: 8193-16384
```

```
fgor-server ~ # fsck.ext3 -b 32768 -nv -C 0 /dev/sda1

e2fsck 1.40.9 (27-Apr-2008)

fsck.ext3: Device or resource busy while trying to open /dev/sda1

Filesystem mounted or opened exclusively by another program?
```

Argh... Tired, might edit this to morow.

*whine* :<

[edit]

okay... so this file system is f**k:ed how do i backup the superblocks (to files) on my other disks?

im gonna try i saving the files with some free util i found for windows.

----------

## NeddySeagoon

FGor,

Read

```
man mount

man e2fsk 
```

Note that mount will take a parameter of the location of the super block to use. 

Be aware that mount works in raw disk blocks and e2fsck works in disk allocation units, which are a multiple of disk blocks.

Knowing this, you can write a mount command that mounts your damaged filesystem, read only, using a backup superblock.

If that works, you may be able to recover your data.

You learned the first lesson of damaged filesystems ... don't let anything write to them.

Hint: mount -o ro,sb=X -t ext2 /dev/... /some/mountpoint .. you need to work out values for X.

Its ext2 not ext3 as journal replay is not possible with a read only mount.

Sorry about the sig ...

----------

