Recover a broken/partitioned/whatever harddrive(external or internal)

So, who HAS NOT experienced a harddrive crash?! The answer is likely no one(either they know it or not).

The Problem
Since I experienced this lately I thought I write a tiny howto, to easy the pain and suffering for you. What happened to me was that I got delivered an external USB harddrive(WD 500GB Essential) and got told that “I NEED MY PICTURES BACK”….apparently after some digging into why it stopped working I found out it “might have been dropped or bumped while connected”. So this means theres a pretty good chance of errors! The harddrive was NTFS and were unable to mount at all – seemed there were no chance to get onto it.

What you need:
Computer running linux(I used Ubuntu Lucid 10.04)
The faulty harddrive connected
Software: testdisk/photorec
Note: You can also use a software called “foremost”, but on my drive it did a quick recover and skipped too much data. Ended up with about 3GB of pictures.

Recover as much data(pictures) as possible!

The Solution
So let me give you a quick tip on how to recover harddrives like this. My solution was run on a Ubuntu Lucid 10.04 and based on the magnificent DataRecovery page over at Ubuntu.

I used “photorec” to recover my data. Simple run photorec by running sudo photorec. This will give you all the options of what harddrive to recover, where to recover it to and so on. So what I did was make a folder called recover and told photorec to recover all my stuff in there. Then, off we go – started recovering!

During the recover-process(had it running for 24 hours, 1 pass) you could clearly see where the harddrive struggled to read data, ergo the damaged area. And the files you recover will be at random – so you need some quick way to sort out the different stuff.

Since I was only looking for my movies and pictures I read the brilliant scripts on how to read the exif-data from image headers to rename the files according to the capture date. I ran the following commands to easily rename all the files:

Make dirs:

mkdir results
mkdir results/jpg
mkdir results/jpg_small
mkdir results/jpg_dup

Move all pictures and remove the small ones:

find recovery/ -name "*.jpg" | xargs -i mv {} results/jpg
find results/jpg -name "*.jpg" -size -1024k | xargs -i mv {} results/small

Rename jpegs according to exif data:

find results/jpg -name "*.jpg" | xargs -i jhead -nf%Y%m%d-%H%M%S {}

Remove duplicates(i found out that i need to substitute *a.jpg with *b.jpg, *c.jpg and so on as well):

find results/jpg -name "*a.jpg" | xargs -i mv {} results/jpg_dup

This will make the results/jpg full of files named after capture date for easy-tracking and organizing.

I haven’t tried to do the same with movies, but surely there must be a way to read some header information from these too. All I needed was the camera-movies which was easy to spot from filesize.

Leave a comment if you have any suggestions or idĂȘas!

One thought on “Recover a broken/partitioned/whatever harddrive(external or internal)”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>