For 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…
Hits for this post: 4477








December 9th, 2008 at 1:00 pm
Thank you so much for this post. This saved over 500 lost pictures including our trip to the zoo and an entire wedding. (My wife was going to kill me!) The tips here saved me a huge headache and $60 for a commercial product that probably would not have worked half as good.
Struggles:
Step 1: installing testdisk in Ubuntu is simple with the command “sudo apt-get install testdisk”
Step 2: I am not a Linux guru and had issues finding my SD card. Using fdisk -l to list out active cards helped me pinpoint the device to image with dd. I run Ubuntu and my device was located at /dev/mmcblk0p1
Also when running fdisk -l the listed devices will show you what to place into the bs value of the dd command. You should see a line such as “Units = cylinders of 2162 * 512 = 1106944 bytes” I used the 512 value here in place of the 1024 for my card and it worked great. (Not sure if this is nessecary)
Step 3: No troubles. I just picked a destination directory and watched my lost pictures appear.
Thank you again for a life saver of a post.
December 9th, 2008 at 11:42 pm
Thanks Alec. Good to know that this post was helpful to you, and nice to hear you overcome some of the struggles in an easier way. Thanks for the details you have covered.
January 9th, 2009 at 4:02 am
Will this work with windows for a sony memory card?
I’m not familiar with Linux. and unfortunately, I accidentally deleted some files from my memory card. There were only a few files deleted, so I really don’t want to have to pay for a program to recover them.
January 11th, 2009 at 9:42 am
@Kathy: There are several windows based programs which will let you records deleted dat, just do a web search. You may come across some free software which does this. And the technique works in Linux for sony memory card.
January 15th, 2009 at 5:53 am
I cannot believe how easy this was. Thank you so much for taking time to post this.
February 6th, 2009 at 11:54 pm
Thanks for the post, this helped me too ! I was trying with autopsy first but could not figure out how to get the pictures easily.
February 9th, 2009 at 3:08 am
just +1 on the thanks. Never head of photorec before, but will definitely not forget about it
February 12th, 2009 at 2:43 pm
Thank you! Thank you! Just recovered +-600 images using this method, from a memory stick. These photos were taken by a designer in Europe on one of her buying trips…seriously, this procedure just saved my neck…or maybe even my job..hehe
Thanks you again
March 4th, 2009 at 2:27 pm
Many thanks you have saved another 400 photos!
When using dd if=/dev/sda1 of=memory_card.img bs=1024 you don’t need to enter a drive or directory path as it is created in the one your terminal is running in.
Tony
April 15th, 2009 at 6:21 pm
Why a GUI, only a few commands in CLI…
April 17th, 2009 at 7:05 pm
Outstanding, another unexplored utility comes to the rescue. Many thanks for the pointers worked exactly as described, my mother in law will be delighted.