View previous topic :: View next topic |
Author |
Message |
behd Apprentice
Joined: 11 Feb 2003 Posts: 155
|
Posted: Tue Sep 07, 2004 10:03 am Post subject: Partition recovery (ReiserFS with Bad Blocks) |
|
|
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 :
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 |
|
|
inode77 Veteran
Joined: 20 Jan 2004 Posts: 1303 Location: Heart of Europe
|
Posted: Wed Sep 08, 2004 12:07 am Post subject: |
|
|
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 |
|
|
Lanthanum n00b
Joined: 26 May 2004 Posts: 18
|
Posted: Tue Feb 01, 2005 3:40 pm Post subject: Sigh, I should have checked here first |
|
|
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?
|
|
Back to top |
|
|
zephirus n00b
Joined: 21 Nov 2003 Posts: 66
|
Posted: Fri Mar 04, 2005 11:25 am Post subject: |
|
|
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 |
|
|
Bob P Advocate
Joined: 20 Oct 2004 Posts: 3355 Location: Jackass! Development Labs
|
|
Back to top |
|
|
flybynite l33t
Joined: 06 Dec 2002 Posts: 620
|
Posted: Sun Aug 28, 2005 4:09 am Post subject: |
|
|
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 |
|
|
p4m n00b
Joined: 10 Feb 2004 Posts: 14
|
Posted: Tue Oct 18, 2005 2:38 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
noleti Apprentice
Joined: 18 Sep 2003 Posts: 153
|
Posted: Wed Jan 11, 2006 11:12 pm Post subject: |
|
|
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 |
|
|
|