Categories
Arcana Geekery Linux MacBook Air

Plymouth boot splash

Boot splash in Linux

Most operating systems have some sort of branded animation or placeholder while they are loading. In Linux, this niche is filled by plymouth. Unfortunately – and this is far from an exclusive scoop – plymouth is a pain in the arse and doesn’t work very well. I’ll never get back the day of my life I spent getting this working – but maybe I can save someone else the time (or at least the bother).

What follows are my attempts to get some sort of loading screen working for Gentoo on my MacBook Air before X/LXDE loads. This was a ludicrous amount of effort to get something so trivial working.

Unless you have a lot of time to kill, I wouldn’t bother with plymouth at all. But for the curious, here’s what I did.

The goal

Gentoo boots very fast on my Mac – typically around 6s before the display manager is loaded. During default boot, Gentoo spits out a lot of kernel and startup messages. While this has a certain satisfaction, along with my prettified Grub boot loader, I wanted something a little slicker.

I was heartended by this excellent blog post by Malcolm Mielle. Here he demonstrates how this charming sleepy cat boot splash can work smoothly in plymouth under gentoo.

Plymouth cat splash
Sweet cat boot splash from krishnan793

How hard could it be?

Steps required

The Gentoo wiki actually has a very useful guide to getting plymouth working – and the Arch wiki is useful as well. This is also a useful blog post.

They indicate the basic steps that are needed to support plymouth, including quite a lot of kernel configuration (for a boot screen!).

Install plymouth

This is the fairly straightforward bit. Plymouth can be compiled directly from the Gentoo tree. Be sure to use the libkms USE flag:

emerge --ask sys-boot/plymouth

I installed v0.9.5-r1. Then I downloaded the cool theme above, and following M. Mielle’s directions cloned it into the /usr/share/plymouth/themes/ directory. You can check the theme is detected using

plymouth-set-default-theme -l

Then set it to use the cat theme (or another of your selection)

plymmouth-set-default-theme PlymouthTheme-Cat

Kernel Modules

First, we need to ensure kernel modesetting support (KMS) is activated for the direct rendering manager for our graphics card – in my case the integrated intel 965 (915-family).

Device Drivers --->
    Graphics Support --->
        <*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  --->
            [*]   Enable legacy fbdev support for your modesetting driver 
        <*> Intel 8xx/9xx/G3x/G4x/HD Graphics (CONFIG_DRM_I915)
        [ ] Bootup logo  ----

The key thing here is to ensure the inferred config module DRM_KMS_HELPER is activated. If you have DRM and KMS active for your graphics card, it should be selected by default. It’s important these modules are built integrated into the kernel, so they’re available as early as possible for plymouth to start working.

Make sure the Bootup logo (CONFIG_LOGO) is turned off, as this can interfere with plymouth.

Initramfs

As the Gentoo wiki explains, the boot splash is loaded from the initramfs (the miniature file system that is loaded into RAM immediately upon boot) and so must be included in it. I was previously using genkernel to create my initramfs, but this does not support plymouth.

I’d recommend using dracut to generate an initramfs containing plymouth. It can easily be installed from the Gentoo package tree:

emerge --ask sys-kernel/dracut

Then use it to generate a new initramfs

dracut --force --hostonly

Plymouth should be detected and included automatically. I did get some other messages that particular modules could not be found – make sure these are all fixed, and then copy the new initramfs to the /boot/ directory where it can be found by the kernel.

Checking plymouth can display at all

It can be a bit tricky to check whether plymouth can display the theme at all. The easiest way I found was to use this script. Execute it from the command line – you can advance the animation by pressing any key.

In my case, nothing appeared at all – either with this script, or using plymouth --show-splash

Make sure modeswitching is enabled

Plymouth cannot work without graphics driver mode switching. In my case, it was necessary to manually ensure modeswitching was enabled by passing a specific kernel parameter. The magic parameter for the intel card is

i915.modeset=1

Botting with this enabled at last allowed me to see the splash on the command line.

Turn on splash screen kernel parameter

By default, Gentoo does not display a splash screen. To do this, you’ll need to add

quiet splash

to the kernel parameter. Finally I saw a splash screen – but only when it shut down. However, I still saw no animation on startup…

Troubleshooting

Start the boot splash immediately

This is a simple one, but caused me some grief. Setting

ShowDelay=0

to /etc/plymouth/plymouth.conf showed a (very brief) splash but then crashed my display manager. Interestingly, putting a delay into DeviceTimout in plymouth.conf allowed the display manager to start, but did not show the proper plymouth bootscreen (only a series of flashing squares).

It seemed plymouth was crashing my desktop – but that the default (with it attempting to start immediately) was starting before the GPU was ready, and so didn’t run (and the OS started ok).

LXDM and Plymouth do not get on

I spent a long time looking through the log files of X and LXDE to find out why it was crashing – but they simply terminated without any error.

Interestingly, when I installed another display manager than LXDM, I found I could show the splash early in boot and X and LXDE would still load fine. Since I wasn’t particularly attached to LXDM, I switched to SLiM instead (other login managers also worked fine). But I never got to the bottom of the mystery of the crashing.

Refinements

Now I got a (very brief) splash on boot, and a longer one on shutdown. A couple of refinements made the boot-up a bit smoother and improved the look.

You can suppress more messages and the cursor during boot by adding the following parameters:

loglevel=3 rd.systemd.show_status=auto rd.udev.log_priority=3 vt.global_cursor_default=0 nowatchdog