When is dd suitable for copying data? (or, when are read() and write() partial) points out an important caveat when using count
: dd
can copy partial blocks, so when given count
it will stop after the given number of blocks, even if some of the blocks were incomplete. You may therefore end up with fewer than bs * count
bytes copied, unless you specify iflag=fullblock
.
The default block size for dd is 512 bytes. count
is a limit; as your question hints it isn't required when copying a device of finite size, and is really intended to copy only part of a device.
I think there are two aspects to consider here: performance and data recovery.
As far as performance is concerned, you ideally want the block size to be at least equal to, and a multiple of, the underlying physical block size (hence 2048 bytes when reading a CD-ROM). In fact nowadays you may as well specify larger block sizes to give the underlying caching systems a chance to buffer things for you. But increasing the block size means dd
has to use that much more memory, and it could be counter-productive if you're copying over a network because of packet fragmentation.
As far as data recovery is concerned, you may retrieve more data from a failing hard disk if you use smaller block sizes; this is what programs such as dd-rescue
do automatically: they read large blocks initially, but if a block fails they re-read it with smaller block sizes. dd
won't do this, it will just fail the whole block.
dd bs=4m iflag=fullblock
vsdd bs=1111
and notice the substantially higher data rates the former will give you. This is because the former aligns with natural block sizes on the SD card, while the latter requires the SD controller to do much reading, copying and reflashing to write partial physical blocks. The importance offullblock
should not be underestimated, by the way, as without it,bs
is only a maximum and partial reads could lead to persistent subsequent misalignments. – Jason C Mar 10 '15 at 04:12