Linux Fu: UEFI Booting [Hackaday]

View Article on Hackaday

Unless your computer is pretty old, it probably uses UEFI (Unified Extensible Firmware Interface) to boot. The idea is that a bootloader picks up files from an EFI partition and uses them to start your operating system. If you use Windows, you get Windows. If you use Linux, there’s a good chance you’ll use Grub which may or may not show you a menu. The problem with Grub is you have to do a lot of configuration to get it to do different things. Granted, distros like Ubuntu have tools that go through and do much of the work for you and if you are satisfied with that, there’s no harm in using Grub to boot and manage multiple operating systems.

An alternative would be rEFInd, which is a nice modern UEFI boot manager. If you are still booting through normal (legacy) BIOS, the installation might be a hassle. But, in general, rEFInd, once installed, just automatically picks up most things, including Windows, Mac, and Linux operating systems and kernels. The biggest reasons you might change the configuration is if you want to hide some things you don’t care about or change the visual theme.

Basics

A UEFI computer stores boot information in nonvolatile RAM. You can examine this and even make some changes using the Linux utility efibootmgr:


$ efibootmgr
BootCurrent: 0004
Timeout: 1 seconds
BootOrder: 0004,0003,0001,0002,0005,0006
Boot0001* UEFI OS
Boot0002* UEFI:CD/DVD Drive
Boot0003* ubuntu
Boot0004* rEFInd Boot Manager
Boot0005* UEFI:Removable Device
Boot0006* UEFI:Network Device

Generally, you won’t want to directly add or delete things using this tool, even though you can. Usually, your operating system takes care of all that. However, it is a pain to pick one partition over the other if you, for example, boot Windows and Linux. You can see from the above dump that I don’t do this, at least not on this computer. However, I do often boot from a removable disk or have multiple kernels or even operating systems installed in different places.

Grub can handle all this, of course. Especially if you use a distribution with a lot of tools, they will scan, looking for things, and rebuild your grub configuration. But if that configuration ever goes bad and you forget to build, look out! Time to boot from a rescue disk, more than likely. Grub is both a boot loader and a boot menu. But rEFInd is a boot menu manager only.

Pros and Cons

There are several reasons you might opt for rEFInd. The biggest practical reason is that it scans for bootable items on every boot. It is also nice looking and can support touchscreens and mice, but not both at the same time. There was an Ask Ubuntu post where the author of rEFInd listed the pros and cons between his code and Grub. His advantages list include:

  • Scans for new kernels on every boot
  • Eye candy
  • Reliable booting fo Windows with secure boot active
  • Able to launch BIOS-mode bootloaders
  • Ability to speed up installs if you don’t install Grub at all
  • Strict enforcement of secure boot policies

Of course, there are also some downsides. Grub is the “official” way to handle things for most distributions and you can assume distros and tools will be compatible with it. It relies primarily on a single developer. Grub is easier to use with networking, LVM, and RAID booting, although these are possible with rEFInd, too. Because rEFInd scans on each boot, there is a brief pause when you boot, of course.

It is possible to have rEFInd boot into Grub, and that can be useful sometimes, but in general, you’ll want to use rEFInd instead of the Grub menus. One exception is if you want an emergency USB drive with rEFInd on it, that might be useful since it can mostly configure itself.

Install

If you use a distro that can handle Ubuntu PPAs, installing the program is simple.


sudo apt-add-repository ppa:rodsmith/refind
sudo apt-get update
sudo apt-get install refind

You can also find detailed instructions on installing in special cases on the project’s website. Once you install, you probably don’t have to do anything, but you might want to browse the configuration file (something like /boot/efi/EFI/refind/refind.conf). There you can adjust a few things like timeouts, default kernel options, and the like. There are quite a few options, but most of them are commented out.

You can also make manual entries, much like Grub. There are several examples in the default configuration file, but you’ll notice they all have the disabled keyword in them, so you would remove that keyword after making changes to suit you. You can also pick a text-based mode, the default screen resolution, and other parameters. I changed the line to show some tools (like reboot or boot into BIOS setup) that were not on by default. In many cases, you won’t need any changes at all.

If you see entries on the screen you don’t want, highlight them and press the minus sign. Don’t worry, you can manage the “hidden tags” using a menu if you change your mind later.

Be warned that while the system does support secure boot, if you use it, it may need a little tweaking. Here’s the good news. If it doesn’t work, just change the boot order back to boot Grub first and you can troubleshoot from there.

Themes

One fun thing you can do is get different themes for the program. These are just collections of artwork used as the banner and as icons for different distributions. For some reason, the program didn’t automatically pick up my Neon with the Neon logo, even though it was present. My simple solution was to replace the default Tux penguin with a copy of the Neon logo.

I’ve read that pressing F10 will screenshot rEFInd, but apparently, I don’t have the latest version, so I had to rely on my phone to take an old-school screenshot. You can see why I changed the penguin logo.

 

The tools along the bottom let you run a memory test, or reboot and shut down. You can also launch an EFI shell or alter the EFI boot order.

Low Risk

Any time you dink with the booting of your computer, you are taking a risk. However, if you install with Grub, you can always leave it as an option from rEFInd. If you get in big trouble, Grub is still there and you can boot from a rescue medium and use efibootmgr to pick your default Grub setup. The documentation for rEFInd has a good writeup on what the author calls “boot coups” when an operating system — looking at you, Windows — presumptively takes over booting.

If you don’t dual boot, you can probably stick with Grub. It is nice to have a more modern-looking boot menu, but it isn’t that compelling. But if you dual boot with Windows, Mac, or other EFI-capable operating systems, or even if you change kernels often, you should really check out rEFInd.

For some specialized cases, you might want to check out a specialized fork of rEFInd, which offers certain additional features. You can find out more about the differences on its home page.

If you want more technical details on UEFI, here you go. Of course, as Scotty famously said, “The more they overthink the plumbing, the easier it is to stop up the drain.” UEFI is a big attack target, and it has been hit before.