Entry 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
- 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
- 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.