Wednesday, December 5, 2012

Recovering from a failed drive

If you have a drive that is starting to fail, there may be a chance to get a lot of the data off it.  Here’s a method that’s worked for me twice so far. It requires a second hard drive as large or larger than the failing drive.  It clones the drive completely, resulting in a copy of the drive that can be inserted and used just as the original, with data and partitions intact.  It does rely on the failing drive to be mostly readable. If your drive is totally failed, this won’t work for you.
First, download the ISO from and burn it to a CD (I use ImgBurn to make CDs).
Unplug all the drives from your system except the failing drive and the new, blank, good drive.  Boot to the rescue CD.  Type “startx” (optional since we’re going to just use the terminal anyway, but it’s nice to be able to have multiple terminals visible at once sometimes)
Insert a USB thumb drive.  It will be used for logging the progress of the rescue program.
run “fdisk -l” – scroll around and make note of the devices – in my case, /dev/sdf is the new drive, /dev/sdg is the old, failed drive, and /dev/sdh is my thumb drive.  Run these commands, but be SURE THAT YOU GET THE SOURCE AND DESTINATION RIGHT or you’ll wipe your data without warning.
> mkdir /mnt/usb0
> mount /dev/sdh1 /mnt/usb0
> ddrescue -r3 -v --force (dev id of failing drive) (dev id of new drive) /mnt/usb0/recovery.log
The first two commands create a mount point and mount the thumb drive. The last one starts the copy.  -r3 means try reading each block up to 3 times before moving on.  -v means be verbose, –force is necessary to make it overwrite the destination device.
ddrescue will try its best to copy the data, skipping stuff it can’t read in 3 tries.  Once it finishes, you can run exactly the same command again. It will use the copy of the log that it wrote to the thumb drive to know (and skip) what has already been copied successfully, and proceed to try to just read the problem areas.  If you like you can now increase the retry parameter.
In my case I had a 1.5T hard drive which had developed a LOT (hundreds) of errors, but they were all soft – the data would eventually read.  I was able to recover 100% of the data on the drive and just slide the new disk in where the old one was and boot right up as if nothing happened.

No comments: