I started on this trend of improving my boot time. I currently use Arch Linux so this is pretty customizable. There are a couple of things you can do to improve boot times, including slimming down the kernel, changing the boot loader, and adjusting Systemd.
First, The Boot loader
The reason I started with my boot loader was because I tried to compile a custom kernel. When I created my custom kernel I started by deactivating a bunch of random modules. This left me with a non-booting kernel. In the process of trying to fix my kernel I messed up my grub install by deleting the Bios entry.
I went back to the default arch kernel and started with changing my boot loader from GRUB to EFISTUB. The reason being why do I need a boot loader when my Bios can load the kernel already. My computer doesn’t need to play a game of hot potato.
It took me a couple tries to get it setup because I was looking at the wrong docs and it wasn’t liking my
UUID for the the rootfs partition. Once I got it all configured I worked with Thor to create a set of scripts to make it easier to adjust my kernel options.
This left me with an Arch install that didn’t have a boot loader. So the speed up was as expected, no GRUB prompt.
Second, Actually Trying to Optimize boot
Now that I’m really hyped to improve my Thinkpad’s’ boot time, I start investigating the causes of my boot. Let’s use this guide on the arch wiki.
$ systemd-analyze startup finished in 6.338s (Firmware) + 31ms (loader) + 3.627s (kernel) + 7.285s (userspace) = 17.282s total graphical.target reached after 7.285s in userspace.
Ouch 17.282 seconds that’s rough. Let’s try to get the under 10 seconds.
So then let’s see who is causing this big slow down:
$ systemd-analyze blame | head 5.449s apparmor.service 860ms systemd-logind.service 692ms lvm2-monitor.service 471ms dev-nvme0n1p5.device 407ms systemd-machined.service 314ms var-lib-snapd-snap-slack-12.mount 313ms var-lib-snapd-snap-core18-941.mount 299ms systemd-timesyncd.service 296ms var-lib-snapd-snap-discord-93.mount
“Uff da” AppArmor takes forever. How can I reduce that? Let’s see what the arch wiki has on AppArmor.
I try those fixes and
apparmor time drops to 2.46s, which helps. I also see a lot of issues with snaps so let’s get rid of some snaps.
$ snap list Name Version Rev Tracking Publisher Notes core 16-2.39 6964 stable canonical✓ core core18 20190508 970 stable canonical✓ base discord 0.0.9 93 stable snapcrafters - gtk-common-themes 0.1-16-g2287c87 1198 stable canonical✓ - gotop htop 2.2.0 1168 stable maxiberta - slack 3.4.2 14 stable slack✓ classic spelunky gnome3-26-1604
Why do I have Gnome installed as a snap package? Let’s clean that up.
snap remove spelunky gotop gnome-3-26-1604 Note, this later broke my discord snap because discord uses Gnome as a dependency.
Oops, I also forgot to install the microcode for my computer when I switched boot loaders, let’s do that real quick. I append
initrd=\intel-ucode.img to my kernel args. However this does add a little bit to my boot time because we have to load another file.
$ systemd-analyze blame | head 1.049s apparmor.service 860ms systemd-logind.service 692ms lvm2-monitor.service $ systemd-analyze Startup finished in 6.319s (firmware) + 27ms (loader) + 2.085s (kernel) + 2.564s (userspace) = 10.997s graphical.target reached after 2.560s in userspace
That’s better but still not under 10s.
Third, Quieting the Boot
So let’s append some options to the kernel args:
quiet loglevel=2 rd.systemd.show_status=auto udev.log_priority=3 i915.fastboot=1
This doesn’t really do much to reduce the boot up messages. Just removed some of the basic kernel messages at startup.
Now we are going to hide
fsck output. Hmm this helped with the kernel messages but not with the boot time.
Let’s try piping the output to another
tty session. We need to append
console=tty12 to the kernel args. This finally removed all the Systemd messages but I don’t know if it helped speed things up.
I learned a lot about boot loaders and the process the system goes through from the firmware loading the kernel to the login screen showing up. I learned how to compile the kernel. I learned the purpose of the
I reduced my boot time from 17 seconds to 11 seconds. Now when I start my machine I get the Lenovo logo then SDDM login. There’s no flurry of text as the machine starts up.
Startup finished in 6.293s (firmware) + 47ms (loader) + 1.559s (kernel) + 631ms (initrd) + 2.549s (userspace) = 11.081s graphical.target reached after 2.548s in userspace
I plan to continue my adventure by trying 2 more things.
- Doing a clean Arch install to get a baseline of boot times with Arch. It looks like Snapd adds time so I imagine that will help.
- Compile a slimmed down Linux kernel and initrd.