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:

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):

sudo dd if=archlinux-RELEASE_VERSION-x86_64.iso of=/dev/sdx bs=4M status=progress oflag=sync

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:

sudo fdisk -l

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:

sudo cryptsetup open /dev/sdaX cryptdev

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:

sudo mount -o compress=zstd,subvol=@ /dev/mapper/cryptdev /mnt

6. List BTRFS Subvolumes

To list the BTRFS subvolumes, run:

sudo btrfs subvolume list -p /mnt

7. Mount Other Partitions

If needed, mount other BTRFS subvolumes as listed in the previous step. For instance:

sudo mount -o subvol=@home /dev/mapper/cryptdev /mnt/home

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:

cat /mnt/etc/fstab
sudo mount /dev/sdaY /mnt/efi  # or /mnt/boot/efi

9. Chroot into the Mounted System

Chroot into the mounted system with the following command:

sudo arch-chroot /mnt

10. Reinstall GRUB

Reinstall GRUB with these commands:

sudo grub-install --no-nvram
sudo grub-mkconfig -o /boot/grub/grub.cfg

To exit the chroot environment, simply type exit.

11. Close the Encrypted Partition

Close the encrypted partition with the following command:

umount -R /mnt
sudo cryptsetup close cryptdev

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.

References