Setting a grub2 Boot Splash Image
For many years, I used extlinux as my boot loader to avoid having to deal with the annoying and difficult grub2. But that was on MBR machines. I never got the sense that extlinux was terribly well supported in the newer UEFI/Secure Boot world. So when I bought my current machine a few years ago, I bit the bullet and let Ubuntu's installer put grub2 on the hard drive.
One of the things I lost in that transition was a boot splash image. When I boot my older extlinux machines, I can set the background to show a nice photo. When I booted the Ubuntu-installed machine, the boot screen was white text on a black background.
I tried several times to configure a grub2 splash image, but nothing worked (including Ubuntu's grub2-splashimages package) and I always gave up after a few hours. After all, is it really worth spending many hours fighting to install a splash image that you'll only see for a few seconds once at the beginning of the day?
But you know, it does matter. Yes, it's only a few seconds, but those seconds come at the very beginning of the day. And you know, seeing a pretty boot splash image kind of lifts my spirits, starting the day off on a high note, while that white-text-on-black-background Ubuntu screen did the opposite.
A few months ago I switched to Debian, which gave me — white text on a blue background. So much better! (Sigh.) I tried again, thinking maybe Debian would be easier, installing the grub2-splashimages package, following various howtos, to no avail. In particular, the howtos are never clear about where to put the splash image, what size and format it needs to be, and what the image path should look like in /boot/grub/grub.cfg.
But after a grub-related discussion on the SFLUG mailing list, I mentioned my problem and got a couple of replies from people who had gotten it to work. Their examples didn't quite work, but they pointed me in the right direction, and I finally got it working.
And now, my day can start with aspens on Pajarito Mountain instead of dull black and white.
Important things for making a working grub2 boot splash
- PNG works, JPG doesn't, even though I found several websites with JPG examples
- Use 640x480 at least initially. I think it's supposed to be possible to use other resolutions, but I haven't explored that yet.
- You can put the image in /boot/grub/imagename.png and refer to it from grub.cfg by that same path. The imagename doesn't have to be splash.png, but it does need to be a png, not a jpg.
- You need to
insmod png
first (for jpg images, the module in /usr/lib/grub/x86_64-efi is called jpeg.mod, not jpg.mod, butinsmod jpeg
still didn't work for me) - Don't use a background color (e.g. don't
set menu_color_normal=cyan/blue
) because that will block out nearly all of your image, not just the part where the text is. If you want to set a foreground color, use black as the background color, because in the grub2 world, black doesn't mean black, it means transparent.
I experimented by modifying /boot/grub/grub.cfg, but once I got it working, I added it to /etc/grub.d so that it will be renewed whenever update-grub runs. You can put it in /etc/grub.d/05_debian_theme; in my case, I put it at the beginning of in /etc/grub.d/09_local which comes after 05_debian_theme and overrides it.
# # First add a boot splash image, overriding whatever 05_debian_them # may have set. # insmod png if background_image /boot/grub/dsc02644.png; then # colors to go on top of the image. # Setting the second color to black actually means make it transparent. set menu_color_normal=white/black set menu_color_highlight=yellow/black else # colors used if the boot splash image doesn't work set menu_color_normal=cyan/blue set menu_color_highlight=white/blue fi
[ 19:29 Jan 17, 2022 More linux | permalink to this entry | ]