Long linux boot time – haveged to help

I own an old laptop which is powered by the Linux operating system. It was always starting in about 20 seconds, but recently I noticed that I have to wait over two minutes for it to boot. This was rather strange because I was not making any significant changes to the system and it was inconvenient because I like it to start quickly.

The cause

I took a look at the dmesg output looking for the place where the time is wasted. What I found was:

$ sudo dmesg | less
[ 16.899023] IPv6: ADDRCONF(NETDEV_CHANGE) ...
[ 156.757845] random: crng init done

So, it looks like my kernel is wasting over two minutes to initialize random number generator. It surfaced that there is a bug which is exhausting the entropy pool used by the kernel for the random number generator. By default, this entropy pool is refilled by collecting disk operations and such things as mouse moves. It was definitely not working for me.

The solution

Fortunately, there is a simple solution to this issue. There is an application which can be installed and will be generating random numbers for the entropy pool working as a daemon (in the background). So you should simply install it, enable and start.

sudo apt install haveged
sudo systemctl enable haveged
sudo systemctl start haveged

From now on, this daemon will start on every boot, but the most important is that the entropy pool will be filled in the meantime – when your system is working. Once I installed haveged and let it work for some time, my boot time decreased to the usual 20 seconds.

My operating system is Ubuntu 18, but the same issue occurs in Ubuntu 16 as far as I can tell and can be spotted also in other distributions.

6 Replies to “Long linux boot time – haveged to help”

  1. This reduced my boot time from 3 minutes to 9 seconds in Manjaro KDE. Thank you very much!

  2. Interesting. Thank you. I am currently unaffected by the issue but I wonder why this started to happen to you.
    i.e. did you update your kernel? What was it that made it suddenly slow down?

    The reason for asking is I’d like to know if this is something that might crop up in the future for me & others.

    1. The thing is that I’m not sure. There is no clear cause of this. I’m using Ubuntu on various machines and I found this issue only on one of them – Dell laptop 🙂

  3. This happened to me as I upgraded from 18.04 to 20.04. Your solution worked like a charm

Comments are closed.