Recover data from SD card

I have a 2 GB Kingston microSD card which is about three years old. I put it in a reader today in my Windows Vista computer, wrote a 32 MB file onto it, safely removed it, and then tried to read it elsewhere. Nothing. Putting it back in the Windows Vista computer it now says:

You need to format the disk in drive F: before you can use it.

What should I do? I have access to many computers and OSes if your recommendations need that. I would be very sad if I lost all the contents of the card. Most of the data is backed up, but there are a few things that aren't. :(

Doing a

# dd if=/dev/sdg of=~/tmp/sd.bin

gives me a 2 GB file, and grepping the file it seems like lots of my data is still there. How can I put it back together?


Photorec is designed specifically for this. It looks at file headers for various well known files and recovers photos - it does however mangle up filenames so you may need to rebuild these from exif data.

CGsecurity also has an application called testdisk for whole drive recovery, which the OP ended up using. This is useful where you know the disk is in reasonably good shape.

In general, I'd use several different applications to improve my chances of recovery, and work off an image and/or store recovered files in a different folder.


A link to photorec was posted, but it only finds known file types. My files were of all random types. The nice thing, is photorec comes with testdisk.

Using testdisk, I worked on the image I made with dd :

# dd if=/dev/sdg of=~/tmp/sd.bin
# sudo apt-get install testdisk #if on ubuntu/debian
# testdisk ~/tmp/sd.bin
(Select the partition)
(Advanced)
(Boot)
(Rebuild BS)
(List)

And there were most of my files! It scanned the image looking for a FAT filesystem. Just walk the filesystem and press c to copy important files to a directory on the local disk.

Thanks for pointing out that utility, The Journeyman geek