Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am using GNU ddrescue to recover data from a hard drive with bad sectors to a good drive. It is the same sized drive. I pointlessly used badblocks at first, but it did tell me that I have 204 MB in bad sectors. I should have told it to stop at first error.
The source drive that I am cloning/recovering has windows 10 on it. Some of the bad sectors are in the 2 gigabyte "system reserved" partition. I started the recovery on the whole device (/dev/sda) but I want to skip copying the first system reserved partition (sda1) since I expect to be able to copy this partition from another system with the same build and cpu type. I've done this before on a Server 2008 system.
Question 1: can I clone only sda2 (the "real" 465GB windows OS and data partition) and restart the recovery using the same logfile? Skipping the "SYSTEM RESERVED" partition? Eg ddrescue /dev/sda2 /dev/sdb2 /mnt/windows/ddrescue-log.log
Question 2: How do I know the data is good from sectors that have had read errors on the first pass? If the drive gives ddrescue data, how does it know the data is correct without reading the data more than once and comparing it? Or have I been fooled by Spinrite's documentation (it says it rereads sectors 20 times, but that program hasn't been useful for 20 years, since the days of MFM/RLL drives).
Question 3: Can I run ddrescue again to verify the data is good? Does the log show which blocks are good?
Ultimately, I want to know at which point is my data good?
My recovery is currently on the second pass. My parameters are ddrescue -d -f -r3 /dev/sda /dev/sdb /mnt/windows/ddrescue-log.log and I am using ddrescue version 1.18.1, which is not the latest version 1.20, but is the only version that I can use via the SystemRescueCD live-cd.
I strongly suggest that you study 'info ddrescue'.
Q1. Yes and yes.
Quote:
5 Invoking ddrescue
*******************
The format for running ddrescue is:
ddrescue [OPTIONS] INFILE OUTFILE [MAPFILE]
INFILE and OUTFILE may be files, devices or partitions. MAPFILE is
a regular file and must be placed in an existing directory. If MAPFILE
does not exist, ddrescue will create it.
Always use a mapfile unless you know you won't need it. Without a
mapfile, ddrescue can't resume a rescue, only reinitiate it.
Q2.
Quote:
4 Algorithm
...
The algorithm of ddrescue is as follows (the user may interrupt the
process at any point, but be aware that a bad drive can block ddrescue
for a long time until the kernel gives up):
1) Optionally read a mapfile describing the status of a multi-part or
previously interrupted rescue. If no mapfile is specified or is empty or
does not exist, mark all the rescue domain as non-tried.
2) (First phase; Copying) Read the non-tried parts of the input file,
marking the failed blocks as non-trimmed and skipping beyond them. Skip
also beyond slow areas. The skipped areas are tried later in two
additional passes (before trimming), reversing the direction after each
pass until all the rescue domain is tried. The third pass is a sweeping
pass, with skipping disabled. (The purpose is to delimit large errors
fast, keep the mapfile small, and produce good starting points for
trimming). Only non-tried areas are read in large blocks. Trimming,
scraping and retrying are done sector by sector. Each sector is tried at
most two times; the first in this step as part of a large block read,
the second in one of the steps below as a single sector read.
3) (Second phase; Trimming) Trimming is done in one pass. For each
non-trimmed block, read forwards one sector at a time from the leading
edge of the block until a bad sector is found. Then read backwards one
sector at a time from the trailing edge of the block until a bad sector
is found. Then mark the bad sectors found (if any) as bad-sector, and
mark the rest of the block as non-scraped without trying to read it.
4) (Third phase; Scraping) Scrape together the data not recovered by
the copying or trimming phases. Scraping is done in one pass. Each
non-scraped block is read forwards, one sector at a time. Any bad
sectors found are marked as bad-sector.
5) (Fourth phase; Retrying) Optionally try to read again the bad
sectors until the specified number of retry passes is reached. The
direction is reversed after each pass. Every bad sector is tried only
once in each pass. Ddrescue can't know if a bad sector is unrecoverable
or if it will be eventually read after some retries.
6) Optionally write a mapfile for later use.
Q3. Yes and yes.
Quote:
4 Algorithm
...
The mapfile is periodically saved to disc, as well as when ddrescue
finishes or is interrupted. So in case of a crash you can resume the
rescue with little recopying. The interval between saves varies from 30
seconds to 5 minutes depending on mapfile size (larger mapfiles are
saved at longer intervals).
Also, the same mapfile can be used for multiple commands that copy
different areas of the input file, and for multiple recovery attempts
over different subsets.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.