How to Safely Retrieve Files Off Failing HDD, SSD, or SD Cards Using Free Tools
All of the drives we are using to store our precious photos and videos are not 100% reliable. Everybody should know that by now (and back everything up) but even if you are doing it properly, there are times when a drive fails and you have nowhere else to get its contents except from the drive itself.
It happened to me recently. A 23GB SD card from a trip, almost full of precious shots, was corrupted when I inserted it into a cheap PC card reader.
As a result, both Windows PC and Mac were unable to read anything from the card and were prompting me to format it instead. After trying lots of commercial software designed specifically for recovering photos and files from SD cards, I was lost. None worked well. One of the tools was able to recover some photos, but only about 2% of what was there initially.
But I did not give up, and finally figured out how to do it properly. Surprisingly, it cost me nothing.
First, the drive may degrade with each attempt to access it, so it is a bad idea to try reading from it repeatedly. It may fail and die entirely. What we need is a tool that can copy the entire drive to an image file on a local disk byte by byte, reading as much as we can. Such a tool exists, and is called GNU Ddrescue .
Its only con is that it requires MacOS or Linux to run, but that shouldn’t be a problem since there are live CDs available. In particular, there is Knoppix , which has all the tools bundled.
So, first, open the console and try to find out what drives we have. In order to do this, use
fdisk -l on Linux and the
/Applications/Utilities/diskutil list on MacOS. MacOS prefers disk names that start with
/dev/r which are raw disks with buffer-less communication.
Now, as you know drive names:
# get most of the error-free data quickly
./ddrescue -n /dev/old_disk /mnt/sdb1/bad_drive.img rescued.log
# then attempt to get data which is in bad areas
./ddrescue -r 1 /dev/old_disk /mnt/sdb1/bad_drive.img rescued.log
/mnt/sdb1/bad_drive.img is a path to an image file to create. Obviously, it should be on another disk, and you should have at least the same amount of space available as the size of the original disk you are restoring.
Now that is done, we need to actually get our data from the disk image. There is another tool for that called PhotoRec . Again, it is a console tool.
Launch it as
./photorec /mnt/sdb1/bad_drive.img then follow these instructions
. At this point you can try various options as many times as you want since image file is not affected and is on a drive that works, so there is little chance of lost data because of messing with the original drive.
And that’s it! Using these two tools I was able to recover all the precious photos from corrupted SD card.
About the author: Alexander Makarov is an open source software developer based in the Voronezh Region of Russia. You can find out more about him on his GitHub , LinkedIn , Patreon , and Twitter . This post was also published here .