How to recover data from a memory card for free

By Ricky Nelson · 21 July 2010

I am closing down my old blog on socketwiz.com and I didn't have much content over there and this was and article I felt like preserving.

So a friend of mine took some pictures on her camera which contains an SD card but for some reason was unable to retrieve the pictures off of it. I have a similar camera and a Mac she has Windows. Many times I’ve been able to access data on removable drives on my Mac that were inaccessible on Windows but not this time.

So my first hurdle was how to mount this drive under the file system. I put the card in my camera but it does a great job of masking that there is a removable drive inside of it. Normally I don’t care. I just plug it in and up comes iPhoto ready to pull the images off and remove them from my camera. So when I plugged her card in, iPhoto dutifully came up…but no pictures. So I found a free piece of software called PhotoRec that would supposedly extract the data from the memory card if I could only see it. So with iPhoto up and running I ran the app, but there was no drive to be seen. For some reason I decided to look around on my Mac to see if by any chance there might be a card reader of some sort and lo and behold right under the CD drive is an SD card reader. Who knew? So I plugged her card into the reader and finally it was properly mounted.

The website for PhotoRec says that as long as you can see the card and the proper size of the card is detected, then there is a very good chance that the data can be recovered. Luckily this card was reporting the proper size. Now PhotoRec is a free application and as such it doesn’t have a fancy user interface that just anybody can click around and figure out. You have to run this utility from the command line.

The drive that is 1000GB is my hard drive, the one that is 513MB is the memory card. So I choose the first one /dev/disk2, not the /dev/rdisk2. And I’m given a screen with more options:

Disk /dev/disk2 - 513 MB / 489 MiB (RO)

Please select the partition table type, press Enter when done.
[Intel  ]  Intel/PC partition
[EFI GPT]  EFI GPT partition map (Mac i386, some x86_64…)
[Mac    ]  Apple partition map
[None   ]  Non partitioned media
[Sun    ]  Sun Solaris partition
[XBox   ]  XBox partition
[Return ]  Return to disk selection

Intel seems like the most reasonable out of the choices so I select that one. I’m then prompted with more choices:

Disk /dev/disk2 - 513 MB / 489 MiB (RO)

Partition                  Start        End    Size in sectors
No partition                   0    1002495    1002496 [Whole disk]
1 P FAT16 >32M                   233    1002495    1002263 [NO NAME]

I’m pretty sure that memory sticks for most cameras are formatted as FAT so I choose that. I’m then prompted with more choices:

1 P FAT16 >32M                   233    1002495    1002263 [NO NAME]

To recover lost files, PhotoRec need to know the filesystem type where the file were stored:

[ ext2/ext3 ]  ext2/ext3/ext4 filesystem
[ Other     ]  FAT/NTFS/HFS+/ReiserFS/...

Again, I choose anything that says FAT, and again I prompted with more choices:

1 P FAT16 >32M                   233    1002495    1002263 [NO NAME]

Please choose if all space need to be analysed:

[   Free    ]  Scan for files from FAT16 unallocated space only
[   Whole   ]  Extract files from whole partition

You know me, I’m going with FAT. Now I’m asked where I would like to save the recovered files. This is starting to look promising.

Do you want to save recovered files in /Users/socketwiz/bin ? [Y/N]

Do not choose to write the files to the same partition they were stored on. I choose to store the files on my desktop and then select Y and it begins to attempt to restore the files…FINALLY. A folder is created on my desktop called recup_dir.1 and PhotoRec appears to be recovering the files:

Disk /dev/disk2 - 513 MB / 489 MiB (RO)
Partition                  Start        End    Size in
sectors
1 P FAT16 >32M                   233    1002495    1002263
[NO NAME]


Pass 1 - Reading sector     384119/1002263, 151 files found
Elapsed time 0h01m41s - Estimated time for achievement 0h02m42
jpg: 151 recovered

After around 10-15 minutes all 412 files are properly recovered. Your mileage may vary but I would say if you can mount your card, and the operating system is reporting back the proper size of your card, then you have a pretty good chance of recovering you data from it. This software also runs on Windows and I would expect you would receive the same choices I described above. At any rate, if you or a friend end up with a corrupted memory card give these steps a try, I hope this helps.

Update for 2026

I wrote this in 2010 and PhotoRec is still my answer, it is still free and it is still maintained. The latest stable release as I write this is TestDisk & PhotoRec 7.2, from February 2024. A few things are worth knowing that I either didn't know or didn't explain well the first time.

Installing it

PhotoRec ships as part of the TestDisk package. It runs on Windows, Linux and macOS, and you can grab it from the official download page or install it with your package manager:

# macOS (Homebrew)
brew install testdisk

# Debian / Ubuntu
sudo apt install testdisk

# Arch
sudo pacman -S testdisk

On Linux you need to run it as root (sudo photorec). On Windows, right click photorec_win.exe and choose "Run as administrator".

Stop using the card

Before anything else, stop writing to the card. Don't take more pictures with it and don't format it. Anything new written to the card can overwrite the files you're trying to get back. PhotoRec itself only reads from the card, so it won't make things worse.

Image the card first if it's failing

If the card is physically flaky, every extra read is a risk. Instead of pointing PhotoRec at the card, copy the whole card to an image file once with GNU ddrescue and recover from the copy. It's ddrescue on Homebrew and Arch, and gddrescue on Debian and Ubuntu. Replace /dev/sdX with your card (check with lsblk on Linux, or diskutil list on a Mac, where it looks like /dev/disk2 like it did for me):

# First pass: grab everything that reads cleanly, skip the bad spots
sudo ddrescue -n /dev/sdX card.img card.map

# Second pass: go back and retry the bad spots a few times
sudo ddrescue -d -r3 /dev/sdX card.img card.map

# Recover from the image instead of the card
photorec card.img

The card.map file keeps track of what has been copied, so you can stop and resume without starting over.

Free or Whole?

Looking back, I glossed over this screen. When PhotoRec asks whether to scan "Free" or "Whole", here's what they actually mean:

  • Free only searches the unallocated space, so it only finds files that were deleted.
  • Whole searches the entire partition, which is what you want when the file system itself is corrupted.

A card that the camera or your computer suddenly can't read, like my friend's, is the corrupted case, so choose Whole. Use Free when the card works fine and you just deleted something by accident.

On the file system screen before that, the rule is simple: unless the card is formatted ext2/ext3/ext4 (camera cards almost never are), choose Other.

Only look for pictures

PhotoRec recognizes a lot of file types, so on a big card it can dig up a lot of junk. On the main menu, File Opt lets you change which file types it recovers. Limit it to jpg (plus your camera's raw format if it shoots raw) and you'll have far less to sort through.

Recovered files land in recup_dir.1, recup_dir.2 and so on, and you can look at them while the scan is still running. To find what you're after, sort the recovered files by extension or by date. PhotoRec sets each file's date from the metadata in the file when it can.

For the full walkthrough, the PhotoRec Step By Step page on the official site is still the best reference.