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

I wrote 19 books to help you become a better developer:

  • HTML Handbook
  • Next.js Pages Router Handbook
  • Alpine.js Handbook
  • HTMX Handbook
  • TypeScript Handbook
  • React Handbook
  • SQL Handbook
  • Git Cheat Sheet
  • Laravel Handbook
  • Express Handbook
  • Swift Handbook
  • Go Handbook
  • PHP Handbook
  • Python Handbook
  • Linux Commands Handbook
  • C Handbook
  • JavaScript Handbook
  • CSS Handbook
  • Node.js Handbook
...download them all now!

Related posts that talk about tools: