Skip to content

How to recover lost data from an SD card

Here’s how I recovered (or tried to) lost data from an SD card.

As usual I write those posts to remember how, as this is the 2nd time I do this procedure and I always have to search how to do it.

I happened to run into trouble with my photography hobby 2 times and SD cards in the past couple months:

  1. an SD card appeared empty on the computer and wasn’t readable anymore from the camera (a camera firmware issue), and I had a few days worth of pictures on it
  2. I accidentally deleted a picture I didn’t want to delete, directly on camera, and that was a good picture

There’s a lot of mess when you look for disk recovery, maybe slightly in panic because you lost precious stuff, and many of the things you’ll find are paid options.

photorec (GitHub here) is a free option, actually it’s free GPL-licensed software, which is even better than “just” free.

It’s a command line tool.

Basically tries to retrieve all data that was stored on an SD card (or another kind of disk storage) even after it was deleted.

In the first case I was able to recover my pictures. In the second case it didn’t work, it was a very different use case, but at least I know I tried.

There’s an official site with docs and also a complete documentation in PDF available

Download it from https://www.cgsecurity.org/wiki/TestDisk_Download

On a Mac, install it using Homebrew using brew install testdisk (photorec comes with another tool called testdisk used to check disk partitions) and then run it with

sudo photorec

download all my books for free

  • javascript handbook
  • typescript handbook
  • css handbook
  • node.js handbook
  • astro handbook
  • html handbook
  • next.js pages router handbook
  • alpine.js handbook
  • htmx handbook
  • react handbook
  • sql handbook
  • git cheat sheet
  • laravel handbook
  • express handbook
  • swift handbook
  • go handbook
  • php handbook
  • python handbook
  • cli handbook
  • c handbook

subscribe to my newsletter to get them

Terms: by subscribing to the newsletter you agree the following terms and conditions and privacy policy. The aim of the newsletter is to keep you up to date about new tutorials, new book releases or courses organized by Flavio. If you wish to unsubscribe from the newsletter, you can click the unsubscribe link that's present at the bottom of each email, anytime. I will not communicate/spread/publish or otherwise give away your address. Your email address is the only personal information collected, and it's only collected for the primary purpose of keeping you informed through the newsletter. It's stored in a secure server based in the EU. You can contact Flavio by emailing flavio@flaviocopes.com. These terms and conditions are governed by the laws in force in Italy and you unconditionally submit to the jurisdiction of the courts of Italy.

Related posts about tools: