Skip to content

Home > GNU/Linux > Cleaning up the GRUB 2 appearance

Cleaning up the GRUB 2 appearance

GRUB2 is the way to go ... with some corrections

Tuesday 17 July 2012, by Stéphane Téletchéa

GNU/Linux world is chasing for a clean boot experience and recent years have seen the adoption of plymouth, bootsplash, splashy, etc, but this has regressed recently in distributions using GRUB 2 as the default bootloader.

Fedora grub menu is in particular at first ugly, and presents too much entries. This is problematic in notebooks where an hidden partition exists and should not be presented in grub menu by default. We will see how to disable this behaviour correctly and permanently.

Removing unuseful entries from GRUB config file

For this work, I have benefited from the great explanation found in

In short, GRUB uses os-prober to detect the available systems, and keeps them all, we need first to modify the detection routines to get rid of these entries:

cd /etc/grub.d

[root@presquelabo grub.d]# diff -Naup 30_os-prober_orig 30_os-prober
--- 30_os-prober_orig   2012-07-15 10:43:15.461436159 +0200
+++ 30_os-prober        2012-07-15 10:43:28.974267225 +0200
@@ -113,6 +113,17 @@ for OS in ${OSPROBED} ; do
  LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
  BOOT="`echo ${OS} | cut -d ':' -f 4`"

+  # Patch to prevent some partitions being autodetected
+  PARTITIONNAME="`echo ${DEVICE} | cut -c 6- 2> /dev/null`"
+  if [ "`echo ${SKIP_THESE_DEVICES} | grep -e ${PARTITIONNAME} 2> /dev/null`" ] ; then
+    continue
+  fi
+  # End of patch
  if [ -z "${LONGNAME}" ] ; then

Note that I’m specifying the device "sda1" but a more sophisticated heuristics should be used (check for the "hidden" status for instance). Adapt the above commands to your hard drive setup.

Once this is done, update the GRUB config file, as described in Fedora GRUB 2 entry, and do not edit manually the file since any update will overwrite your changes.

On my system:

[root@presquelabo ~]#  grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub.cfg ...
Found theme: /boot/grub2/themes/system/theme.txt
Found linux image: /boot/vmlinuz-3.4.4-5.fc17.x86_64
Found initrd image: /boot/initramfs-3.4.4-5.fc17.x86_64.img
 No volume groups found
Found Windows Vista (loader) on /dev/sda2

Setting up the default selection

In GRUB 1, entries were specified with a number starting at zero. You can still use this mechanism, but since GRUB 2 update does not guarantee the order of entries in the menu, the solution below is better:

- List the existing entries

[root@presquelabo ~]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
Fedora Linux
Windows Vista (loader) (on /dev/sda2)

- Set the new default entry

grub2-set-default "Windows Vista (loader) (on /dev/sda2)"

- Check if the default entry is correctly selected

grub2-editenv list
saved_entry=Windows Vista (loader) (on /dev/sda2)

In order to have the "hidden partition" skipped in GRUB 2 menu, I have opened a bug report on Fedora’s bugzilla.

Adding some colors to the "ugly" default menu

Fedora 17 comes with no theme by default ...

To enable it, just uncomment the line:


in /etc/default/grub

But, before rushing on the reboot, go to /boot/grub2/themes/system/ and adjust the size of background.png. The default image size is very big (2048 x 1536 pixels), for a laptop for instance, you can easily resize it to 1280 x 800, adapt to your screen resolution, but the default size is too big for most of us.

Copy the original image to "image_orig" and resize it using imagemagick (convert) or GIMP.

Now you can reboot :-)

Will Fedora re-enable themes for GRUB 2?

This is really unlikely since the theming was disabled because of speed issues (see the bugzilla discussion here).

Your mileage may vary, but at least you know why and know if you prefer a faster boot, or a more elegant one.

Comment on this article