HowTo recover jpeg images from corrupt memory card

Today my digital camera decided that it had been too well behaved of late and the SD card decided to completely corrupt itself for no good reason, losing all the photos on it.

I've spent a significant portion of my youth messing around with file system editing and partition table editing an was not going to give up on the series of photos I'd taken over the last couple of days – luckily it didn't need anything more than a couple of simple commands to recover all the photos. Go Open Source software.

This tutorial is written for Ubuntu, but should be similar for most Linux machines

Step 1 was to make an image of the card (to have a backup of it) using the venerable dd command.

sudo dd if=/dev/sdb of=sdcard.img bs=1M

  • sudo – used to perform command as root user (i.e. have correct privileges)
  • dd – command to copy data a byte level
  • if=/dev/sdb – read data from /dev/sdb – you may need to change this depending on where your memory card it located.
  • of=sdcard.img – save this to the sdcard.img file in the current directory
  • bs=1M – Copy it in 1M chunks

Once this has completed you will need to run the marvellous program recoverjpeg on it.

First lets install it:

sudo apt-get install recoverjpeg

Then run it:

recoverjpeg sdcard.img

and you should get something like the following:

$ recoverjpeg sdcard.img
Restored 290 pictures

The images will be saved in the same folder.

Check the images out and hopefully it works as well for you as it did for me.


This post was posted in , , , , , by on