0

When typing the command:

dd if=/dev/urandom of=outputfile bs=1G count=1

I should receive a file at the size of 1GB if I understand correctly.

Yet, I receive a file of the following values:

33554431 bytes (34 MB, 32 MiB) copied, 0.27126 s, 124 MB/s

Why is that?

On the system where it works I receive:

1+0 Records in
1+0 Records out

Where the file ends up with 34MB I receive:

0+1 Records in
0+1 Records out

1 Answers1

3

The device /dev/urandom temporarily returned zero bytes (no more data). The dd utility treated that as EOF and stopped. Since you know that /dev/urandom will generate more random data you need to tell dd to reattempt reading input:

dd if=/dev/urandom iflag=fullblock bs=1G count=1

The iflag=fullblock flag is also needed when reading from tools such as zcat that write data in non-block-sized units.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287