Faster recovery from a disk with bad sectors
Solution 1:
First, for the software to use: you could try using ddrescue
instead of dd
.
ddrescue
has a switch to do only a limited number of retries. It can also use a logfile, so it records which blocks were bad. If you later feel like doing more retries, you can use the same logfile to run ddrescue
again with different options (like more retries) and it will retry only the necessary blocks.
Example usage:
# ddrescue -n /dev/sda /dev/sdb rescue.log
# ddrescue -r1 /dev/sda /dev/sdb rescue.log
From the ddrescue
info-page:
-n, --no-scrape
Skip the scraping phase. Avoids spending a lot of time
trying to rescue the most difficult parts of the file.
-r, --retry-passes=<n>
Exit after given number of retry passes. Defaults to 0.
-1 means infinity. Every bad sector is tried only once
in each pass. To retry bad sectors detected on a previous
run, you must specify a non-zero number of retry passes.
Here are some additional sources to using ddrescue
:
info ddrescue
- http://www.forensicswiki.org/wiki/Ddrescue
Edit
In case the HDD itself is taking too long, you can try to enable a feature called TLER (Time Limited Error Recovery) or CCTL (Command Completion Time Limit). Not all HDDs have it, but you can use it to limit the time on the HDD controller itself. This approach can be combined with using ddrescue
, of course.
Linux has a tool called smartctl
(in the smartmontools
package).
To check the current setting ("disabled" means an unlimited time, which you do not want):
# smartctl -l scterc /dev/sda
To set it to a fixed value (5.0 seconds in this example. Setting it to 0 disables TLER):
# smartctl -l scterc,50,50 /dev/sda
Source for TLER: http://en.wikipedia.org/wiki/TLER
Solution 2:
For a fast and quick option to rescue the disc you can use a sh script file and run the file with sh. It contains this line, just repeat sudo ddrescue
and sleep 3
few more times. The sleep is used to make the drive rest some seconds:
#! /bin/sh -e
sudo ddrescue -d -r0 -e +0 -T 1s -n /dev/drivepartition file.img log.logfile
sleep 3
The options used above:
-
-r0
: with no retries -
-e +0
: exit on first error -
-T 1s
: exit with 1 second fail read -
-d
: Direct I/O -
-n
: no scrape
You can use -R
after finish with option -A
once, that will reverse and remove all errorsize and start again backwards. Means it will read errors differently.