Linux Howto: Cleaning up Your GRUB 2 Menu (part 2)
Bogus Entries, Splash Screen

Akkana Peck
Thursday, February 25, 2010 11:04:38 AM
In the last
installment, I showed how to add new entries for your grub2 menu, and
gave a few simple examples of entries that work.
But that boot menu is long, confusing and ugly. How do you fix it?

figure 1
Getting Rid of Bogus Menu Entries
I mentioned in the last article that Ubuntu's scripts generated
56 lines of grub entries on my system. That's because I have three
root partitions and a lot of kernels in /boot.
Ubuntu generates entries to boot every kernel with every root
partition -- except most of those combinations don't actually work,
because the kernel may depend on modules or userspace programs
that are only installed in one of your distros. The only entries
you can be sure are right are the ones for the current Ubuntu install
with the current Ubuntu kernel -- and those may not be first in the menu.
So if you boot multiple distros, you can simplify your boot
menu and eliminate that clutter with a little editing.
Fortunately, grub.cfg includes comments to show which grub.d
file generated which entries. Here's the sequence:
- First, 10-linux finds all the kernels in /boot and
makes two entries -- one regular, one recovery -- for each kernel
using the current root partition.
- 20_memtest86+ adds a couple of memtest entries.
- For every other Linux root partition besides the current one,
30-os-prober makes two entries, regular and recovery, for each kernel.
- Your custom entries in 40_custom get added last.
You can turn off the entries from 30-os-prober by adding a line
to /etc/defaults/grub:
GRUB_DISABLE_OS_PROBER="true"
Most of them don't work anyway, so there's not much loss there.
Make custom entries for your other distros, as described in the
previous article.
Turning off all the extra kernel entries from 10-linux is only
a little harder. Of course, you could disable the file entirely --
for instance, chmod 000 /etc/grub.d/10_linux --
and put everything in 40_custom. But then system updates can't
add entries for new kernels.
Better is to modify how it looks for new kernels.
Look for a line like this in 10_linux:
list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
This is the line that finds your installed kernels.
You can restrict it to use only the current kernel version by replacing
that line with this:
# Get the current kernel version:
kernelvers=`uname -r`
# Remove the local version and architecture:
kernelvers=${kernelvers%%-?*}
list=`for i in /boot/vmlinuz$kernelvers-* ; do
Don't forget to run update-grub before rebooting!
Fixing That Ugly Splash Screen
How about that ugly white-on-black boot screen (Figure 1)?
Surely there's some way to improve that?
/etc/grub.d/05_debian_theme controls the color and
background image of grub2's boot screen.
If you just want some nicer colors, edit this function at the beginning
of the file:
set_mono_theme()
{
cat << EOF
set menu_color_normal=white/black
set menu_color_highlight=black/white
EOF
}
Normal is the color of most of the menu; highlight is the
item that's currently selected. The two colors, like "white/black",
represent the foreground and background colors for the text in the menu.
There's no documentation on what colors you can use,
but you should be fairly safe with the ones from the
grub1
manual.
Next: Background Image, Text Colors, Black Means Transparent »