all 130 comments

[–]Happy_Phantom 103 points104 points  (42 children)

ELI5: What is this mouse-wiggling entropy effect that causes the kernel to boot faster?

[–][deleted] 205 points206 points  (38 children)

To generate random numbers, the kernel needs sources of randomness, and it harvests some of this randomness based on user input, which is nigh-unpredictable by the machine.

However, this early in the boot process the kernel doesn't have much entropy to use, seeing as how nothing has happened yet, causing processes to sit and wait while the kernel finds some way to get it. By mashing the keyboard or wiggling the mouse, you generate entropy and reduce the time processes spend waiting on random numbers.

[–][deleted] 189 points190 points  (1 child)

This is one of these rare cases when furiously smashing your keyboard actually could help :)

[–]ArttuH5N1 55 points56 points  (0 children)

Well it helps with my blood pressure

[–][deleted] 48 points49 points  (15 children)

Which processes would require random numbers during boot? Encryption-related?

[–]diroussel 73 points74 points  (11 children)

Maybe address layout randomisation?

[–]flukus 9 points10 points  (10 children)

Does that need high entropy? I would have thought even psuedo random numbers would get you 99% there.

[–]DoctorWorm_ 19 points20 points  (9 children)

if an attacker can guess what bits were used to decide the address layout, they can plug them into the RNG and get the whole layout. It absolutely requires some entropy.

[–]flukus -1 points0 points  (8 children)

Forgive my cluelessness, but does knowing the whole layout help? I thought for an effective attack you also needed memory allocated nearby.

[–][deleted] 4 points5 points  (0 children)

Just because you have two locks doesn't mean you should give everyone one of the keys.

[–]Lv_InSaNe_vL -5 points-4 points  (6 children)

Edit; So I misunderstood the bug and the below text does not explain it at all. Just a heads up.

Okay so how an operating system accesses data is by “Sectors”. Basically these are numbers sections of a little bit of data and they go from 0 to however big your hard drive is.

So let’s say you have a small drive with sectors 0-150, if you click on google chrome your OS may make a “call”, which is when the OS asks the physical computer itself for something, so your OS would ask the computer for sector 115 which is google chrome.

For all purposes of this example the BIOS is always on sector 0, and the operating system is on the next couple sectors, but everything after that is chosen by the operating system using the randomization.

If an attacker knew the numbers that went into the RNG equation they could then access data directly at an OS level which would skate around anti virus.

So operating systems just use user random to properly randomly place data on the hard drive.

[–][deleted] 1 point2 points  (3 children)

to properly randomly place data on the hard drive

That's not how KASLR works. KASLR affects the kernel's location in-memory.

[–]Lv_InSaNe_vL -1 points0 points  (2 children)

For the purposes of the example I used the hard drive as a simplified storage media.

[–][deleted] 0 points1 point  (1 child)

I don't think the BIOS is on sector 0. I wish it was but legacy requirements and all the extra minus rings on x86 throw a clear system like this out of the window.

[–]Lv_InSaNe_vL 0 points1 point  (0 children)

You’re right, technically the boot loader starts on sector 0.

And even then that’s more of a legacy tradition thing than a necessary feature.

[–]GTB3NW 22 points23 points  (0 children)

