1

I am reading many tutorials about the dd command. There are some examples including the bs and count parameters. Some of them where each one is isolated over the other and other where both are used together, but is not very clear the explicit relation about their values.

At a first glance seems enough and straight use only bs - and of course taking in consideration that count by default works with 512 bytes, it because bs by default is 512 bytes. It such as: bs=512 count=#.

Question #1:

  • When and why is mandatory use both together?

According with some research, a block has a size of 512 bytes. For example - not sure if are valid:

bs=1M   count=10
bs=1M   count=5
bs=1.5M count=7

Extra Question #2

  • Is there an explicit relation and rate for the values used for them together?

It for example to know if - bs=1M count=10 - bs=1M count=5 - bs=1.5M count=7 - each one are correct or not - and why.

Note: I am assuming there is a kind of rate or rule to define the values when they are used together and therefore avoid to put any random value to see what happens - and harm the disk for a failed experiment. Correct if I am wrong.

Reason: because the dd command must be use it very carefully I want have very clear the use of them, isolated and together. Of course with the correct values. It is the reason to create this question.

Goal until now it is mentioned in many tutorials about to create a swap file - in my case for Ubuntu. How was not clear the dd syntax, I did do a research of this command and knew the other features, convert and copy

Manuel Jordan
  • 1,728
  • 2
  • 16
  • 40

1 Answers1

3

When and why is mandatory use both together?

It's important to know what your goal is. Without supplying count, dd will copy until EOF is reached (which for some block devices, like /dev/zero, will never be the case).

Otherwise, dd will copy count blocks of size bs.

Is there an explicit relation and rate for the values used for them together?

This once again depends on your task. It can be beneficial to tune bs for speed, and count can be used to only copy a part of something.

To make things maybe a bit more clear, the following examples will all write a 1024 byte file.

dd if=/dev/zero of=/tmp/testfile count=2
dd if=/dev/zero of=/tmp/testfile bs=1k count=1
dd if=/dev/zero of=/tmp/testfile bs=128 count=8

For more information, see the coreutils manual entries regarding block size and dd invocation

Panki
  • 6,664