恢复 dd 读取错误,跳过/寻找数字

bmc*_*cws 3 linux dd

我正在尝试使用以下命令从损坏的 CD 上复制数据:

dd if=/dev/sr1 of=IDT.img conv=sync,noerror status=progress

但是,“of”设备断开连接,dd 停止(输出如下)。

...
dd: error reading '/dev/sr1': Input/output error
1074889+17746 records in
1092635+0 records out
559429120 bytes (559 MB, 534 MiB) copied, 502933 s, 1.1 kB/s
dd: writing to 'IDT.img': Input/output error
1074889+17747 records in
1092635+0 records out
559429120 bytes (559 MB, 534 MiB) copied, 502933 s, 1.1 kB/s
Run Code Online (Sandbox Code Playgroud)

我可以继续:

dd if=/dev/sr1 of=IDT.img conv=sync,noerror status=progress seek=1092635 skip=1092635

或者搜索/跳过数字应该是两个1092636,还是跳过/搜索彼此不同,或者完全不同?

PS 我知道我可能为此使用了错误的命令,例如 ddrescue 可能更好。但我现在可能被 dd 困住了(?)。我不希望在输出文件方面出现更多错误。

tan*_*nsy 9

使用ddrescue。它可以读取损坏的介质并“保留”损坏的部分,而 dd 则不能。

想象一下你的原始数据:

  +-+-+-+-+-+-+-+-+-+-+-+-+
  |a b c d e f g h i j k l|
  +-+-+-+-+-+-+-+-+-+-+-+-+
Run Code Online (Sandbox Code Playgroud)

损坏后 ( X) 它们看起来像这样:

  +-+-+-+-+-+-+-+-+-+-+-+-+
  |a b c X X X X h i j k l|
  +-+-+-+-+-+-+-+-+-+-+-+-+
Run Code Online (Sandbox Code Playgroud)

dd conv=sync,noerror 将读取以下内容:

  +-+-+-+-+-+-+-+-+
  |a b c h i j k l|
  +-+-+-+-+-+-+-+-+
Run Code Online (Sandbox Code Playgroud)

ddrescue 将读取什么内容。

  +-+-+-+-+-+-+-+-+-+-+-+-+
  |a b c 0 0 0 0 h i j k l|
  +-+-+-+-+-+-+-+-+-+-+-+-+
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,dd 读取的原始消息是倾斜的,如果您以这种方式生成文件系统映像,它将变得不可用。您可以安装 Ddrescue 映像而不会出现任何问题,这将帮助您像往常一样访问未损坏的数据,并且可以轻松地将损坏的数据放在一边并进行下一步处理。

  • 感谢您的意见,但是您确定并且有来源支持吗?我问是因为我看到 _"conv=sync 告诉 dd 用 null 向左填充每个块,这样,如果由于错误而无法读取整个块,则保留原始数据的完整长度,即使不是所有数据本身都可以包含在图像中。”_来自 https://superuser.com/questions/622541/ (2认同)

roa*_*ima 6

您遇到了读取错误,因此选项conv=sync,noerror几乎肯定会改变数据流,不幸的是使您的输出文件毫无价值,或者至少是不准确的副本。

每次输入出现错误读取(短读取)时,该conv=sync选项都会用 NUL 字节填充块。该dd命令将尝试从停止的地方继续输入流,但输出现在插入了未知数量的 NUL 字节。

您应该停止使用dd和使用ddrescue,它是为从坏媒体中恢复数据而创建的。

类似主题的参考答案