Related link: http://www.garloff.de/kurt/linux/ddrescue/
One thing I like about Linux is that there are always tools out there to discover that save you a lot of time or in this case data. I always love to walk a new user through transferring files from one drive to another and tell them “now run
watch df to check the output.”
“Watch? Oh WOW why didn’t I know about this before?”
Well, I had another one of those moments the other day when I ran across dd_rescue. This utility addresses the issue of using dd to image a drive that has bad blocks or otherwise has errors. When dd hits an error, it fails, so you are left with using skip and seek arguments to try to route around the bad blocks. Dd_rescue addresses this by simply skipping bad blocks it finds (or trying X number of times before skipping if you wish), so you can image even failing drives full of bad blocks.
Of course, dd_rescue has its problems as well. While it does skip bad blocks, it takes it some time to do so, and since bad blocks are often grouped together, it can take a very long time to dig through a group of bad blocks. If this group is at the front of your data, you are wasting the valuable last breaths of your hard drive looking at bad blocks, instead of recovering good ones.
The dd_rhelp script addresses this by acting as a front-end for dd_rescue. When dd_rescue finds a bad block, dd_rhelp has it jump ahead a bit, and then read blocks in reverse until it finds the tail end of the bad block group. It then continues forward and grabs all of the good blocks first. Then, after it finishes grabbing your good data, it goes back to the bad data and attempts to recover what it can from there.
dd_rhelp has an added advantage in that it can also resume at any point in the recovery by keeping track of where it is in dd_rescue’s logs. So if you have to Ctrl-C from the process, you can just re-run it and dd_rhelp will pick up where it left off. Also, it has a nice little ASCII progress meter, which is useful for keeping track of where you are.
Of course, it makes sense to not run this rescue while you are booted into the bad drive, so either move the drive to another system, or use some sort of rescue disk like Knoppix.
So, to use this, download dd_rescue version 1.03 or later (1.03 is also packaged in Debian unstable at the moment, but testing seems to have 1.02) from its site, and then get the latest version of dd_rhelp. While older versions of dd_rescue will work by themselves, dd_rhelp requires 1.03. Building dd_rhelp is a simple matter of untarring and running
./configure && make, and it even compiled just fine under Knoppix.
Once the tools are ready, you can recover a drive with
# dd_rhelp /dev/hda1 /mnt/hdb1/hda1_rescue.img
Then run fsck on the image you have created, mount it loopback (
mount -o loop /mnt/hdb1/hda1_rescue.img /mnt/hda1 in my case) and then browse through it and recover the files you need.
Now you can see if you still have a warranty on the drive and return it, demolish it with a sledgehammer, or take it apart and use it as a desk accessory.
What are some of your “click of death” horror stories? IBM Deathstar or otherwise!