Recovering lost files from faulty disk or storage card

Corrupted or mistakenly formatted sd cards and hard drives can be very frustrating and lead to panic. But relax there are some methods you can use to restore your data.


This guide will only work if your drive is still accessible. Sometimes a hardware failure leads to an inaccessible drive which require a more professional handling of the issue. But there are some professionals out there which can couple with the most challenging tasks, like this guys: https://www.youtube.com/user/hddrecoveryservices


First before you do any more manipulation should you take a step back and do a full bitwise copy of the drive.

In linux there is a command called dd_rescue. It's a fork of the dd command which was first written in 1974 and you can find out more of its history here: https://en.wikipedia.org/wiki/Dd_(Unix). dd_rescue won't stop on IO errors like the original dd command.


The dd command takes two parameters

  • in file
  • out file


The in file parameter should be the drive. Ie, when connecting a drive to a Unix system the all end up under /dev/xdy depending of the type of drive. For me the my connected usb drive got the path /dev/sdb.


The out file parameter should be a file you can write the information to. It could also be another drive which then need to be at least as large as the drive you want to copy from. If you copy to another drive then you are going to overwrite the data that you already have on that drive.


The drive duplication will take some time depending on the size of the drive and the interface you are copying over (usb1/2/3/C or IDE/SATA).


Once you have copied the drive then you can use one or all of the following tools to try to recover the missing or corrupted files:

Test disk: https://www.archlinuxuser.com/2017/07/testdisk-partition-file-recovery.html

Photorec: https://www.tecmint.com/photorec-recover-deleted-lost-files-in-linux/

Foremost: http://foremost.sourceforge.net/


I successfully recovered over 5000 images and 200 videos from a faulty phone memory with these tools. Now I have made multiple backups of these images.