How to recover data from a Damaged Drive or Filesystem
In this article I will tell you how to recover data from such media devices using ddrescue.
According to the software’s man page – GNU ddrescue is a data recovery tool. It copies data from one file or block device to another to rescue data in case of read errors. Honestly, this is a really polite description, GNU ddrescue is far more capable than that. Here are some of its features.
Features of GNU ddrescue
Ddrescue is fully automatic i.e. you don’t have to tell it what to do after every step. It will take an input file and an output file as arguments and while copying data will try to recover the errors.
A good thing about ddrescue is that it won’t overwrite your output file (until explicitly asked for) everytime it runs and will try to fill in the gaps.
Using a Log file with ddrescue makes recovery more efficient. So, if you re-run ddrescue it will scan only the needed blocks. You can even interrupt the rescue anytime and resume it later.
Automatic merging of backups
If you have 2 or more copies of your damaged file or disk, run ddrescue on both of them and point the output to the same file and there is a good chance that you will get an error free file. This is because it is nearly impossible to have errors at same places in all the copies so ddrescue will recover all the data for you.
If you don’t have GNU ddrescue installed you may install it from here (http://ftp.gnu.org/gnu/ddrescue/) or you may install it from your favourite package manager (apt, yum etc). It should be available by the name of gddrescue.
The basic syntax for ddrescue is
If you need to recover data from a damaged drive, say /dev/sda, then use /dev/sda as the input file and since you can’t write to the same disk use another drive as an output file e.g. a USB drive (/media/USB/) file or another drive /dev/sdb.
So your command should look something like this.
ddrescue -r 3 /dev/sda /media/USB/file /media/USB/logfile ddrescue -r 3 infile outfile logfile
where, r –max-retries equals the no. of rescue re-tries when an error is encountered
If you run the above command successively with the same log file then ddrescue will read only the gaps (with errors) in the file.
So, next time you damage a CD, hard disk etc, just use GNU ddrescue to recover the data for you.
Documentation file is located HERE