Recover your images from your broken CF/SD card

During our last holiday I recognized that my 4GB CF card was not recognized any more by my camera and my mac. I was looking for a recovery service on the net but the prices charged there were too high, so we accepted that the images from 1 day were lost.

I did not reformat the card because I was interested in recovering or searching for a possibility to recover. Today I sat in front of my screen and recognized that I had a linux server now up and running and that there should be tools to read and rescue the data there. I started a more detailed search session for rescuing data from CF cards using linux and I discovered the tool ddrescue, do not mix up with dd_rescue which is a complete different thing. The packagename for installation is:

sudo apt-get install gddrescue

Afterwards you can use the ddrescue binary on your linux machine. I read this article and concentrated on the part just above point 5 in the text where the different rescue steps are describe. You should read the whole text to understand what ddrescue does, but you don’t have to.

What you need for rescuing:

  1. a linux system
  2. a card reader
  3. a shell
  4. ddrescue installed
  5. time
  6. TestDisk application (download the package you will need the photorec binary)

First you have to find out what device is used for your card. Most cards can not be mounted if there is a logical defect causing the behavior. You should do a

tail -f /var/log/messages

to check which device your card is on. Example entry:

Nov 18 08:18:33 raspberrypi kernel: [864751.809897] sd 1:0:0:0: [sda] 7813120 512-byte logical blocks: (4.00 GB/3.72 GiB)

Within my system the card was recognized as the sda device so I had to use /dev/sda. The below commands have been issued one after another. If you get any errors executing the next statement you sometimes have to eject the card an reinsert and the command will work again. Details for the commands you will find in the aforementioned gnu link.

  • Please replace /dev/sda with your device name.
  • Please replace <destination_image> with the full qualified path to your desired destination where ddrescue should create the rescue image file.
  • Please replace <logfile> with the full qualified path to your desired destination where ddrescue should create the log file.

sudo ddrescue -i0 -s50MiB /dev/sda /home/pi/rescue/hdimage /home/pi/rescue/logfile
sudo ddrescue -i0 -s1MiB /dev/sda /home/pi/rescue/hdimage /home/pi/rescue/logfile
sudo ddrescue -i30GiB -s10GiB /dev/sda /home/pi/rescue/hdimage /home/pi/rescue/logfile
sudo ddrescue -i230GiB -s5GiB /dev/sda /home/pi/rescue/hdimage /home/pi/rescue/logfile
sudo ddrescue /dev/sda /home/pi/rescue/hdimage /home/pi/rescue/logfile
sudo ddrescue -d -r3 /dev/sda /home/pi/rescue/hdimage /home/pi/rescue/logfile

You should be patient the different steps can take quite a while. I have not measured the overall process because I did some searching and testing in between. Afterwards I copied the image file to my mac for further processing. If you install TestDisk on your linux system you do not have to this.

Don’t try to mount the image it is a data image only so there will be no success. This image can now be used for image rescue software like TestDisk – photorec.

If you have downloaded the package, extract it in a desired folder and open the terminal. Go to the folder you put TestDisk to and you will find the binary photorec there. Start photorec (replace <image_file_name> with the path and name to your image ddrescue created:

photorec <image_file_name>

The software openes in a DOS like application window where you can move around using the arrow keys and I followed the onscreen instructions, a few minutes later I had my images back

Steps I did within photorec:

  1. Select the media of media listed
  2. Hit enter on proceed
  3. Select unknown partition
  4. Select other if you card is from a digital camera (FAT/NTFS/HFS+…)
  5. next steps are obvious and bang your images are back

This procedure restored almost all images I thought lost. Only a handful images where damaged. So cool. Saved 100 € minimum.


Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden / Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s