6

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?

user253751
  • 2,266

2 Answers2

3

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

dervishe
  • 465
  • 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
2

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.

tastytea
  • 430