/dev/random empty?

Robert Connolly robert at linuxfromscratch.org
Mon Jul 18 21:22:56 PDT 2005


On July 19, 2005 12:02 am, Darren McGrandle wrote:
> Gentlemen,
>
> I've searched through the list archives, but haven't found any
> solution to this issue.  With my shiny new hlfs build, my
> /dev/random appears to be totally drained.  /dev/urandom and
> /dev/frandom work fine, but 'cat /dev/random' just sits there
> infinately.
>
> Any thoughts?

/dev/random is a blocking device. That means if its empty you, or your 
program, will have to wait until it refills. urandom and frandom are 
non-blocking, that means they never run out and you only have to wait for the 
speed of the device, which may be 0.5MB per second or so (frandom is faster 
than urandom).

Try:
cat /proc/sys/kernel/random/entropy_avail

this will tell you how much entropy you have in core memory, and how 
much /dev/random has available.

Most entropy comes from your mouse, if you have one. The keyboard and network 
traffic is also used. The kernel is coded to decide how to use entropy 
sources, like the keyboard and mouse. You can use audio-entropyd, or 
hw_random, if you have those devices, to refill your random device 
constantly.

Also see:
http://www.linuxfromscratch.org/hints/downloads/files/entropy.txt

In other words, what you are saying is normal, especially if you 
cat /dev/random. Think of /dev/random as a swimming pool, or sink full of 
water. It's easy to drain, and you have to wait a bit to let it refill 
depending on how much input sources you have.

robert



More information about the hlfs-dev mailing list