Sunday, May 24, 2009

Practical Matters - Recovering Data from a Failing Hard Drive

I tend to leave my Linux workstation running constantly at home. Tuesday morning after returning from work, I found it locked up. Hard reboot and oops, it didn't complete the boot up. Grabbed a live CD, ran fsck /dev/sda2. The program found numerous errors and I spent a few minutes hitting the "Y" key numerous times approving the program's repair queries. After the repair, the system could boot. I then went to bed after shutting the system down. Later that evening before going to work, I booted the system and left it running. I returned the next morning to a failing system again. So I shut it down and used my Windows system to surf the web. I didn't touch the box until Friday. Friday, I found the PowerMax diagnostic executable on my Windows system. Installed it to a floppy and tested the bad drive in the Linux box. Bad news, the diagnostic gave an R03 error code whatever that means. Reset the machine's BIOS, then reran the PowerMax software - same error. Nothing was going to bring this drive back from the brink. The PowerMax software urged me to backup the drive before it failed. DUH!

So off I go to Best Buy. Grab a 500 GB Western Digital hard drive for $89.00, at least half of what the Maxtor likely cost when I bought it two years(?) ago. No wonder these things don't last any more. Set the new drive to slave with the jumper, plug it into the EIDE cable (yes, I'm using PATA), reseat the cable in the primary drive after a bad BIOS check. I decided to try a Bart PE live CD. Both Norton Ghost 8.3 and 11.0 failed. Version 11 at least failed immediately. Version 8.3 attempted to build the partitions on the new drive and then failed late into the second one. Norton always did disappoint when it came to drive recovery. Next, I tried a Linux live CD. I used the old workhorse dd.

dd if=/dev/sda of=/dev/sdb bs=4096k conv=notrunc,noerror,sync.
old drive new drive 4MB chunks don't truncate or stop for errors

I told dd to copy the data from the old drive to the new drive in 4MB chunks without stopping for errors, etc.. It failed after copying 81GB of data. That was new. Usually dd doesn't stop for anything unless the drive is already dead. Time to use ddrescue. I'd known about ddrescue for about 4-5 years, but had never needed to use it. It turned out that there is an improved version, GNU ddrescue, or gddrescue. There's even a version for Macs now.

First, I have to install the program on the live CD:

apt-get install ddrescue gddrescue

then

ddrescue /dev/sda /dev/sdb

and the recovery was done in about 30 minutes. Normally, one writes ddrescue infile outfile logfile (everything in UNIX/Linux is a file, even devices), but I decided I didn't want to fill up the ramdisk of the live CD in case ddrescue found a lot of errors. It turned out it didn't find any errors.

Last, but not least, set the new drive to master (remove the jumper basically for WD). Take the old drive out and replace it with the new drive, and I have my old system back. I had updated the kernel to 2.6.29 earlier in the morning and VMware Workstation fails to compile new modules, but that's another story. I hope this helps anyone trying to recover a failing hard drive from any system. If you are using an Ubuntu live CD, remember to put sudo in front of your apt-get install command. You may have to run sudo apt-get update prior to the sudo apt-get install. Supposedly, ddrescue will recover data from CDs, but since many audio CDs are copy-protected, a bit-by-bit recovery tool will tend to fail. This is unfair, but what can one do when copyright fair use has been crippled by theft by users and greed by producers. If you can send the drive back for a refund if it's under warranty, use GNU shred on it before you do.

Labels:


Comments:
Phew! Thats a relief John.

Looks like a close run thing.

Only in this age can there be so much legitimate drama in the near death of our PCs.

They're so much part of us, of our lives, part of the family.

Secretly I confide that my PC is more importannt than my 2 dogs!! There I said it.

My PC is my delicate thread to sanity and intellectual contact outside my sleepy hollow.

Regards

Pete
 
Pete,

I'm sure that you would miss your dogs more than your data. The furry ones are surrogate children and are unique. The data can be recreated or replaced or recovered, but once a pet has died, he or she is gone for all practical purposes. So, enjoy them while you have them.
I really just posted this to save someone a support call of $250 on up, if they didn't backup their data. I'm not sure what I'd do without the Internet, probably read more books.

John
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?