I've read many guides and forum posts describing how to use dd
, but one thing I've noticed is that people always use different values for the bs=
, count=
and seek=
switches.
Please can someone explain what these switches do exactly (the man page isn't very detailed), and explain what the best settings for them are for different tasks, such as creating files from /dev/random or /dev/zero, and overwriting partitions and external drives.
Best Answer
I really don't know how to explain this better than the manpage does.
bs=
sets the blocksize, for examplebs=1M
would be 1MiB blocksize.count=
copies only this number of blocks (the default is for dd to keep going forever or until the input runs out). Ideally blocks are ofbs=
size but there may be incomplete reads, so if you usecount=
in order to copy a specific amount of data (count*bs
), you should also supplyiflag=fullblock
.seek=
seeks this number of blocks in the output, instead of writing to the very beginning of the output device.So, for example, this copies 1MiB worth of
y\n
to position 8MiB of the outputfile. So the total filesize will be 9MiB.Since you mention
/dev/random
and overwriting partitions... it will take forever since/dev/random
(as well as/dev/urandom
) is just too slow. You could just useshred -v -n 1
instead, that's fast and usually available anywhere.