2

I have a faulty 320GB drive which has reading errors in samish GB positions but the exact positions vary. I am ok with probability of errors, this is out of question here.

First of all I was surprised with that I need conv=sync for conv=noerror being actually useful but ok, I have spare time to grow new foot. I found it because of file -s /dev/sdc* did not give any sensible output for last partitions (i.e. same as for source drive), it said data instead. However, I did not get any practical improvement after I added sync to my command line: the file -s output still makes no sense except for first partition which does not contain errors in FS description section so file -s command detects FS correctly. I confirm erratic copying with mount -o ro for both drives and comparing md5sums for all files (but directory structure alone is erratic).

I am trying to dd it to new bigger drive this way:

dd if=/dev/sda3 conv=noerror,sync bs=1M of=/dev/sdc3 2> /part3_log
grep -oPaz '[[:digit:]]*(?=\+[[:digit:]]+ records out\n)' </part3_log >/part3_log_bads # parsing is ok for this specific case
rm /part3_log_01
for i in $(cat /part3_log_bads); do dd if=/dev/sda3 conv=noerror,sync bs=1M of=/dev/sdc3 skip=$((i-1)) seek=$((i-1)) count=1 2>>/part3_log_01; done # retrying erratic blocks. i-1 because of number of records is written after erratic block was padded and written. noerror does not make any practical difference here. 

I get this output for each erratic block in /part3_log (as expected):

dd: error reading ‘/dev/sda3’: Input/output error
71051+3 records in  <<<<<<<<< second number increments from 0 after each erratic block indicating partial read, this is expected
71054+0 records out
74505519104 bytes (75 GB) copied, 2546,96 s, 29,3 MB/s

And I get this strange output (speed difference is expected) for all blocks in /part3_log_01:

1048576 bytes (1,0 MB) copied, 6,5663 s, 160 kB/s
0+1 records in
0+0 records out
0 bytes (0 B) copied, 6,41877 s, 0,0 kB/s
0+1 records in
1+0 records out
1048576 bytes (1,0 MB) copied, 7,42028 s, 141 kB/s
1+0 records in
1+0 records out

What draws my attention is that almost each input record is read partially while there are no errors reported despite them actually happening (I see them in dmesg). There are no error being reported for sdc (as expected, it's a new drive).

So, ho do I blindly copy faulty drive and then retry the faulty records? My approach seems to fail at two points:

  • it fails to copy data without shift occuring after erratic blocks (despite conv=sync being present)
  • it fails to report errors while retrying bad blocks.

P.S. I would like to do it with dd only. Using ddrescue is problematic ATM.

P.P.S. It's Debian 8.7.1 and dd 8.23

  • You should probably run partprobe after copying over an entire drive so that the kernel knows about the new partition layout. – Mark Plotnick Jul 6 '17 at 16:15
  • @MarkPlotnick I forgot about it but new partition table was in effect after first time I rewritten it. It probably refreshes periodically. I did replug my HDD after my very first attempts and never changed MBR since then so it's definitely not an issue. – Euri Pinhollow Jul 6 '17 at 16:24
2

Try ddrescue (gddrescue in most distros):

GNU ddrescue - Data recovery tool. Copies data from one file or block device to another, trying to rescue the good parts first in case of read errors.

  • I would like to do it with dd unless I absolutely need ddrescue. – Euri Pinhollow Jul 6 '17 at 16:02
  • 1
    @EuriPinhollow you absolutely need to use ddrescue. Really. – roaima Jul 6 '17 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.