Decreasing or emptying the entropy pool

random

I work with virtual machines a lot, and they seem to generally be low on entropy (no mouse or other entropy-generating inputs). A bug with my software has surfaced, and I think it's due to running out of entropy. I want to test it, but it only happens occasionally, and is hard to reproduce.

How can I empty out the entropy pool to test how my software behaves when it has run out?

(Note: I'm calling someone else's code that uses dev/random, so using dev/urandom instead to prevent blocking isn't an option.)

Best Answer

First of all, you should make sure that it's really the depletion of the random pool that produces the bug in your software. You can run cat /proc/sys/kernel/random/entropy_avail to test the available entropy on your system and check if it hits zero.

Secondly, AFAIK (I haven't tested these commands) you can decrease the entropy pool by setting the appropriate variable in /proc. To set it to 32 bits:

echo 32 > /proc/sys/kernel/random/poolsize

or

sysctl -w kernel.random.poolsize=32

Related Question