ArticleslgStudy

computer science

Ddrescue

Ddrescue is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Ddrescue rather than just read about it. In short: GNU ddrescue is a data recovery tool for disk drives, DVDs, CDs, and other digital storage media. It copies raw blocks of storage, such as disk sectors, from one device or file to another, while handling read errors in an intelligent manner to minimize data loss by scraping good sectors from partially read blocks.

Ddrescue — main illustration
Ddrescue — illustration

Key takeaways

  • Ddrescue belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Ddrescue to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Ddrescue from memory before moving on to harder problems.

Reference excerpt

GNU ddrescue is a data recovery tool for disk drives, DVDs, CDs, and other digital storage media. It copies raw blocks of storage, such as disk sectors, from one device or file to another, while handling read errors in an intelligent manner to minimize data loss by scraping good sectors from partially read blocks. GNU ddrescue is written in the C++ programming language, and is available as open-source software that was originally released in 2004. It is also available in binary form as a component in most Linux distributions.

Description ddrescue uses a sophisticated algorithm to copy data from disk drives, and other storage devices, causing as little additional damage, if they are failing, as possible. It is considered to have the most sophisticated implementation of a block-size-changing algorithm in free and open source software, and is considered an essential data recovery tool. The status of the copy process is recorded in a map file (previously called logfile) that aids in the progress of multiple stages of the recovery algorithm, and facilitates interrupting the recovery, and repeating it as needed to recover more data. The program does not write zeros to the output in place of bad blocks, so that additional errors not encountered previously do not destroy previously recovered blocks. This makes it possible to merge multiple defective copies of CDs or DVDs into one backup file. By virtue of the map file, only the needed blocks are read from the second and successive copies.

Algorithm The algorithm of ddrescue is described in its manual. Broadly:

Every block starts as "non-tried". (Copying) A regular copy in large blocks with a time limit is performed to quickly copy the "good" parts of the medium. The parts that have timed out are retried in reverse with a time limit. Then a forward large-block pass without time limit is applied to the remaining blocks, then a reverse large-block pass. The remaining blocks are considered problematic and "non-trimmed", i.e. candidates for trimming. (Trimming) For each non-trimmed block, copy sector-by-sector from the start to find the first failed position and mark it as a bad sector. Then copy sector-from-sector from the end to find the last failed position. Any edge adjacent to a known bad sector is not considered a candidate for trimming. The remaining sectors are candidates for "scraping". (Scraping) For the remaining "non-scraped" blocks, copy them sector by sector. Failures are marked bad sectors. (Retrying) Optionally go through the remaining bad sectors by reading sector by sector forwards and then backwards, until the retry limit is met. The default is to not retry at all. When interrupted the progress is saved to a mapfile. During startup the mapfile is read to determine what needs to be done.

Fill mode ddrescue also features a fill mode, able to selectively overwrite parts of the output file using a supplied mapfile, using a selector string that describes that state of blocks are to be overwritten. It does not rescue anything. Uses include:

Fill the parts of an image corresponding to bad sectors in the map file with the text "BAD-SECTOR_" repeated many times. Fill the parts of an image corresponding to non-copied parts in the map file with the text "NON-RESCUED-SECTOR_" repeated many times. Fill the parts of a source disk (a block device is a file on *nix systems) corresponding to non-bad sectors in the map with zero, wiping all the good parts before sending it to the manufacturer for warranty replacement. Fill the parts of a source disk corresponding to bad sectors in the map with zero, to force a remap of bad sectors.

Unrelated recovery tools GNU ddrescue is not a derivative of dd which also copies blocks of storage from disk storage, but does not operate in a strategic, algorithmic manner. GNU ddrescue is also distinct from the similarly named program dd_rescue.

See also

Backup Disk cloning GNU Project

Notes

References

External links GNU ddrescue Manual

Illustrations

Ddrescue illustration

Worked examples

Example 1 — a first encounter with Ddrescue

Start with the simplest possible case. Write down what Ddrescue claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Ddrescue before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Ddrescue ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Ddrescue

In research
Ddrescue appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Ddrescue in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Ddrescue is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free data recovery software, Free software programmed in C++, GNU Project software, so understanding it makes those chapters shorter.
In everyday life
Look for Ddrescue outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Ddrescue” →

How to study Ddrescue in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Ddrescue means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Ddrescue out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Ddrescue in simple terms?

GNU ddrescue is a data recovery tool for disk drives, DVDs, CDs, and other digital storage media. It copies raw blocks of storage, such as disk sectors, from one device or file to another, while handling read errors in an intelligent manner to minimize data loss by scraping good sectors from partia…

Why does Ddrescue matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Ddrescue?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Ddrescue.

Tags

  • Free data recovery software
  • Free software programmed in C++
  • GNU Project software
  • Hard disk software
  • Software programmed in C++
  • Software using the GNU General Public License

Keep exploring