Recover deleted files from Memory card in Linux

Recover filesFor the past few months I have been using my Sony Cybershot W80 extensively and taking photos left and right. One of the features that I use is that of creating folders on the memory card. On one such occasion I created a new folder which was for experimenting with the camera options next day.

Once I finished with the experimenting I wanted to delete them, since there were lots of photos deleting them individually did not make any sense so I used the ‘delete all photos in the folder’. The pictures got deleted fine….but as luck may have it the initial few photos were the one which I wanted. So was it all gone for ever??

Well….Google is here…..did a quick round of search and ended up with a quick open source solution to recover media files from a memory card. here is what needs to be done.

  • Install ‘testdisk’ package for your distribution
    The first step which I did was to install a software package named “testdisk”, depending on the distribution you use you should easily be able to find the package.
  • Make an image of the memory card
    The next step is to make an image of your memory card, this is achieved using the ‘dd’ command which comes by default with most distributions, the command you will have to issue is:

    $ dd if=/dev/sda1 of=memory_card.img bs=1024

    In the above command, ‘if’ is the input drive which should be your memory card, ‘of’ is the file name for the image which we are creating, and ‘bs’ is the byte size.

  • Recover files by scanning the image using photorec
    The final step is to use a command provided by testdisk package. The ‘photorec’ command will recover all the JPG and GIF files which were recently deleted from your memory card. The command is very simple:

    $ photorec memory_card.img

    The software will take you through a menu driven interface where you will have to select a few options to get your work done. It is simple and anyone should be able to use it with ease.

So by following the above three simple steps I was able to recover the pictures which I had thought were lost for ever and that to using only free software and on a Linux system. There is one or the other software in a Linux system which will always be there for your requirement but may have been unknown to you, but once you know your requirement you would be amazed at the options that are available, atleast I was blown away. Three cheers to free software and lots of thanks to the developers of ‘testdisk’ and ‘photorec’. Now only if someone would write a proper GUI for this….well I don’t want to be too greedy… ;-)

So I am off to take more photos without having to worry about losing some photos unintentionally when deleting photos from the Cybershot memory card…

Leave a Reply