Thursday, August 25, 2011

Clone a failing Windows hard disk with ddrescue on Ubuntu Rescue Remix

Scenario: The hard disk is starting to throw "bad block" errors. Windows still works/boots, but who knows for how much longer. And you don't want to have to go through the time and expense of rescuing the data from the failing disk, installing Windows and all your applications on a new hard disk, and re-loading the data on the new hard disk.

Solution: You want to use a free Linux tool called Gnu ddrescue to clone the failing drive to the replacement drive.  This is one of the tools available on the Ubuntu Rescue Remix.  For more info on this tool, start here: http://www.gnu.org/s/ddrescue/ddrescue.html

If you Google ddrescue, you'll find lots of info on how to use ddrescue to recover data.  However, there's not a lot on how to move a Windows load from a failing drive to a new drive.  For example, one mistake that I've made is imaging the failing drive instead of cloning it.  The image file is not easily restored and bootable on the new drive. 

Here's what you need to do.  Idiots beware, this is not an idiot-proof guide.  Important but obvious steps are omitted.  Feel free to embellish or enumerate such steps in your comments.
  1. Download Ubuntu Rescue Remix here: http://ubuntu-rescue-remix.org/Download and burn it to a CD.
  2. Get a hard disk to replace the failing drive that is the same size or larger.
  3. Connect the new disk to the machine with the failing disk.  A fast connection (eSATA) is better than a slow connection (USB).
  4. Boot the machine to the Ubuntu Rescue Remix CD.  This will get you to a command-line prompt; there is no GUI.
  5. At the command prompt, key in the command:
     .  This command will identify the disks as /dev/sda and /dev/sdb (or perhaps /dev/hda and /dev/hdb, or perhaps you have more than 2 drives connected, ...).  This command will list the size and make of each drive, which should allow you to determine which drive designation is the source/failing drive and which is the target/replacement drive. You need to know this without ambiguity; it is easier if the target is larger than the source.  
  6. For the sake of example, let's assume that the source drive designation is determined to be /dev/sda and the target drive designation is /dev/sdb.  Your situation may be different.  To clone the source drive, at the command prompt, key in the command:

    That's it.  Depending on the size of the source drive and the number of bad blocks, it will take time to clone the drive.
  7. When ddrescue is done, swap out the target disk for the source disk in the PC, and fire it up.  It should boot and work as well as the source disk, but without the looming prospect of imminent disk failure.
  8. If you have used a larger target disk to clone the source, you may want to expand the partition to use the whole, larger disk.  GParted will do the trick.  Unfortuantely, this tool is not on the Ubuntu Rescue Remix CD.  Parted is, but it will not resize NTFS partitions.  You can find GParted on the Ubuntu live CD.  You can download it here:  http://www.ubuntu.com/download/ubuntu/download.  Instructions for using GParted to resize a disk are here: http://gparted.sourceforge.net/larry/resize/resizing.htm.