8

I have noticed so keyboard/mouse hanging and other issues since I bought my new computer and installed Ubuntu 11.10.

I researched where increasing the /proc/sys/kernel/random/entropy_avail helps and it does.

Currently I do this by running $ ls -R / in a terminal. Of course this just reads the directory and files.

It does in fact raise it to 4000 plus. Then it drops back down to 300 and 400.

After looking and trying to find a solution, how can I increase the entrophy_avail without manually LSing the hard drives from the terminal?

I must confess that I have been using Ubuntu full time since 8.04 and Windows completely free since Natty. I don't really understand this entropy_avail but my computer seems to do better when it is high at peak usage.

Jorge Castro
  • 70,934
  • 124
  • 466
  • 653
p37307
  • 161
  • 1
  • 2
  • 7

4 Answers4

5

I have the same issue. I found haveged works the best. Simply run

sudo apt-get install haveged -y

and you are done. It will start itself and add entries to start on boot.

Nash0
  • 201
  • 4
  • 7
  • This didn't really do much for me… (cf. [my comment](https://askubuntu.com/q/99144/362789#comment1055519_656208)). – Geremia Dec 31 '15 at 22:12
  • `haveged` worked much better for me than `rngd`/`rng-tools` on a virtual machine. `rngd` reported "can't open any entropy source" and filled entropy too slow (about 100 bits/minute). It could not supply `gpg --gen-key`. On the other hand, `haveged` supplied it fast enough. With `haveged`, `cat /dev/random` will run continuously. – wisbucky Jul 09 '19 at 01:12
4

Try using

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

This worked for me.

Byte Commander
  • 105,631
  • 46
  • 284
  • 425
nobody
  • 49
  • 1
  • 3
    The new `rngd` doesn't have a `-t` flag… – Geremia Dec 31 '15 at 22:04
  • That brought my `entropy_avail` up to a constant ~¾ of the pool size. Is it just tricking the entropy estimation? Invoking `ls -R /` doesn't increase it beyond what `rngd` did. – Geremia Dec 31 '15 at 22:11
  • 6
    That's a really bad idea. It's just filling the kernel entropy pool with entropy coming from the kernel itself. See the warning here: https://wiki.archlinux.org/index.php/Rng-tools – Florin Andrei Jan 17 '17 at 20:56
  • Lol. Yes, don't do that. You're insane. – Owl Aug 23 '19 at 16:08
4

This article here seems to have found a package that will essentially feed the random number generator with the output of the random number generator... essentially generating as much random as you need at the cost of have 'less random' numbers.

The reason that ls -R / works is because the primary source of random bits in linux is hardware noise. ls'ing the whole filesystem generates a lot of that.

The instructions from the other article are reproduced here:

sudo apt-get install rng-tools
sudo vim /etc/default/rng-tools
#Set the value: HRNGDEVICE=/dev/urandom
sudo /etc/init.d/rng-tools start
Huckle
  • 7,128
  • 4
  • 26
  • 41
  • 1
    This is a [bad idea](https://lwn.net/Articles/525459/). There is a reason why cryptosystems like TLS need truly unpredictable random bits. – Sven Marnach May 07 '17 at 13:56
1

Increasing the avilible entropy pool gives more cryptographic random data for things like gpg and openssl to generate encryption keys. The keyboard and mouse do not know or care how much entropy is available, and a lack of entropy should not cause anything to hang other than generating new cryptography keys. In fact, normal use of the keyboard and mouse add to the entropy pool.

psusi
  • 37,033
  • 2
  • 68
  • 106
  • 1
    I admit I had a hard time understanding exactly why the mouse & keyboard need so much random data, but I can image that they need some. I'm assuming that they're wireless and that the random bits are used to modulate the signal somehow. I can imagine that some poor program resulted in the need for lots of needless random bits, draining the pool. – Huckle Jan 28 '12 at 18:06
  • 1
    @Huckle, no, the mouse and keyboard have no need of random data, they are used to *generate* random data. That is why `gpg` tells you to type away on the keyboard when it's trying to generate a new key. If the wireless signal is modulated at all, it is done with hardware, not software. – psusi Jan 28 '12 at 18:13
  • Well, then 'It should have nothing at all to do with normal usage of the keyboard' is probably not worded correctly in the answer, as it does have *something* to do with it. Maybe you meant to say 'It shouldn't prevent normal operation of the keyboard'. – Huckle Jan 28 '12 at 21:07
  • @Huckle, yes, I suppose so. Corrected answer. – psusi Jan 28 '12 at 22:52