Switching the Bootloader from GRUB2 to Limine on an Arch Linux UEFI Machine

 2024-09-22

 Arch Linux

This article is the English version of the Japanese article titled ‘UEFIマシン上のArchLinuxのブートローダをGRUB2からLimineに変更する’.

Let’s change the boot loader

Hello. This time, I will change the boot loader of Arch Linux from GRUB2 to Limine. I have been using GRUB2 until now, but I wanted to try a new boot loader, so I changed it. Currently, there is no benefit from changing a boot loader that is working properly from a practical point of view, but I think that being able to play around with it is the best part of free OS such as Linux. Let’s have fun customizing the OS today.

Precautions before starting work

This work involves replacing the boot loader that starts the OS, so if the work fails, the OS may not be able to start. If the OS cannot be started, it is necessary to perform recovery work using the Arch Linux installation media. If you are not confident in performing this recovery work, it is wise to avoid modifying the boot loader. In this article, I will publish the steps that I actually took, but please note that the work may differ slightly depending on the partition configuration and architecture of your system. In particular, depending on the UEFI firmware, changing the NVRAM using efibootmgr may not work properly. When performing the work, be sure to do so at your own risk.

About the working environment this time

First, let me summarize the author’s working environment. This time, I will install Limine on a UEFI machine. For information about Legcy BIOS, please see ArchWiki.

ItemValue
OSArch Linux
BIOS systemUEFI
ESP(EFI System Partition)/boot

What is Limine?

Limine is a lightweight, advanced, and portable bootloader. It supports the multiboot1 and multiboot2 specifications. It was developed as a reference implementation of the Limine Boot Protocol.

It aims to avoid bloat like GRUB2 and keep the responsibilities of the bootloader simple. If you are interested, please see Limine’s Design Philosophy.

Limine supports both Legcy BIOS and UEFI firmware.

Installing Limine

First, install the limine package with pacman.

pacman -S limine

Next, copy /usr/share/limine/BOOTX64.efi to /boot/EFI/limine/.

mkdir -p /boot/EFI/limine
cp /usr/share/limine/BOOTX64.efi /boot/EFI/limine/

Next, register Limine to NVRAM with efibootmgr. sdX is the disk of the ESP, and Y is the partition number. If the ESP is /dev/sda1, set sdX=sda, Y=1.

efibootmgr \
--create \
--disk /dev/sdX \
--part Y \
--loader /EFI/limine/BOOTX64.efi \
--label "Limine"

Next, use the efibootmgr command to check that Limine has a higher priority than GRUB in the efi file invocation order. Check the value of BootOrder to check the priority. If GRUB is 0001 and Limine is 0002,

BootOrder: 0002, 0001, ...

If it is displayed like this, it is OK. If Limine has a lower priority, change it with the efibootmgr command.

As a supplementary note, if you copy the BOOTX64.efi file to, for example, /boot/EFI/BOOT/BOOTX64.efi, the efi firmware will automatically search for it without any configuration in efibootmgr, so you may be able to boot without registering it with efibootmgr.

Limine settings

GRUB2 will automatically generate a configuration file with the grub-mkconfig command, but Limine requires you to create the configuration file manually. Limine is a highly customizable boot loader, so it has a high degree of freedom and can be configured in many ways. Here we will write the minimum settings for booting Arch Linux, but for other settings, please refer to the official documentation.

Example of /boot/limine.conf settings

TIMEOUT=5

:Arch Linux
PROTOCOL=linux
KERNEL_PATH=boot:///vmlinuz-linux
CMDLINE=root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx rw
MODULE_PATH=boot:///initramfs-linux.img

In the above, we set only the TIMEOUT item simply to start Arch Linux, but you can customize it in detail, such as setting an image as the wallpaper. BMP, PNG, and JPEG images can be used as wallpaper images.

Boot test

Now, let’s check whether we can boot using limine. Reboot the system. If the following screen appears, it’s OK.

limine boot screen

Deleting GRUB2 (optional)

This should only be done if you are able to boot the OS stably with Limine and no longer need Grub. If you think you may need to use Grub again, it is better to leave it. First, delete the GRUB2 registration with efibootmgr. Here, we assume that GRUB2 is registered as 0001.

efibootmgr -b 1 -B

Next, delete the directory containing the GRUB2-related files. In this case, we assume that the grubx64.efi file exists in /boot/EFI/grub/grubx64.efi.

rm -r /boot/grub
rm -r /boot/EFI/grub

Summary

I was able to use Limine to boot Arch Linux installed on a machine with UEFI BIOS. Using Limine, I realized that while GRUB2 is very useful for detecting other OSes (os-prober is required) and automatically generating configuration files, it also does a lot more than just its simple function as a boot loader.

Another boot loader in the official Arch Linux repository is rEFInd. It is a boot loader exclusively for UEFI and does not support Legacy BIOS, but if you are interested, please check out rEFInd.