Sat 31 Dec 2005
How to restore reiserfs partition from crashed disk
Posted by Anton Titov under Server administration , LinuxFew days ago, a server of mine had all of it’s 4 disk crashed. The problem was that one of the disks was overheating and that seemed to help other harddrives to crash (don’t buy Maxtor).
So, if you have a case like mine - some partitions with reiserfs on hard drive with bad blocks this guide may help you.
Firts try to mount you partition and copy as mouch data as you can. But the chances are, that if you are searching the net for a solution that you cannot mount your partiton and reiserfsck dies, saying you have bad blocks.
First download and install dd_rescue (if you plan to boot from LiveCD while restoring, you can try this statically linked binary dd_rescue binary), as dd conv=noerror will not help - it will not write something instead of unreadable zones which changes drive size and most of the data, that is after the bad blocks will not be restored /or you will have the files, but with garbage in them/. dd_rescue also shows you how much of the disk cannot be copied, which may give you some hope to restore you files, as most of the time you will have just few megabytes or less in bad blocks.
You will need another hard disk with enough free space to copy the whole partition (not only for used space). Now boot from a good hard drive or from LiveCD (Gentoo, Knoppix, Ubuntu, should not matter). Mount the good hard drive with free space somewhere.
Now if your failed partiton is /dev/sda1, and /mnt/disk2 is a place with enough free space run
dd_rescue /dev/sda1 /mnt/disk2/sda1-img
or
/path/to/just/downloaded/from/above/link/dd_rescue /dev/sda1 /mnt/disk2/sda1-img
now find some work to do as this will be slow.
When dd_rescue finishes you may want to make another copy of just copied image if you have enough free space, this most probably will be faster:
dd_rescue /mnt/disk2/sda1-img /mnt/disk2/sda1-img2
Now run
reiserfsck –rebuild-tree /mnt/disk2/sda1-img
if after you type Yes program dies silently try:
reiserfsck –rebuild-sb /mnt/disk2/sda1-img
first.
Now you should be able to mount your partition as:
mkdir /mnt/sda1fixed
mount -o loop /mnt/disk2/sda1-img /mnt/sda1fixed
now go to /mnt/sda1fixed and see what you have.
If you are unlucky most of your files will be in /lost+found with strange names. The good news is if you find a directory there, it’s contents will have good names. So you may want to try:
cd /mnt/sda1fixed/lost+foud
find -name some_file_with_not_common_name_that_should_be_in_directory_that_is_important_for_you
with
find -name shadow
you should be able to find your /etc directory.
After trying this, if you-re still missing important data, you can try the above procedure, but with adding -S to reiserfsck parameters:
reiserfsck –rebuild-sb -S /mnt/disk2/sda1-img
but first read reiserfsck man page.
Hope this helped you.
And a piece of advice: backup you data regularly.
Leave a Reply
You must be logged in to post a comment.