Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Partition recovery (ReiserFS with Bad Blocks)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
behd
Apprentice
Apprentice


Joined: 11 Feb 2003
Posts: 155

PostPosted: Tue Sep 07, 2004 10:03 am    Post subject: Partition recovery (ReiserFS with Bad Blocks) Reply with quote

DISCLAIMER: This tip was quickly written just to keep track of what I've done. If I posted it here, it's only because I tought that it could be usefull for others aswell... so if you find mistakes (pls not in my spelling or english ;) ) or find better way to do it... feel free to comment !

Well I had 200 Gb of datas on a relatively new Maxtor dirve (~ 6 months)
which is now completly corrupted by bad blocks :(

some of the partition were even no more mountable:
mount /dev/hdb1 /mnt/data1 = "mount: Not a directory" (whatever the mount flag used... -ro -t auto/reiserfs/etc...)

here's how I recovered at least some of my datas:

- first get a new hdd and have partition at least as big as the faulty ones
- boot on a recovery CDs (or if you are in my case and that your favorite distro is still running on that comp, try from there)
NB. one of my favorite recovery boot cd: http://www.sysresccd.org/download.en.php

1. Copy as most as you can from the faulty partition
Code:
dd if=/dev/hdb1 of=/mnt/hdc4/hdb1.img conv=noerror

NB. noerror tell to dd to continue whatever happens

NB. I had to "Ctrl-C" because dd wasn't doing anything after some times...
!!! Before "Ctrl-C"ing verify that your img file is not growing !!!
Code:
ls -l /mnt/hdc4/hdb1.img (2 times and let a few seconds between)


2. Setup loopback
NB. your kernel may not have loop block device built in :
Code:
modprobe loop

then:
Code:
losetup /dev/loop0 /mnt/hdc4/hdb1.img


3. Try to mount the loopback:
Code:
mount -t reiserfs -o ro /dev/loop0 /mnt/rescue


But sadly, I ended with "mount: wrong fs type, bad option, bad superblock or too many mounted file systems"

4. Check & rebuild the reiser partition:

a. Simple check (at this point it's not even recognized as reiser partition)
Code:
reiserfsck /dev/loop0


b. Try to fix the superblock
Code:
reiserfsck --rebuild-sb /dev/loop0

Most probably the entire partition hasn't been copied... therefore I had the best results with those answers:
Code:
Did you use resizer ?

answer: "y" (if whole partition hasn't been copied "y" seems better)
Code:
Partition size [nnnn]

well difficult to guess exactly and quickly (but it's probably possible based on img size). Anyway default value offered by reiserfsck gave me good results... so just press <enter>
Code:
Do you want to rebuild the journal header ?

answer: "y" (if the start of the partition is ok, it should work... so pray that there wasn't bad blocks there...)

c. Re-check the partition
Code:
reiserfsck --check /dev/loop0

Now it's recognized as a reiser partition ! great... but it's still corrupted !

d. rebuild fs tree
Code:
reiserfsck --rebuild-tree /dev/loop0

(will take some time if your partition is several Gb large)

e. Last check ?!?
Code:
reiserfsck /dev/loop0

Hurrah now it's recognized !!!

5. Let's rescue all we can
Code:
mount /dev/loop0 /mnt/rescue


Good luck !

[edit 2004.09.08] Text formated and a few text added


Last edited by behd on Wed Sep 08, 2004 10:36 am; edited 2 times in total
Back to top
View user's profile Send private message
inode77
Veteran
Veteran


Joined: 20 Jan 2004
Posts: 1303
Location: Heart of Europe

PostPosted: Wed Sep 08, 2004 12:07 am    Post subject: Reply with quote

Nice howto!

Quote:
ls -l /mnt/hdc4/hdb1.img (2 times and let a few seconds between)


Just a suggestion:

Code:
watch -n 5 'ls -l /mnt/hda4/hdb1.img'


And you have an updated value automatic every 5 secs.
Back to top
View user's profile Send private message
Lanthanum
n00b
n00b


Joined: 26 May 2004
Posts: 18

PostPosted: Tue Feb 01, 2005 3:40 pm    Post subject: Sigh, I should have checked here first Reply with quote

I missed this post in my initial search. I have a bad HD, and I am in the process of restoring it.
It looks like I had a bad sector in the superblock, I think...

I used http://ubcd.sourceforge.net/ to repair the bad sectors, which dd conv=noerror appears to avoid.

I did the other reiserfsck fixes, but the partition is still un-mountable. I am in the process of doing a dd now.

Anyone know how to extract files from an unmountable fs? I am looking at a really long day of grepping for my <html></html> tags to get my website back, and I got a bunch of .oggs that I would hate to have to collect again.

Backups? What backups?
:cry:
Back to top
View user's profile Send private message
zephirus
n00b
n00b


Joined: 21 Nov 2003
Posts: 66

PostPosted: Fri Mar 04, 2005 11:25 am    Post subject: Reply with quote

Thanks, the datadump worked perfect to recover my lost data on my 200GB Maxtor... Makes me wonder if it is a Maxtor thing causing this problem...
Back to top
View user's profile Send private message
Bob P
Advocate
Advocate


Joined: 20 Oct 2004
Posts: 3355
Location: Jackass! Development Labs

PostPosted: Wed Jul 13, 2005 10:04 pm    Post subject: Reply with quote

Nice How-To! 8)
_________________
.
Stage 1/3 | Jackass! | Rockhopper! | Thanks | Google Sucks
Back to top
View user's profile Send private message
flybynite
l33t
l33t


Joined: 06 Dec 2002
Posts: 620

PostPosted: Sun Aug 28, 2005 4:09 am    Post subject: Reply with quote

Here are a couple more hints....

I believe it would be best for the dd to use 'conv=noerror,sync'

As you know:
noerror = Continue after read errors (because we know the disk has errors!)

Here is the sync help:
sync = Pad every input block to size of ibs with trailing zero bytes.

This fills the bad block space with zero's rather than just skipping them. Some (most?) file systems depend on metadata being in block +x bytes. Without this flag, your filesystem metadata could be availble but won't be found!

I believe it would be possible to use LVM to create a big disk out of smaller disks partitions to rescue a partition larger than your available space on one disk along. Just in case you need to rescue without buying a new big disk!!
Back to top
View user's profile Send private message
p4m
n00b
n00b


Joined: 10 Feb 2004
Posts: 14

PostPosted: Tue Oct 18, 2005 2:38 pm    Post subject: Reply with quote

Thank you behd,

just recovered my reiserfs partition (from a Maxtor DiamondMax Plus 8 40gb) following your simple how-to

Never never never recovered one single usefull file from a NTFS partition
Gentoo GNU Linux is GREAT :D
Back to top
View user's profile Send private message
noleti
Apprentice
Apprentice


Joined: 18 Sep 2003
Posts: 153

PostPosted: Wed Jan 11, 2006 11:12 pm    Post subject: Reply with quote

A thankful bump so this might help others - I was able to rescue at least some stuff... and it was a samsung disc for a change ;)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum