How to Recover Data Even When Hard Drive is Damaged

Note: Before attempting this procedure, make sure the damaged hard drive is being detected by the computer’s BIOS. If the computer cannot detect the hard drive then no software will detect it. To do this the drive must be connected directly a computer’s IDE or SATA cable, not by USB. Then you must go into the computer’s BIOS to see if it is being detected.


Ubuntu Rescue Remix and Ddrescue
Ubuntu Rescue Remix is a Linux Live CD. It already comes with a whole array of data recovery tools. One of them is Ddrescue. Ddrescue, is one of the best data recovery programs available and it is free. Ddrescue works by extracting a raw image of your hard drive and transferring it to another drive.  It extracts data bit by bit, regardless of the file system on the drive. The reason it works even when hard drives are dying is because Ddrescue retries several times and even tries to read data backwards. The procedure sometimes can take days, but it is very effective.

The Setup
As you can see by the picture down below I have two hard drives connected to the computer’s controller card. One is the source and the other the destination drive. I usually flip them upside down so that gravity helps a little if the arms are too close to the plates, also I place the hard drives in a rubber mat to prevent vibration. Both hard drives in the picture are SATA, nevertheless, you can have IDEs restoring to SATAs and vice versa (or even to USB drives, but they can be harder for Ubuntu Rescue Remix to detect).
The procedure involves 3 drives:
1) Your source drive (your damaged hard drive),
2) Your destination drive, this hard drive has to be slightly bigger than the source because it contains the raw image which will occupy the exact same size as your “source” drive, you then need a little extra space for the log files created by DDrescue. This drive must be totally empty or data in it will be overwritten!!!.
3) A drive to extract the raw image to. This drive can be the exact same size or bigger than your original “source” drive, but never smaller. This drive must also be totally empty or the data in it will be overwritten!!!.

Extracting the Raw Image
Download the ISO CD image of Ubuntu Rescue Remix (It’s linux, so it’s free), burn the CD and boot the computer with it.
Plug in the source and destination drives and run the following command that will tell you how many drives Ubuntu is seeing:
sudo lshw -C disk -short
The “lshw” command can sometimes be unreliable. If not all of your hard drives are being displayed, try the following command:
cat /proc/partitions

The “cat” command might not give you many details about the drives, but it will display all of them reliably.  For example, if  “lshw” only shows you one out of two drives, just by running the “cat” command and using simple deduction you can determine what the logical name of the missing drive is. (“Cat” will display drives and its partitions; drives are the ones without numbers at the end. Example: a drive will show as /dev/sda and a partition as /dev/sda1)
Identify the logical name of your destination drive (the drive where you will dump the contents of the damaged hard drive to). Create a Linux partition on that drive so that you can dump the image from your bad hard drive in there. Lets say, for this example, you have identified your destination drive as: /dev/sda. (yours could be sdb, sdc, sdd, etc. So change the following command according to what you have). *** Make sure not to confuse your source and destination drives, or you might end-up overwriting all your data***. Issue the following command at your shell prompt to format the destination drive:
sudo mkfs.ext3 /dev/sda
After formating, mount the destination drive, create a “recovery” directory, and get inside it.  To do this execute the following commands one by one (some of these commands may require sudo in front):
sudo mkdir mnt
sudo mount /dev/sda mnt
cd mnt
sudo mkdir recovery
cd recovery
After issuing the last command “cd recovery” you are inside the newly created recovery directory in your destination drive. Now, assuming you have identified your source hard drive as /dev/sdb (the broken hard drive you will be extracting the data from), run Ddrescue to extract the raw data, creating a file on the destination drive called “image” and a log file called “log”:
sudo ddrescue -r 3 /dev/sdb image log
This command will begin extracting the raw image from the bad hard drive, placing it inside the “recovery” directory on your destination drive. Take a look at the last two words in your command line; “image” is the name you are giving your your raw data image file, so, all your data will be stored in one single file named “image”. The las word “log”, is the name of your log file. You can change the name of these two file names to whatever you wish. The log file is extremely useful since it tells Ddrescue at what point it is during the data extraction process, therefore, it will know at what point to begin again if the process gets interrupted. In case of such an event all that needs to be done is to issue the same previous command, using the same file and log names inside the same directory containing the partial raw image file.

Restoring the Raw Image
When finished getting the image, unmount your destination drive by issuing the following command:
sudo umount /dev/sda
and turn the computer off. If you don’t unmount the drive before turning the computer off, the “lshw” command will have a hard time finding this same drive next time your run the command (notice the command is spelled umount not unmount).
Now we have acquired the image, however, since it is in raw format it is unreadable. We need to extract this image to a third hard drive. With the computer turned off unplug the damaged hard drive. We do not need it anymore. Plug in a good hard drive of equal or higher capacity, boot the computer with Ubuntu Rescue Remix and run the command to identify the drives again. Go inside the directory where the images are stored (in the source drive). Now the hard drive containing the raw image will be your source and your new empty hard drive will be your destination. Assuming your source drive is /dev/sda (the one containing the raw image), enter the following commands one by one to mount and enter your source drive:
sudo mkdir nmt
sudo mount /dev/sda mnt
cd mnt
cd recovery
Then and assuming your destination is /dev/sdb (your new empty drive where the raw image will be restored to), make sure your drive it empty otherwise you will overwrite your data) issue the following command to restore the image to your new drive:
sudo ddrescue image /dev/sdb

Make partition Active
cleanmgrcropped
Connect your hard drive to another computer (as a slave or by USB) and see if you can access the files. If you cannot, and the partition inside the hard drive is a Windows partition (NTFS, Fat, etc.), you might need to make the partition “active” using another Windows computer. If that is the case, connect the hard drive (as a slave or by USB) to a computer that has Windows and do the following:

Click on Start (The start orb in Vista and Windows 7) >> Click Run (“Search for programs” field in Vista and 7) >> type diskmgmt.msc and press enter.
This will bring up Disk Management. Right click on your newly connected drive and click on “Mark Partition as Active”

Fix Corrupt Partition (If Needed)
Go to “my computer” on the current computer and see if you can browse the files inside the hard drive, if you cannot, you have a bad MBR or partition table. Use TestDisk to fix it (comes with Ubuntu Rescue Remix).

No comments:

Post a Comment

adsense