Resurrecting a lost hard disk...
My main desktop system had been powered off for a few weeks and when I powered it on last weekend it wouldn't boot up completely. It was complaining about errors, specifically errors on the hard drive that contains all my documents. The 1.5TB hard drive had been my home directory repository for the past 2 years and never gave any signs of trouble.
I grabbed my copy of SpinRite and set it loose, but it too had troubles and would get a "divide by zero" error less than 30 seconds after starting. Not good. I got a bit further by removing it and trying to access it via a USB-to-SATA adapter I had. This time SpinRite could work on the drive (albeit VERY slowly), but I still couldn't mount it or see the data.
After playing with it for most of last weekend I resigned to the fact that it was dead. Thankfully, when I purchased it via NewEgg.com in November 2010, I spent the extra money and got the Western Digital Caviar Black 1.5TB SATA drive - it came with a 5 year warranty. It was well within the WD warranty period, and when I got to their on-line support page, all I had to do was enter the serial number and choose cross-ship, and the new drive was waiting for me two days later.
While waiting for the HDD, I did some research and came across the "ddrescue" utility - a Linux utility that tries to read raw sectors from one place and dump them to a new file or other drive. The tool will attempt to re-read sectors a few times, but it will log the bad sectors in a file, then continue with the rest of the disk. I decided to give it a try, and I'm glad I did.
When the replacement drive came, I put it into the case and attached the failing drive to the USB adapter. After running SpinRite on the new drive for a couple days (even level two took 20+ hours - I couldn't really start on recovery until Friday night), I decided to try the ddrescue tool. I ended up booting from an Ubuntu "LiveCD" and running a very simple command:
ddrescue -v /dev/sdc /dev/sda disk_rescue.001.wri
That setup ddrescue to be verbose ("-v"), try coping everything from /dev/sdc (the failing drive), to /dev/sda (the new drive), and save all your notes in a file named "disk_rescue.001.wri".
It was slow going at first. It was maxing out at about 500KByte/second - that was going to take a long time. As I let it sit for about 15 minutes, I noticed that it started leveling out at a better 6MByte/second. Still not great but better.
Since ddrescue will auto-restart if it has a log file to reference, I killed it and re-ran it with the "-c 1024" option. Using "-c" told the program to take a bigger "bite" each time it copied from the disk, and that seemed to bring the speed up to 32MByte/second. Playing with different values didn't help the speed much, so I let it run over night and it was still running Saturday morning. It ran all day Saturday, but finally finished sometime early Sunday morning.
I could tell tha some stuff was being copied - I used "dd if=/dev/sda count=25 bs=1024k | strings | more" and could see some text - but mounting the new filesystem reported a lot of errors about the superblock.
I did some additional searching and found this blog entry:
How to repair a broken ext4 superblock in Ubuntu
In short I ran "mke2fs -n /dev/sda1" and found a number of superblocks listed so I chose one more in the middle. I then ran "e2fsck -b {block_number} /dev/sda1" and let it run. The first time I ran it, there were a lot of errors that I had to answer "y" to, and a large but smaller set the second time. I then re-ran it with the "-y" option to tell it to fix everything and it finally came up clean enough for testing.
I was finally able to mount it and look around. To my initial suprise, the home directory wasn't there, only a "lost+found" directory. Checking there, were a few new files, and under there was my "dan" home directory. I moved it to the correct location on the disk and rebooted my system.
WOW! My system came up and I was able to login with my "dan" account. Much more suprising, all of the videos and bigger files I have checked so far have been fine.
I think I dodged a bullet this time - I really need to look into a true RAID NAS solution for my home directory.
P.S. I know that a RAID system does NOT take the place of a true backup. We do have an off-site backup solution that I use to keep important files in: JungleDisk with Amazon Simple Storage Service. It's not the cheapest solution, but it encrypts with my private key BEFORE sending it out ot the Amazon servers, and I can use the program on as many systems as I need. Highly recommended.

Dan Linder