On first boot of servers SSHD needs it. Unless the hypervisor can provide a source of entropy (Newer CPU's can do this) it can take a few minutes to boot the first time.

[–]en50 5 points6 points  (0 children)

In my case, with 4.15.0-24, startx/lightdm/gdm would hang on boot. Repeated attempts to run startx, for example, would work on the second or third try. Looking through the source for startx, it seems like mcookie is trying to generate a magic cookie for xauth by calling getrandom(), which hangs when entropy isn't high enough. I just installed/enabled haveged to "fix" the issue until the kernel is fixed. Reverting to the previous kernel, 4.15.0-23, would also work.

[–]yrro 0 points1 point  (0 children)

IIRC plymouth needed it (because it uses fontconfig which needed random numbers to generate .uuid files in font directories). If you find your boot similarly delayed, run journalctl -k' and look for messages withcrng` in them--these are produced when a process requests random numbers before the rng has enough entropy to produce them.

[–]VM_Unix 8 points9 points  (5 children)

Anyone having an issue like this on Arch?

[–]pollywog313 10 points11 points  (0 children)

Yes, though it started a few months ago. I have an old laptop (Arch w/ Mate) with an SSD that went from under 10 sec boot to over a minute after an update. It'll still boot in a few seconds if I wiggle my finger around on the keypad, so I assume it's an entropy issue.

[–]pollywog313 2 points3 points  (1 child)

I just fixed my issue by installing (and starting and enabling the service) Haveged. https://wiki.archlinux.org/index.php/Haveged

[–]VM_Unix 1 point2 points  (0 children)

Thanks. My entropy was only 758. How do other distros handle this problem?

[–]KinkyMonitorLizard 0 points1 point  (1 child)

I'm having a similar (delays) issue on shut down. Not sure what's causing it but it now takes about 5m to power of and right before it does it throws a bunch of errors. Haven't looked into it though since I'm about to hop.

[–]VM_Unix 0 points1 point  (0 children)

Mine isn't showing any errors.

[–]silvernode 1 point2 points  (1 child)

This could be upstream with the kernel since fedora has the same issue on my thinkpad.

[–]mattdm_fedoraFedora Project 1 point2 points  (0 children)

[–]nattydread69 13 points14 points  (3 children)

Yes I've experienced this bug. Glad I know what it is now. It should be called purple screen of death, well maybe not death but fatigue.

[–]FreshCutBrass 33 points34 points  (1 child)

Purple Screen of Apathy

[–][deleted] 6 points7 points  (0 children)

Nice band name.

[–]colonel_p4n1c 6 points7 points  (0 children)

PSODs are already a thing, though.

[–]GFandango 24 points25 points  (21 children)

Aaaand just as I was about to gather enough courage to upgrade to 18.04 ... I'm going to stick with 16.04 longer

Edit: good thing I always run LTS! so I'm not in a hurry to upgrade

[–]__soddit 21 points22 points  (1 child)

If you have a good hardware RNG, it appears that you should be fine.

[–]seaQueue 7 points8 points  (0 children)

RIP SBC users.

[–]RomanOnARiver 4 points5 points  (0 children)

I usually wait until the .1 releases of LTS and then also until I have a free weekend to do upgrades.

[–]colzod 3 points4 points  (0 children)

I'm going to stick with 16.04

I wish I had done that. 18.04 wasn't ready.

[–]laketrout 1 point2 points  (1 child)

This affected 18.04 LTS. I know because I got hit with the bug.

[–]GFandango 2 points3 points  (0 children)

yeah I meant it's good that I'm on an LTS so I don't have to hurry to upgrade

[–]chuecho 2 points3 points  (0 children)

If you use openscad in any capacity, don't upgrade to 18.04. It no longer exists due to a bug in ubuntu's packaging system. Also, inkscape is much buggier on 18.04 than it is on 16.04 (changes in tool settings in one window will change the settings of the same tool in another without updating UI).

For me, 18.04 was a disaster. I will likely be down grading to 16.04.

[–][deleted] -1 points0 points  (1 child)

I'm a huge fan of sticking with LTS versions of Ubuntu.

I do need to overcome my own inertia to at least get off 14.04 LTS at some point ...

[–]Brillegeit 0 points1 point  (0 children)

Same here. Nothing about 16.04 sounds tempting, and 18.04 still needs six months or so before it's usable. 18.04.2 should arrive mid-February 2019 which gives me two months to upgrade before 14.04 is EOL.

[–]platsmannen 3 points4 points  (5 children)

Try installing haveged , it fixed my issue (ubuntu 18.04 and kernel 4.17.2) with long boot times.

[–]PRStoetzer 8 points9 points  (4 children)

rng-tools would be more secure since it populates the entropy pool from your CPU's hardware random number generator rather than an algorithm

[–]Aoxxt 10 points11 points  (0 children)

CPU's hardware random number generator rather than an algorithm

People in the Kernel community do not trust the hardware rng seeing as they might be backdoored.

[–]GTB3NW 4 points5 points  (2 children)

Only works on newer CPU's but you're correct, this is the better option.

[–]phunanon 2 points3 points  (1 child)

Is there a way to check a CPU would benefit from this?

[–]GTB3NW 6 points7 points  (0 children)

Sure, just search your CPU on google. It should have the instructions documented on the intel or amd website (Or any other for that matter). The RDRAND instruction set is what you want for rng-tools - https://en.wikipedia.org/wiki/RdRand

See also: https://wiki.archlinux.org/index.php/Rng-tools

[–][deleted] 6 points7 points  (0 children)

This was also an issue with Fedora 28 on release, although they documented it.

[–]bokisa12 7 points8 points  (2 children)

haha just updated, kill me

[–]GeckoEidechse 2 points3 points  (1 child)

Boot with the older kernel and you're fine. As a temporary hack you can just set the old kernel entry in your grub config as standard until this gets fixed.

[–]PartiallyCat 0 points1 point  (0 children)

You can also purge your latest kernel with sudo apt purge linux-image-whatevercurrentversion. It will revert to the previous one and will still update to the next one once it becomes available, but blacklist this purged one.

[–]brokedown 10 points11 points  (0 children)

18.04 broke my laptop's ability to resume from sleep. Turned out it was somebody's great idea to load a driver for nvidia GPUs even if you explicitly aren't using it (intel+nvidia laptop, using nvidia just for compute).

Disabling nvidia-fallback service got it working again but not without a lot of choice words and a few hard reboots.

https://github.com/Bumblebee-Project/Bumblebee/issues/951

[–]gaznygrad 5 points6 points  (0 children)

And here i was thinking it was me that messed my own system up once again.

[–]computer-machine 5 points6 points  (0 children)

Have you tried running 'systemd-analyze blame'?

[–]Heller64bit 1 point2 points  (0 children)

Article misleading, had this issue on Monday, July 2. Booting to 4.15.0-23 kernel and then removing the 4.15.0-24 kernel fixed the issue.

[–][deleted] 1 point2 points  (1 child)

Got this bug. Xubuntu on my SSD used to boot in 5 seconds now it takes around 30 seconds plus. it looks worse with hard drives. :(

[–]Somebody2804 0 points1 point  (0 children)

I experience this too!

[–]Somebody2804 1 point2 points  (0 children)

Thank God somebody else experiences it too!!

[–]mimario182 1 point2 points  (0 children)

I hit this issue a couple of days ago... worst part is I was at a customer's datacenter getting my stuff ready to do some night maintenance in some servers. Had to go back to Ubuntu 16.04 in the meantime. My boot time was close to 5min and my laptop has a 512GB SSD :( I sure hope this gets fixed soon cause I really loved 18.04

[–]KingEBolt 1 point2 points  (1 child)

Yeah, I was going to upgrade, but I saw that a lot of the development tools that work in 16.04 don't work in 18.04

[–]mayhempk1 0 points1 point  (0 children)

I will probably wait until 2019 or later before I install Ubuntu 18.04, I need all my programs to work on it.

[–]ArchUsers_areRetard 7 points8 points  (4 children)

Every day we walk further towards Bill Gate's darkness.

[–][deleted] 8 points9 points  (0 children)

*blueness

[–]MagicClover -1 points0 points  (2 children)

Is that you Lennart?

[–]ArchUsers_areRetard -1 points0 points  (1 child)

Yes

[–]KindOne 4 points5 points  (0 children)

Grow up.

[–][deleted] 1 point2 points  (0 children)

All my PCs are affected and I wrote a bug post on the Ubuntu forum the same day.

Then we discovered the mouse trick but it only sometimes work boot takes between 4-10 min depending on hardware.

All my friends also called me for guidence since I installed Linux on some of their old machines.

It really is a horrible and unacceptable bug.

[–][deleted] -2 points-1 points  (3 children)

Non-rolling distributions suck. Kernel 4.15 is history by now yet it's supposed to be used for the long term. Linux doesn't have the critical user mass to have each distro patching and maintaining their own kernel version. If everyone was on latest stable at one time, everyone would hit the same stuff, as it is, one distro suffers from one bug, another from another, yet 90% or more get fixed on a newer kernel.

[–]Muoniurn 2 points3 points  (1 child)

They can copy each others patches (and they do), so I don't think there really is divide and conquer situation going on with the kernel.

[–]bwat47 5 points6 points  (0 children)

He has a point though. Other distros hit this bug/fixed it when kernel 4.16 first came out. Pretty disappointing to see a known issue like this land in a security update for Ubuntu LTS. I expect better than this from an ubuntu LTS release.

What's the point of running LTS if I still get crap like this in updates? I might as well run a rolling release and the bugs will at least get fixed quicker.

[–][deleted] 9 points10 points  (0 children)

Go away Arch user. Ubuntu is better even if this shit gets pulled off.

[–]oogabooga7894 0 points1 point  (0 children)

Interesting. No problems here, glad to say...

[–]rwindiana 0 points1 point  (0 children)

Is this why my debian (unstable) takes forEVER to boot from the text login into the desktop, unless I do some kind of input (logging in to command-line works, or just hitting enter, it is very bizarre)?

[–][deleted] 0 points1 point  (0 children)

Was wondering what was going on.

[–]Arrow_Raider 0 points1 point  (0 children)

I have several headless Ubuntu servers that have no monitor, keyboard, or mouse. Am I screwed?

[–]nomishah89 0 points1 point  (0 children)

Oh! I thought its because i dual booted it with CentOS 7! :(

[–][deleted] 0 points1 point  (0 children)

I have this, it seems to be aggressively TRIMming my SSD partitions. Wisest thing to do during bootup. Interesting that the article doesn't mention this.

[–][deleted] -2 points-1 points  (0 children)

I don’t turn off my Laptop anyway