Optimizing Arch Linux Boot: EFISTUB

6/25/2019

Recently, I became interested in improving my boot configuration and speed on my Arch Linux + Thinkpad setup (my main machine). My friend, Andrew (at scientificpineapple.com) gave me reccomendations. After an evening of tinkering, we he and I both felt we had a much-improved setup.

Firstly, I sought to switch to direct UEFI booting using “EFISTUB”. Most Linux installs by default use a “bootloader”, usually Grub2. The purpose of a bootloader is to start the boot process by doing the initial job of loading the initramfs (which, in turn, loads up the full Linux OS). This has been the standard for many years. Newer hardware supports a standard called UEFI, which is capable of loading the initramfs all on its own. This would eliminate the need for grub, reducing startup time (and general complexity of the system). The Arch Wiki provides some nice resources on EFISTUB, which is the name of this technique.

Reading through the wiki page along with several linked pages, we were able to distill the content down to the following:

The entire process is documented well in the Arch Wiki. I chose to modify my EFI mount point manually, using my /etc/fstab file:

## Added this line to FSTAB file to tell
# it how to mount the EFI partition.
## UUID identifies the partition, /boot
# states where to mount it, and vfat tells
# the OS what filesystem to expect.
## The rest are just parameters so that
# it mounts correctly.
UUID=D03A-8416  /boot   vfat    rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro   0   0

Once the EFI partition was mounting successfully, I had to copy the initrd and linux images over from their location under /boot (with the EFI not mounted) to their new location in /boot with the EFI partition mounted.

Next, the grub configuration file (the location varies with each install) could be opened up. Inspecting it would reveal what options are passed to the kernel on boot. I used these options (along with information in the Arch Wiki and some help from Andrew) to construct a line that could be run (using the efibootmgr tool) to insert a boot entry. It looked something like this (efibootmgr needs to be run as root):

efibootmgr --disk /dev/sda\
--part 1\
--create --label "Arch-EFI-autogen"\
--loader /vmlinuz-linux\
--unicode 'root=/dev/sda6 rw quiet initrd=\intel-ucode.img initrd=\initramfs-linux.img'\
--verbose -T

The tool is well documented, so I won’t go into much more detail on how that works. The only notable part was the issues I had using a UUID to identify the boot partition. For whatever reason, using a UUID resulted in a failure. I had to use the /dev/sda6 notation instead.

Since this line is long and complicated, it is a good idea to save it as a script. Reading about some of efibootmgr’s options, I added lines to the script that would

  1. Remove entries 1 and 2
  2. Add an entry for a regular boot
  3. Add an entry for a silent boot
     - Adding this entry "bumps" the previous one to be second, so that the silent boot is default
    

The concept of “silent booting” is one I’ll discuss next post, and was the next optimization Andrew and I sought on our laptops.

If you want to take a look at the script I constructed, it is available on my personal git instance.

I’ll be back soon with info on our next optimization: silent boot!


Creative Commons License

Unless stated otherwise, content on this page is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.