6

I wish to clone a large disk (a 500GB SSD, for what it's worth), and I am leaning toward using cat, as suggested by Gilles here. But what gave me pause is that I do not really know what cat does upon read errors. I know how dd behaves in these cases, i.e. the command

dd if=/dev/sda of=/dev/sdb bs=64K conv=noerror,sync status=progress

does not stop for errors on read, and pads the read error with zeroes (the sync option) so that data stays in sync. Unfortunately, it does so by padding the zeroes at the end of the block to be written, so that a single error in an early 512-byte read messes up the whole 64K of data (even worse with larger, faster block sizes).

So I am wondering: can I do better/differently with cat? Or should I just move on to Clonezilla?

muru
  • 72,889
MariusMatutiae
  • 4,372
  • 1
  • 25
  • 36

2 Answers2

13

cat stops if it encounters a read or write error.

If you’re concerned there might be unreadable sectors on your source drive, you should look at tools such as ddrescue.

Stephen Kitt
  • 434,908
1

If no sectors that are bad or difficult to read,

I would recommend Clonezilla. It is safer because thare are checkpoints (questions if you want to continue)

cat and dd and ddrescue assume that you know exactly what to do and that you double-check before pressing the Enter key. 'They do what you tell them to do without any question, even if you tell them to wipe the family pictures.'

Furthermore, Clonezilla is smart enough to only copy used blocks (and skip free blocks), which makes the cloning much faster.

If you expect sectors that are bad or difficult to read,

I agree with @StevenKitt that ddrescue is a good tool. The info pages contain a good tutorial,

info ddrescue
sudodus
  • 6,421