Fixing GRUB on a LUKS + BTRFS Arch Linux system
Last Updated 2022-08-28
Recently, an update to the GRUB bootloader package in Arch Linux introduced a regression that caused boot failures on UEFI systems. The commit in question added a call to fwsetup --is-supported
in /etc/grub.d/30_uefi-firmware
. If the GRUB version installed via grub-install
did not support this command, it would cause GRUB to fail to load and boot directly into the system BIOS.
This update made it through testing and into the stable repositories, breaking boot for many Arch users, including myself. To recover, I had to chroot into the installed system from a live USB and reconfigure GRUB. This was complicated by my use of full disk encryption (LUKS) and the BTRFS filesystem. As this is a non-standard setup, many users facing similar issues may find themselves lacking experience with the required recovery steps.
Prerequisites
Before starting, you will need:
- A USB drive with at least 8GB of storage to create a live Arch Linux environment.
- Access to another working computer to download and create the live USB.
- The latest Arch Linux ISO image.
Steps
1. Prepare Your Installation Media
First, you’ll need to download the Arch Linux ISO and verify its checksums. You can download the ISO from this link. Ensure that you have the correct release version.
2. Create a Bootable USB Drive
You have two methods to create a bootable USB drive:
Method #1: Ventoy (Multiboot Installer)
Ventoy simplifies the process of creating a multiboot installer. Just copy the Arch Linux ISO to the USB drive, reboot, and a menu will list all available bootable images. You can find more information on Ventoy here.
Method #2: dd Command
You can also write the installer to an unmounted USB drive using the dd
command as root. Ensure you correctly identify the target device to avoid overwriting any important data.
For example, under Linux, if your USB drive appears as sdx1
, you would write the installer to sdx
(remove the partition number):
3. Get a List of Partition Schemes
After booting from the live ISO, you’ll need to list partition schemes for the connected drives. To do this, run the following command:
Some prefer sudo lsblk -f
, but fdisk
provides a more organized and comprehensible presentation of information.
4. Open the Encrypted Partition
Identify the encrypted partition, or the largest one, and open it using the following command:
5. Mount the Partition
After opening the encrypted partition, mount it with the following command. If you use zstd compression for your drive, include the compress=zstd
flag:
6. List BTRFS Subvolumes
To list the BTRFS subvolumes, run:
7. Mount Other Partitions
If needed, mount other BTRFS subvolumes as listed in the previous step. For instance:
If you’re unsure which partitions to mount, you can mount all of them for safety.
8. Mount the ESP Partition
Mount the ESP partition, which might be at /efi
or /boot/efi
(for older installations). You can check the /etc/fstab
file of your installed system to confirm the mount point:
9. Chroot into the Mounted System
Chroot into the mounted system with the following command:
10. Reinstall GRUB
Reinstall GRUB with these commands:
To exit the chroot environment, simply type exit
.
11. Close the Encrypted Partition
Close the encrypted partition with the following command:
Finally, reboot your system with sudo reboot
. Your Arch Linux system should
now boot correctly.
Notes
It’s important to note that this guide is specific to a LUKS + BTRFS setup, so if you have a different setup, the steps may vary. As always, it’s recommended to back up your important data before making any changes to your system.
Note: If you encounter any problems during this process, refer to the Arch Linux wiki for troubleshooting tips.