盲目地将故障驱动器添加到新驱动器

盲目地将故障驱动器添加到新驱动器

我有一个有故障的 320GB 驱动器,在 samish GB 位置有读取错误,但确切位置有所不同。我对错误的可能性很满意,这在这里是不可能的。

首先,我很惊讶我需要conv=sync真正conv=noerror有用,但好吧,我有空闲时间来长新脚。我发现它是因为file -s /dev/sdc*没有为最后一个分区提供任何合理的输出(即与源驱动器相同),它相反data。但是,在添加sync到命令行后,我没有得到任何实际改进:file -s除了第一个分区之外,输出仍然没有任何意义,该分区在 FS 描述部分中不包含错误,因此file -s命令可以正确检测 FS。我确认mount -o ro两个驱动器的复制不稳定,并比较md5sum所有文件的 s (但目录结构本身不稳定)。

我正在尝试以这种方式将其添加到新的更大的驱动器:

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. 

我得到每个不稳定块的输出/part3_log(如预期):

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

对于以下位置的所有块,我得到这个奇怪的输出(预计会有速度差异)/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

引起我注意的是,几乎每个输入记录都被部分读取,而没有报告错误,尽管它们实际上发生了(我在 中看到它们dmesg)。没有报告任何错误sdc(正如预期的那样,这是一个新驱动器)。

那么,我该如何盲目复制故障驱动器,然后重试故障记录呢?我的方法似乎在两点上失败了:

  • 它无法复制数据,而不会在不稳定的块之后发生移位(尽管conv=sync存在)
  • 重试坏块时无法报告错误。

PS我只想用它来做dd。使用ddrescue有问题的 ATM。

PPS 这是 Debian 8.7.1 和 dd 8.23

答案1

尝试 ddrescue (大多数发行版中都是 gddrescue):

GNU ddrescue - 数据恢复工具。将数据从一个文件或块设备复制到另一个文件或块设备,在发生读取错误时尝试首先挽救好的部分。

相关内容