The bs= argument is just an upper bound for the buffer/block size. In fact, with such a large bs (1G) and when reading from a special file (urandom), a "short read" is very likely to happen, with the result that the created file may be smaller (even much smaller) than 32 GB. What you need is the iflag=fullblock argument to dd, which has the desired effect of actually filling the buffer/block to the specified size.
However, I would strongly recommend to not use such a low-level tool as dd for this purpose.
Instead, head -c ... /dev/urandom > file is easier to use and much less of a footgun.
Even better, if you don't actually need the file to be filled with random content, fallocate -x is a much faster alternative (orders of magnitude faster) on filesystems that support the fallocate system call.
This invocation of
dd
to create a random file is not guaranteed to do what you expect it to do (I assume the goal is creating a 32 GB file).https://github.com/usnistgov/ndn-dpdk/blob/311de078aa4dc3ea28db5f8858e70a1bef7b9ccd/sample/benchmark/README.md?plain=1#L112
The
bs=
argument is just an upper bound for the buffer/block size. In fact, with such a largebs
(1G) and when reading from a special file (urandom), a "short read" is very likely to happen, with the result that the created file may be smaller (even much smaller) than 32 GB. What you need is theiflag=fullblock
argument todd
, which has the desired effect of actually filling the buffer/block to the specified size.However, I would strongly recommend to not use such a low-level tool as
dd
for this purpose. Instead,head -c ... /dev/urandom > file
is easier to use and much less of a footgun.Even better, if you don't actually need the file to be filled with random content,
fallocate -x
is a much faster alternative (orders of magnitude faster) on filesystems that support thefallocate
system call.