Recovering Data on Linux
How to recover data on an ext3 linux partition’, ‘Ok.. For some reason, I came home one day and my Trustix 2.1 server had crashed. After rebooting, it was giving a kernel panic as if it couldn\’t find the / partition (hda2). So, how do I get to my data? Well.. here are some things to try (or, what I did to get them back).
First, I pulled the HD out and stuck in it my workstation (running Fedora Core 1).
Next, I tried to mount it:
#mkdir /mnt/recover
# mount /dev/hdb2 /mnt/recover
mount: wrong fs type, bad option, bad superblock on /dev/hdb2 or too many mounted file systems.
Hmm.. That\’s wierd.. Well, Luckily ext3 stores backup superblocks. So, let\’s find one:
#mke2fs -n /dev/hdb2
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
12140544 inodes, 24277554 blocks
1213877 blocks (5.00%) reserved for the super user
First data block=0
741 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Well.. There we go. Let\’s use 32768.
# e2fsck -f -b 32768 /dev/hdb2
It will start doing a scan, and if it gives errors, say “y” to fix them. Also, if it says it doesn\’t support Journal FS\’s, tell it to continue anyway. If you are getting so many errors that you think it will take a long time to correct, I just hit CNTL-C to break out, and then I tried the mount command again. This time, it worked and I was able to get onto the partition and backup my data. Now, I will repartition/reformat and build the server again.. Goodbye Trustix 2.1 (going commercial after 2.2) hello TinySofa!