November 28, 2004

Recovering corrupted flash cards

Last night I had an unfortunate incident with Snow...whilst attempting to extract photos from a compact flash card, Windows ended up corrupting the card, probably by deleting the partition table. There's always that feeling of dread when you lose a whole bunch of valuable photos from a flash card, and it seems that thre's nothing that can be done as nothing is able to read the card again...right? WRONG!

With a bit of geek work, I discovered that it is in fact possible to recover the images from a flash card, as usually it's only the FAT and partition tables that get trashed, rather than the data itself. I wrote a little tool in perl to take advantage of this, and was able to successfully recover all but one photo.

The tool is deceptively simple. Just take a dump of the entire flash card with 'dd', and feed it to this tool, which looks for special bytes in the data that signify a JPEG image, and it extracts it to separate files.

Download script

The script doesnt guarantee complete recovery and may in fact recover very few images. The ideal situation for recovery is this:

  • Flash was formatted or completely deleted
  • Photos were taken WITHOUT anything being deleted
  • Disaster struck

In that case, recovery is likely to be full. If you delete photos with your camera (eg to re-take a shot) then fragmentation is likely and recovery of some photos will be hard. Note that ONLY jpeg image files will be recovered, but it's easy to change the script for other file types, just by editing the magic number.

I'd be interested in hearing any success stories with this tool.

Posted by Ben at November 28, 2004 02:18 PM

Fine solution :-). It is works .-) as well as some 2MB win tools. Autor have very good idea.


Posted by: unde at August 23, 2005 05:31 AM
Post a comment

Remember personal info?

Recent Entries
- Linux on an HP Compaq NC6400
- Sodium in water? Bah..try Caesium!
- I'm off to Lugradio
- Food for thought...
- Replacing ugly Helvetica fonts in Xorg
Support me...

Email me:
NL time:03:31
Book: Assassini (Thomas Gifford)
Amazon wish list
Search the web