The Hidden Blog

As it turns out, I do have a hostname.

Recover photos from storage devices

Published on March 25, 2014

Today I got asked if I could recover some photos from an accidentally formatted CompactFlash memory card. I knew about TestDisk already because I used it in the past to recover some files from corrupted harddisks but I was looking for another, easier tool for the task.

I wasn’t able to find anything free and decent looking so I went back and gave TestDisk another look. Browsing their wiki I stumbled upon PhotoRec which is a tool dedicated for the exact task I was going to need it for. And the best part: It already ships with TestDisk per default.

If you are using homebrew (and you should!) just install it with a quick and painless

brew install testdisk

And we are ready to use it.

If you are not a homebrew fan just download the version for your operating system from the downloads page and unpack it with double click or

tar -xvf testdisk-x.xx.mac_intel.tar.bz2

Navigate to the directory and run it with sudo ./photorec

If you have installed it with homebrew get yourself a new and shiny terminal window and run sudo photorec. It’ll prompt for your password. After that you’ll see an interface like the following:

Now just select the disk you want to recover files from, navigate with the arrow keys and proceed with Enter.

Select the partition you want to recover files from and proceed with Enter

In the next step you’ll have to select the filesystem type. If it’s a memory card for a camera it’s usually Other. Proceed with Enter.

The next step will ask you which strategy the tool is going to use. Just searching the free space or everything. Select Whole and continue with Enter.

Once we have done that we’ll have to choose the location where PhotoRec is restoring the files to. Navigate through your file system and press C and the restore process will start. It’ll look like this and will take quite some time, depending on how much storage it needs to go through.

The displayed ETA is usually pretty accurate. Once this is done it’ll display a summary on how many files it was able to recover.

You’ll find all your restored files in a directory called recup_dir.x in the destination directory you specified in the previous step.

The End.