I have a great deal of information saved on old CD-Rs, but that may not be the best way to preserve data. Over time, optical media can degrade -- and those old CD-Rs and DVD-Rs may already be on their way to the optical media afterlife. One extremely useful tool for rescuing data on damaged disks and failing hard drives is GNU ddrescue.
You're probably already familiar with the
dd utility. For those who aren't,
dd is standard *nix utility (you'll find many implementations) that performs a low-level copy of data of a disk or file. It's often used these days to write images to USB keys, for example, for folks who want to boot off a USB key. It's also very useful for data recovery -- but it can be frustrating to use if the source media has a lot of errors. If that's the case, you'll want to turn to
What's so great about
ddrescue? Essentially, it expects read errors, and as a result it is designed to run multiple passes and try to reconstruct a disk that's degrading in some fashion.
To start with, you can use
ddrescue with relatively few options:
ddrescue /dev/sr1 filename.iso filename.log
Here, you're telling
ddrescue to copy the device at
filename.iso and save a logfile called
filename.log. Why do you want the logfile? This keeps a record of what the utility has done so far and where it's found errors. It's also a good idea to use this because it allows you to interrupt a job and start over again later without having to start from scratch.
This will start copying the file and give you a status report on the number of blocks rescued, rate of copying and errors (if any). If you're like me and start copying disks before you've been seeing any errors, you may need to make only one pass. But if you do encounter errors, you can take another pass at it using the logfile and hope that
ddrescue can recover the error:
ddrescue -r4 /dev/sr1 filename.iso filename.log
Rinse and repeat as necessary. Note that the
-r option tells
ddrescue how many times to retry before giving up.
If you want to see exactly (or at least in more detail) how GNU ddrescue works, check out the algorithm section of the ddrescue manual. It explains the steps
ddrescue uses to try to rescue data and in what order. You'll probably want to look over the manual anyway to familiarize yourself with
ddrescue as a utility and its other options. It has quite a few options that may come in handy in more complex scenarios.
You might also want to start copying over some of that old optical media right away, even if you're not seeing errors or haven't had a reason to read the disks lately. Although
ddrescue is a very handy and reliable tool, it has its limitations.
Joe 'Zonker' Brockmeier is a freelance writer and editor with more than 10 years covering IT. Formerly the openSUSE Community Manager for Novell, Brockmeier has written for Linux Magazine, Sys Admin, Linux Pro Magazine, IBM developerWorks, Linux.com, CIO.com, Linux Weekly News, ZDNet, and many other publications. You can reach Zonker at firstname.lastname@example.org and follow him on Twitter.