Weekend Project: Theming Your Linux Bootloader

1157

These days, a lot of Linux users have one distro on their main machines and do everything they can to boot into a usable desktop as fast as possible. Those of us who dual-boot multiple distros — or even OSes — though, still have to stare at the bootloader screen for a few seconds every time we power-cycle. So why not put a new coat a paint on that tired, old text-based menu? Pull up a terminal, and we’ll make booting something to look forward to.

The majority of Linux distributions today use either GRUB, the Grand Unified Bootloader, or GRUB 2, a rewrite of the original GRUB that adds new features — including themeability. Although it is rock-solid, the “legacy” GRUB does lack a bit in the flair department. If you are on a distribution that uses the legacy GRUB (such as Fedora or openSUSE), one of the simplest steps you can take is to switch to GRUB 2 instead.

There is also a derivative of GRUB 2 to consider: Burg, the Brand-new Universal loader from GRUB. Like GRUB 2, it offers simple support for both graphical- and text-mode theming, but adds a few additional features, such as collapsible menus.

Last but not least, if you use Apple hardware you may use the rEFIt bootloader to switch between Mac OS X and Linux. It comes with a slick looking graphical theme, but you are not limited to the default look and feel. We’ll take a look at each of these bootloader theming options in turn.

GRUB 2

GRUB 2 adds an array of theming options to GRUB Legacy’s traditional text-menu boot screen. The format consists of a text file that lists fonts, colors, and bitmap components, and defines their onscreen layout. Themable elements include the background image, progress bars, and “styled boxes” — which are akin to window-manager-like box definitions; you can specify images for each corner, the left, right, top, and bottom sides, and the space in the middle.

There is a lot of flexibility here, but you cannot alter GRUB 2’s essential presentation of the boot choices; you get a list of bootable kernels with human-readable names, and you can alter how it is rendered, but you can’t rearrange it entirely. You can use HTML or SVG colors, or comma-separated RGB triples, and you can use PFF2 bitmap fonts. There is a complete guide to GRUB 2’s theme format on Colin Bennett’s GRUB 2 site; he worked on the theming functionality in 2008 for the Google Summer of Code.

Both Ubuntu and Debian use GRUB 2 by default, so if you use either of those distros you can jump right to the theming section. Fedora users can install GRUB 2 instead of GRUB Legacy through the distro’s package management system. OpenSUSE users have a bit harder task, as the distro does not currently package GRUB 2; however it can be compiled from source — the dependencies are minimal. Of course, that limitation only applies if openSUSE is the only Linux distribution you intend to install; because both GRUB and GRUB 2 install to the master boot record (MBR) of the hard disk, which you use is OS-independent. Thus if you dual-boot between openSUSE and a GRUB 2 distro, you can simply install GRUB 2 through the second distro. As is always the case where bootloaders are concerned, though — use caution. If you don’t follow directions, you can wipe out the bootloader and be faced with the highly inconvenient task of re-installing from other media.

Burg Bootloader

The Ubuntu community wiki contains some of the most comprehensive GRUB 2 documentation, including how to tweak existing themes and define your own theme. The instructions appear to be a bit out of date, however, in respect to the file that you need to edit — GRUB 2 stores configuration files in /etc/grub.d/; the theming commands seem to have moved to the 00_header file. If you intend to do some customizing, start by simply changing the splash screen image. Move on to defining your own theme later.

Of course, you’ll probably want to browse some ready-made, pre-tested themes before you create a custom one all on your own. Bennett’s site has a few examples; for additional collections your best bet is to check the openDesktop sites, gnome-look.org and kde-look.org.

Burg

Burg expands on GRUB 2’s theming in a number of respects, including the ability to hide text and present an “icon only” boot menu. This is the most popular design choice in practice, but it is not mandatory; Burg can also switch between text and graphical modes, play sounds, and do other unusual tricks.

