I am running the following command on an ubuntu system:
dd if=/dev/random of=rand bs=1K count=2
However, every time I run it, I end up with a file of a different size. Why is this? How can I generate a file of a given size filled with random data?
You're observing a combination of the peculiar behavior of
Unless you're designing an OS installer or cloner, you should never use
Most uses of
In general, when you need to use
...it's not difficult to put dd at fault; for example try this code:*
Aside from my comment (at the end of your question), something like this is iteresting to watch... It catches your bytes in file
Move your mouse and watch it speed up.
Then, with me moving the mouse continuously, it took a relatively much shorter 1 minute 15 seconds to collect the same number of bytes.
This shows pretty clearly that collecting entropy is not CPU speed based, but rather it is random events based, and that my Ubuntu system uses the mouse as one of its significant random factors.
I get files of size 213 bytes on that machine. Back to man 4 random:
I get 2048 bytes from every invocation of
I conclude that the difference is due to how much entropy your machine generates between invocations of