4

Almost any tutorial will tell you that to clone a disk on the command line (say, to clone /dev/sda to /dev/sdb) you can use:

dd if=/dev/sda of=/dev/sdb ...and some block size options...

This reads the contents of /dev/sda and writes them to /dev/sdb.

Why can't we simply use cat < /dev/sda > /dev/sdb?

  • I thought I'd just point out the fact that cat /dev/sda > /dev/sdb would work just as well and is simpler. – John Leuenhagen Aug 29 '16 at 2:02
0

Of course you can use cat or cp. But dd has more options such as only backup/restore the bootsector or copy a limited amount of random data from /dev/random.

Wikipedia has a more detailed description of different use cases.

0

cat have less options than dd. With dd you can specify the block size you will use to copy your data, the number of bloc and apply some conversion to them like ucase, lcase, ascii, ebcdic, ... dd have also a noerror conversion flag which allow to continue the copy even if some errors occurs. Here: https://stackoverflow.com/a/150989/3747381 you have comment about their relative efficiency. You can also read this comment: https://stackoverflow.com/a/151081/3747381

  • 1
    Conversion is irrelevant to the use case of cloning a disk drive. – user253751 Dec 17 '15 at 20:21
  • 1
    on the contrary, to clone a disk / partition, you will use the noerror and sync conversion flags... like: dd if=/dev/sda of=/dev/sdb conv=noerror,sync bs=4096 – dervishe Dec 17 '15 at 20:30

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