How to feed the entropy pool for random numbers (Unix)

Last edited on

A process can hang for a few minutes, when it reads from /dev/random. Typically this occurs for secure socket connections, and when the kernel cannot get random events from mouse moves or key presses. So, clearly, this can happen when running a test suite with multiple test cases.

The size of the entropy pool can be retrieved with:

cat /proc/sys/kernel/random/entropy_avail

Another clue can be to look at whether any of the files the AUT has open includes /dev/random. This can be done as follows (and where is replaced with the actual process ID):

ls -l /proc/<pid>/fd

Remember to ssh into the machine, so that the entropy pool isn't affected by your typing.

It is possible to feed the pool with pseudo-random numbers using rngd as root:

rngd -r /dev/urandom -o /dev/random -f -t 1

On Debian systems, rngd is in the rng-tools package; on Red Hat systems (including Fedora), it is in the rng-utils package.