gddrescue: a tool for recovering data from damaged media
December 12th, 2007 edited by TinchoEntry submitted by John Carlyle-Clarke. DPOTD needs your help, please contribute!
I wanted to recover data from a failing hard drive, and asked on IRC if any good tools existed for Ubuntu. Someone pointed me towards GNU ddrescue (named gddrescue
in Debian and Ubuntu), which is designed for rescuing data from any file or block device.
Don’t confuse this with dd_rescue (package name ddrescue
). GNU rescue is a better tool.
The GNU site describes GNU ddrescue as a data recovery tool, and lists these features:
- It copies data from one file or block device (hard disc, CD-ROM, etc) to another, trying hard to rescue data in case of read errors.
- It does not truncate the output file if not asked to, so every time you run it on the same output file, it tries to fill in the gaps.
- It is designed to be fully automatic.
- If you use the log file feature of GNU ddrescue, the data is rescued very efficiently (only the needed blocks are read). Also you can interrupt the rescue at any time and resume it later at the same point.
- The log file is periodically saved to disc. So in case of a crash you can resume the rescue with little recopying.
- If you have two or more damaged copies of a file, CD-ROM, etc, and run GNU ddrescue on all of them, one at a time, with the same output file, you will probably obtain a complete and error-free file. The probability of having damaged areas at the same places on different input files is very low. Using the log file, only the needed blocks are read from the second and successive copies.
- The same log file can be used for multiple commands that copy different areas of the file, and for multiple recovery attempts over different subsets.
The algorithm of GNU ddrescue is as follows:
- Optionally read a log file describing the status of a multi-part or previously interrupted rescue.
- Read the non-damaged parts of the input file, skipping the damaged areas, until the requested size is reached, or until interrupted by the user.
- Try to read the damaged areas, splitting them into smaller pieces and reading the non-damaged pieces, until the hardware block size is reached, or until interrupted by the user.
- Try to read the damaged hardware blocks until the specified number of retries is reached, or until interrupted by the user.
- Optionally write a log file for later use.
To use it, you need to install gddrescue
, but it is invoked as ddrescue
. This is confusing, but it’s because dd_rescue
had already taken the name.
The syntax is simple and the man and info documents are pretty good. Here is an example session with a data CD (no errors found).
$ ddrescue -v /dev/cdrom Recovered.iso ddrescue.log About to copy 101763 kBytes from /dev/cdrom to Recovered.iso Starting positions: infile = 0 B, outfile = 0 B Copy block size: 128 hard blocks Hard block size: 512 bytes Max_retries: 0 Split: yes Truncate: no Press Ctrl-C to interrupt Initial status (read from logfile) rescued: 0 B, errsize: 0 B, errors: 0 Current status rescued: 101763 kB, errsize: 0 B, current rate: 3801 kB/s ipos: 101711 kB, errors: 0, average rate: 2702 kB/s opos: 101711 kB
Useful links:-
- Interview With GNU DDRescue’s Antonio Diaz Diaz
- Article on drive recovery tools
- Pat Patterson’s article on Ubuntu hard drive recovery
- Manual as a text file
- Ubuntu forums article on data recovery
Related software:-
- Foremost (data recovery) - http://foremost.sourceforge.net
- Advanced Forensic Format - http://www.afflib.org
- Rescubuntu - an Ubuntu Live CD Remix designed for system recovery (includes GNU ddrescue)
- Sysresccd, another Live CD for system rescue, which features GNU ddrescue
- Partedmagic, yet another popular Live CD for drive partitioning and recovery, again featuring GNU ddrescue!
gddrescue
is available in Debian since Etch, and in Ubuntu since Edgy. It was started by Antonio Diaz Diaz in 2004.
December 12th, 2007 at 6:49 pm
Another related multiplatform free software is TestDisk ( http://www.cgsecurity.org/wiki/TestDisk ).
It can recover files from multiple file systems and disk configurations (RAID, LVM, …).
I already tried it successfully on two machines.
There’s another software named PhotoRec, distributed on the same website, but is more oriented on multimedia files, hence its name http://www.cgsecurity.org/wiki/PhotoRec
December 13th, 2007 at 9:54 am
Very useful : thanks !!!
December 14th, 2007 at 6:56 am
Some more notes from my personal tipswiki:
- for CD-ROMs you should probably specific “-b 2048″
- if the disk is failing fast and you want to get the most data out of it on the first try, you should probably use “-n” on the first run. This will avoid splitting error areas. Subsequent runs can use “-r1″ or “-r3″, without “-n”, to retry those error areas.
December 14th, 2007 at 9:24 am
I’d like to mention dvdisaster.
It’s designed for preventing CDs/DVDs fom getting unreadable.
But it can also be used to recover from disks if you did no prevention. In fact I most often use ist to create images from disks.
It also has a good algorithm,
it offers the ability to recover from different drives, maybe reading different parts of the disk and so completing the image. And it has a nice GUI.
It’s in Debian since etch.
Homepage is http://dvdisaster.sourceforge.net
December 14th, 2007 at 12:43 pm
Another related softwares are TestDisk and PhotoRec which are multiplatform.
The homepage of these projects are :
* http://www.cgsecurity.org/wiki/TestDisk
* http://www.cgsecurity.org/wiki/PhotoRec
September 4th, 2008 at 9:01 am
Thanks for providing nice article on data recovery. I have used Stellar Phoenix Windows data recovery to recover my lost partition.This is very good software you can try it.