How to recover data from a Damaged Drive or Filesystem
In the previous article I told you a couple of methods to recover a lost partition. This is the case when you have a fine working hard drive. Now, what if the media concerned(CD, DVD, Hard Disk etc) is damaged. In this article I will tell you how to recover data from such media devices using GNU 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 trying hard 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 but 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 for the same output file and there is a great chance that you may get an error free file. This is because it is pretty 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 or you may install it from your favourite package manager (apt, yum etc), it will be available by the name of gddrescue.
The basic syntax for ddrescue is
[shredder12]$ ddrescue <options> input_file output_file <logfile>
e.g. if you need to recover data from a damaged drive /dev/sda then use it as an input file and since you can't write on the same disk use another as an output file e.g. a USB drive /media/USB/file
so, finally your command should look something like this.
[shredder12]$ ddrescue -r 3 /dev/sda /media/USB/file /media/USB/logfile
where,
r --max-retries 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. don't freak out just use GNU ddrescue to recover the data for you.



























Post new comment