March 21, 2019

Linux Howto: Cleaning up Your GRUB 2 Menu (part 2) - page 2

Bogus Entries, Splash Screen

  • February 25, 2010
  • By Akkana Peck

Adding a background image

Background images are a little trickier. 05_debian_theme looks for images in two places: /boot/grub and /usr/share/images/desktop-base. That happens in this line:

  for i in {/boot/grub,/usr/share/images/desktop-base}/moreblue-orbit-grub.{png,tga} ; do

There's a grub2-splashimages package in Karmic -- but it puts its images in /usr/share/images/grub, not one of the two places grub2 looks! So whether you use an image from grub2-splashimages or one of your own, you'll have to copy it to /boot/grub by hand, or edit the list of image locations.

What image types can you use? That line in 05_debian_theme only matches .png or .tga files, not .jpg. But look a few lines down:

      case ${bg} in
        *.png)          reader=png ;;
        *.tga)          reader=tga ;;
        *.jpg|*.jpeg)   reader=jpeg ;;
Turns out grub2 understands jpg files too -- it's just that the script mistakenly screens out those files.

So you might be better off dumping that complicated "for i" line and just specifying the image you want to use, like this:

for i in /boot/my-splash-image.jpg ; do
(Programmers will note that you can also remove the for loop entirely if you want to.)

Text colors, revisited

That takes care of the image. But if you chose a dark image, you may notice that Ubuntu changed the text color from white to black (Figure 2).

figure 2
figure 2

That's because 05_debian_theme sets a different color scheme if you're using a background image. It comes from this part of the file:

if background_image `make_system_path_relative_to_its_root ${bg}` ; then
  set color_normal=black/black
  set color_highlight=magenta/black

What's that black/black? Obviously it's not black foreground text on a black background.

At least in Karmic's version of grub2, specifying "black" as a background is actually a secret code for "transparent". So "white/black" will give you white text and let you see your image underneath (Figure 3).

figure 3
figure 3

No, it doesn't make any sense. No, it isn't documented anywhere, and may change at any time. But for now, this trick will let you set up a pretty boot screen that looks any way you like.

In Part 3, I'll discuss some additional challenges and strategies for multiple-boot machines under Grub 2.

Akkana Peck is a freelance programmer and writer, and author of the book Beginning GIMP: From Novice to Professional. She also fiddles with way too many kernels and �� Linux distros..

Most Popular LinuxPlanet Stories