5

I'm trying to copy data off a rather damaged CD using the following command:

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

However, the 'of' device got disconnected and the dd stopped (output below).

...
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

Can I resume with:

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

Or should the seek/skip numbers be both 1092636, or should skip/seek be different from each other, or something entirely different?

PS I know I'm probably using the wrong command for this, e.g. ddrescue is probably better. But I'm probably stuck with dd now(?). I don't expect any more errors on the output file side of things.

bmcws
  • 115
  • 2
    Just used dd in haste instead of ddrescue! I had guessed the conv=sync would line up the blocks, but I guess not! BTW, the files on the input CD are all videos. I mounted the image and the videos seem to play albeit with some corruption, it seems. Nevertheless, looks like ddrescue is the way to go! – bmcws May 26 '21 at 11:51

2 Answers2

12

You have encountered read errors, so the options conv=sync,noerror have almost certainly altered the stream of data, unfortunately making your output file worthless or at the very least an inaccurate copy.

Each time there is a bad read (short read) on the input, the conv=sync option pads out the block with NUL bytes. The dd command will attempt to continue the input stream from where it left off, but the output now has an unknown number of NUL bytes inserted.

You should stop using dd and use ddrescue, which was created for recovering data from bad media.

Referenced answers for similar topics

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
9

Use ddrescue. It can read damaged media "preserving" damaged parts while dd cannot.

Imagine your original data:

  +-+-+-+-+-+-+-+-+-+-+-+-+
  |a b c d e f g h i j k l|
  +-+-+-+-+-+-+-+-+-+-+-+-+

After damage (X) they look like that:

  +-+-+-+-+-+-+-+-+-+-+-+-+
  |a b c X X X X h i j k l|
  +-+-+-+-+-+-+-+-+-+-+-+-+

What dd conv=sync,noerror will read:

  +-+-+-+-+-+-+-+-+
  |a b c h i j k l|
  +-+-+-+-+-+-+-+-+

What ddrescue will read.

  +-+-+-+-+-+-+-+-+-+-+-+-+
  |a b c 0 0 0 0 h i j k l|
  +-+-+-+-+-+-+-+-+-+-+-+-+

As you can see original message read by dd is skewed and if you produce this way filesystem image it will be rendered unusable. Ddrescue image you are able to mount witout problem which will help you to access undamaged data as usual and damaged to be easily put aside and dealt next.

tansy
  • 741
  • 2
    Thanks for the input, but are you sure about it and have source to back it up? I ask because I saw "conv=sync tells dd to pad each block to the left with nulls, so that if, due to error, the full block cannot be read, the full length of the original data is preserved, even though not all of the data itself can be included in the image." from https://superuser.com/questions/622541/ – xpt Nov 10 '21 at 19:53
  • You can test it on any damaged medium you can find. Easiest option is cd, or old usb drive. Anything. Let us know how was your test going. – tansy Nov 23 '21 at 01:40
  • So you don't have anything to back up your claim "original message read by dd is skewed and if you produce this way filesystem image it will be rendered unusable" then. – xpt Nov 24 '21 at 03:49
  • I shown you experiment which would shore my point, but you did d not do it, nor even considered it. I am not intending to record video with some damaged drive to show you what you can do yourself. You did not do anything, towers that so, Yes, you're right, i don't. – tansy Dec 07 '21 at 20:16