The major distros don’t currently package Burg, because of its experimental nature, so to install it you’ll need to visit the project site. Burg is based on GRUB 2; as a result users on a GRUB 2 distro like Ubuntu have the easiest time. The project maintains a Personal Package Archive (PPA) for recent Ubuntu releases; to install Burg all you need to do is add the PPA as an Apt repository, and select the Burg package. There are also instructions for compiling the Burg source code useful for other distributions — as with GRUB 2, it is a straightforward process with no unusual dependencies. The only hurdle is that the source installation relies on pulling code from the project’s Bazaar repository, but this step is documented for those that don’t use Bazaar.

Burg’s main configuration file is /boot/burg/burg.cfg. It allows you to specify basics such as auto-boot timeout (with a GRUB_TIMEOUT=n command), specify the screen dimensions for graphical mode (with GRUB_GXFMODE=640x480 or your resolution), as well as several other variables.

You specify the Burg theme to use, by name, with GRUB_THEME=themename. Themes are stored in the directory /boot/burg/themes/; each theme is itself a directory containing a file named theme and whatever images the theme requires. The theme uses a CSS-like syntax to describe the layout, alignment, and color of UI elements, including decorative images, fonts, menus, and buttons. It’s not quite CSS, though, so it is a good idea to read the documentation before building your own.

As you can see on the theme screenshot page, there are some pretty fancy effects possible with Burg. Some of the examples simply recreate GRUB 2 themes, while other veer off in entirely new directions. The downloads page has a “burg-theme” package available that contains all of the themes cataloged on the screenshots page and more.

You can look for additional Burg themes on the openDesktop sites listed in the previous section, but another good — perhaps better — source is the Burg project’s web discussion forum. There are also a few Burg themes beginning to appear on general desktop-art sites like DeviantArt, although you’ll have to look for them.

Finally, another one of Burg’s nicest conveniences is the ability to preview a theme without rebooting the system. Just run sudo burg-emu from a terminal; this is especially helpful to do when you are customizing or drawing your own theme from scratch.

rEFIt

The rEFIt bootloader is designed for Extensible Firmware Interface (EFI)-based Apple hardware; this covers Intel-based Mac products (and thus, probably the majority of Macs currently in circulation). It is popular with a lot of users who want to dual-boot OS X and other operating systems, because Apple’s official multi-boot tool Boot Camp only supports two OSes total, and doesn’t officially support Linux as one of them. Also, you can install rEFIt from within OS X itself, which is handy for those who are just starting their journey with Linux.

It is open source, and although its default installation presents a slick graphical UI (in fact, you will probably notice that many of the earliest Burg themes borrow from rEFIt’s design), you don’t have to stick with it. The easiest thing to do is change the icons shown for the boot-time menu selections. The project wiki explains how; each icon is a file in the efi/refit/icons directory, and the default package includes stock icons for OS X, Windows, Linux, all of the BSDs, BeOS, Haiku — even FreeDOS. There are also special icons for hard drive and optical storage volumes and several rEFIt functions, all of which can be customized as well.

To customize the selection screen even more, you can edit the refit.conf file installed by the package. By uncommenting lines — all of which, thankfully, are documented — you can specify alternate background images, “selected” item overlays, and title banners.

Unfortunately, finding third-party rEFIt themes is a little more work than finding GRUB 2 or Burg themes. There are some isolated themes on the gnome-look.org and kde-look.org sites, and a handful on DeviantArt, but no central repository exists, nor is there an active themer forum anywhere. Still, if you search the web, you will find dozens of good selections. Colin Harrington makes a stark-but-high-color theme that keeps things simple; if integration is your thing you might prefer Dmitrijs Ledkovs’ Humanity theme that uses Ubuntu icons. Mark von Ackerman’s Museo takes a decidedly different approach, using careful shading and line work to achieve an almost hand-drawn effect. It’s certainly different, which could be just the thing you’re looking for.

That’s why we all got into Linux in the first place, isn’t it? To have full control and customization over our hardware and software environment? Well, if you care enough to customize your icon theme and window decorations, but you’re still using the default GRUB or GRUB 2 boot screen, you’re only halfway there. And if you’re going to impress a newcomer to the Linux world with your choice of operating systems, let’s face it: you want to start making a good impression right from the first second.