What is the difference in using cp and dd when cloning USB sticks?
In this case, the difference is that dd
is constrained to reading 4096-byte blocks at a time, since you have used bs=4096
. The likely effect is that dd
will be much, much slower than cp
. Try with a larger block size (10M
, 50M
?).
The particular buffer size that's best suited for the current devices might be different from cp
's (or cat
's). You can't easily control cp
's buffering. dd
's utility shines when:
- you have very large devices to copy, so that experimenting to determine the best block-size is worthwhile.
- you have to copy only part of a disk. You can specify
count
to limit how many blocks are copied. - you want to resume an interrupted copy. You can't do so with
cp
, but you can try withdd
, by using theseek
andskip
options. -
you want to pipe it to the standard input of something (admittedly,
cat
will work here too):dd if=/dev/sda bs=10M | ssh host dd of=/dev/sdb
dd
usefulness is very well discussed in this Unix and Linux post:
dd vs cat — is dd still relevant these days?
Related videos on Youtube
![MrWm](https://i.stack.imgur.com/JZ2Nf.png?s=256&g=1)
MrWm
Updated on September 18, 2022Comments
-
MrWm almost 2 years
I found that there are at least two methods to clone a USB stick: (with
/dev/sdb
as the source while/dev/sdc
the target)Cloning with
cp
:sudo cp /dev/sdb /dev/sdc
Cloning with
dd
:sudo dd if=/dev/sdb of=/dev/sdc bs=4096
Are there any significant differences between the two commands and why is dd preferred over cp?