Skip to content

Instantly share code, notes, and snippets.

@KunalGautam
Created September 1, 2026 08:58
Show Gist options
  • Select an option

  • Save KunalGautam/89b9f7daf446a80f67c740af17bbfa2e to your computer and use it in GitHub Desktop.

Select an option

Save KunalGautam/89b9f7daf446a80f67c740af17bbfa2e to your computer and use it in GitHub Desktop.

Arch Linux Secure Boot Guide (systemd-boot + UKI + sbctl)

This guide documents the complete architecture, setup process, and recovery steps for UEFI Secure Boot on this Arch Linux installation.


1. System Architecture

  • Operating System: Arch Linux (Kernel: linux-lts)
  • Bootloader: systemd-boot (/boot/EFI/systemd/systemd-bootx64.efi & /boot/EFI/BOOT/BOOTX64.EFI)
  • Kernel Image: Unified Kernel Image (UKI) (/boot/EFI/Linux/arch-linux-lts.efi) generated by mkinitcpio
  • EFI System Partition (ESP): Mounted at /boot (/dev/nvme0n1p1, FAT32)
  • Firmware: UEFI 2.70 (INSYDE Corp.)
  • Key & Signature Management: sbctl (Secure Boot Control)

2. Why systemd-boot + UKI Instead of GRUB?

When Secure Boot is enabled on UEFI systems:

  • Standard GRUB 2 on Linux enforces shim_lock verifier validation (error: kern/efi/sb.c:shim_lock_verifier_init:177:prohibited by secure boot policy) when booted directly without Canonical/Fedora's shim wrapper.
  • systemd-boot natively loads signed Unified Kernel Images (UKIs) directly with UEFI Secure Boot support, zero intermediate shim requirements, faster boot times, and seamless pacman hook integration.

3. Quick Setup & Automation

To configure Secure Boot on a fresh installation or after resetting UEFI keys, simply run:

chmod +x ~/enable-secure-boot.sh
sudo ~/enable-secure-boot.sh

4. Manual Step-by-Step Instructions

Step 1: Install sbctl & systemd-boot

sudo pacman -S --needed sbctl
sudo bootctl install

Step 2: Clear Firmware Keys (Enter Setup Mode)

  1. Reboot directly into your UEFI/BIOS firmware settings:
    systemctl reboot --firmware-setup
  2. In the Security / Boot menu:
    • If options are greyed out, set a temporary Supervisor Password.
    • Select "Clear Secure Boot Keys" / "Custom Mode" / "Erase all Secure Boot settings" (transitions firmware to Setup Mode).
    • Save changes (F10) and boot into Arch Linux.

Step 3: Generate and Enroll Custom Keys

# Create custom keys in /var/lib/sbctl/keys
sudo sbctl create-keys

# Enroll custom keys + Microsoft OEM vendor certificates into UEFI NVRAM
sudo sbctl enroll-keys -m

Important: The -m flag is essential. It includes Microsoft's OEM certificates into the KEK and db, ensuring external displays, GPU Option ROMs, and Thunderbolt controllers function without issues.

Step 4: Sign Bootloader and Kernel Images

Sign all EFI binaries and register them in the sbctl database (via -s):

# systemd-boot binaries
sudo sbctl sign -s /boot/EFI/systemd/systemd-bootx64.efi
sudo sbctl sign -s /boot/EFI/BOOT/BOOTX64.EFI

# Unified Kernel Images (UKI)
sudo sbctl sign -s /boot/EFI/Linux/arch-linux-lts.efi
[ -f /boot/EFI/Linux/arch-linux-lts-fallback.efi ] && sudo sbctl sign -s /boot/EFI/Linux/arch-linux-lts-fallback.efi

# Linux kernel image
[ -f /boot/vmlinuz-linux-lts ] && sudo sbctl sign -s /boot/vmlinuz-linux-lts

Step 5: Verify Signatures

sudo sbctl verify

Confirm that all listed binaries report ✓ ... is signed.

Step 6: Enable Secure Boot in BIOS

  1. Reboot into firmware setup:
    systemctl reboot --firmware-setup
  2. Set Secure Boot -> Enabled.
  3. Save changes (F10) and boot into Arch Linux.

Step 7: Verify Secure Boot Status

In Arch Linux, verify active status:

sbctl status

Expected output:

Installed:    ✓ sbctl is installed
Setup Mode:   ✓ Disabled
Secure Boot:  ✓ Enabled
Vendor Keys:  microsoft

You can also check with bootctl status:

Secure Boot: enabled (user)

5. Automatic Maintenance (Pacman Hook)

sbctl includes an ALPM hook located at:

/usr/share/libalpm/hooks/zz-sbctl.hook

Whenever pacman updates linux-lts, mkinitcpio, or systemd, the hook automatically runs sbctl sign-all, ensuring newly generated UKIs and bootloaders are signed before the reboot.

To manually re-sign all tracked files at any time:

sudo sbctl sign-all

6. Troubleshooting & Recovery

Problem Cause Solution
prohibited by secure boot policy (GRUB error) GRUB shim_lock module Switch to systemd-boot (sudo bootctl install) and sign systemd-bootx64.efi.
Firmware is not in setup mode UEFI keys not cleared Reboot to BIOS (systemctl reboot --firmware-setup) and clear Secure Boot keys.
System won't boot after enabling Secure Boot Bootloader / UKI not signed Temporarily disable Secure Boot in BIOS, boot into Arch Linux, run sudo sbctl sign-all, verify with sudo sbctl verify, and re-enable Secure Boot.
External monitor / GPU doesn't show video Missing Microsoft OEM certs Re-enroll keys with -m: sudo sbctl enroll-keys -m.
#!/usr/bin/env bash
# ==============================================================================
# Arch Linux Secure Boot Setup Script (systemd-boot + UKI + sbctl)
# ==============================================================================
set -euo pipefail
# Ensure script is executed with root privileges
if [ "$EUID" -ne 0 ]; then
echo "This script requires root privileges. Elevating with sudo..."
exec sudo "$0" "$@"
fi
echo "================================================================="
echo " Arch Linux Secure Boot Configuration (systemd-boot + UKI) "
echo "================================================================="
echo ""
# 1. Install sbctl
if ! command -v sbctl &> /dev/null; then
echo "==> [1/5] Installing sbctl..."
pacman -S --needed --noconfirm sbctl
else
echo "==> [1/5] sbctl is already installed."
fi
# 2. Configure systemd-boot (replaces GRUB to avoid shim_lock issues)
echo "==> [2/5] Setting up systemd-boot..."
if ! bootctl is-installed &> /dev/null; then
bootctl install
echo "✓ systemd-boot installed successfully."
else
bootctl update
echo "✓ systemd-boot is up to date."
fi
# 3. Check and Enroll Keys if in Setup Mode
echo "==> [3/5] Checking Secure Boot status..."
STATUS_OUTPUT=$(sbctl status 2>&1 || true)
echo "$STATUS_OUTPUT"
echo ""
if echo "$STATUS_OUTPUT" | grep -q "Setup Mode:.*Enabled"; then
echo "✓ Firmware is in Setup Mode."
# Create keys if not already present
if [ ! -d "/var/lib/sbctl/keys" ]; then
echo "--> Creating custom Secure Boot keys..."
sbctl create-keys
else
echo "✓ Custom Secure Boot keys already exist in /var/lib/sbctl/keys."
fi
# Enroll keys with Microsoft OEM vendor certificates
echo "--> Enrolling keys into UEFI NVRAM (with Microsoft OEM certs)..."
sbctl enroll-keys -m
echo "✓ Keys enrolled."
else
echo "ℹ Firmware is not in Setup Mode (Keys are already enrolled or locked)."
fi
# 4. Sign all UKI and bootloader EFI binaries
echo "==> [4/5] Signing boot binaries and saving to sbctl database..."
# Critical bootloader & UKI paths
BOOT_FILES=(
"/boot/EFI/systemd/systemd-bootx64.efi"
"/boot/EFI/BOOT/BOOTX64.EFI"
"/boot/EFI/Linux/arch-linux-lts.efi"
"/boot/EFI/Linux/arch-linux-lts-fallback.efi"
"/boot/vmlinuz-linux-lts"
)
for file in "${BOOT_FILES[@]}"; do
if [ -f "$file" ]; then
echo "--> Signing $file..."
sbctl sign -s "$file" || true
fi
done
# Sign any additional unsigned EFI binaries found on the ESP
echo "--> Checking for any remaining unsigned EFI binaries..."
sbctl verify 2>&1 | awk '/not signed/ {print $2}' | while read -r unsigned_file; do
if [ -n "$unsigned_file" ] && [ -f "$unsigned_file" ]; then
echo "--> Signing $unsigned_file..."
sbctl sign -s "$unsigned_file" || true
fi
done
# 5. Verify all signatures
echo ""
echo "==> [5/5] Verifying signatures:"
sbctl verify
echo ""
echo "================================================================="
echo " Secure Boot configuration completed!"
echo ""
echo " If Secure Boot is not yet enabled in your firmware:"
echo " 1. Run: systemctl reboot --firmware-setup"
echo " 2. In BIOS/UEFI settings, set 'Secure Boot' -> 'Enabled'"
echo " 3. Save and boot into Arch Linux"
echo " 4. Check status with: sbctl status"
echo "================================================================="

Arch Linux Secure Boot Guide (systemd-boot + UKI + sbctl)

This guide documents the complete architecture, setup process, and recovery steps for UEFI Secure Boot on this Arch Linux installation.


1. System Architecture

  • Operating System: Arch Linux (Kernel: linux-lts)
  • Bootloader: systemd-boot (/boot/EFI/systemd/systemd-bootx64.efi & /boot/EFI/BOOT/BOOTX64.EFI)
  • Kernel Image: Unified Kernel Image (UKI) (/boot/EFI/Linux/arch-linux-lts.efi) generated by mkinitcpio
  • EFI System Partition (ESP): Mounted at /boot (/dev/nvme0n1p1, FAT32)
  • Firmware: UEFI 2.70 (INSYDE Corp.)
  • Key & Signature Management: sbctl (Secure Boot Control)

2. Why systemd-boot + UKI Instead of GRUB?

When Secure Boot is enabled on UEFI systems:

  • Standard GRUB 2 on Linux enforces shim_lock verifier validation (error: kern/efi/sb.c:shim_lock_verifier_init:177:prohibited by secure boot policy) when booted directly without Canonical/Fedora's shim wrapper.
  • systemd-boot natively loads signed Unified Kernel Images (UKIs) directly with UEFI Secure Boot support, zero intermediate shim requirements, faster boot times, and seamless pacman hook integration.

3. Quick Setup & Automation

To configure Secure Boot on a fresh installation or after resetting UEFI keys, simply run:

chmod +x ~/enable-secure-boot.sh
sudo ~/enable-secure-boot.sh

4. Manual Step-by-Step Instructions

Step 1: Install sbctl & systemd-boot

sudo pacman -S --needed sbctl
sudo bootctl install

Step 2: Clear Firmware Keys (Enter Setup Mode)

  1. Reboot directly into your UEFI/BIOS firmware settings:
    systemctl reboot --firmware-setup
  2. In the Security / Boot menu:
    • If options are greyed out, set a temporary Supervisor Password.
    • Select "Clear Secure Boot Keys" / "Custom Mode" / "Erase all Secure Boot settings" (transitions firmware to Setup Mode).
    • Save changes (F10) and boot into Arch Linux.

Step 3: Generate and Enroll Custom Keys

# Create custom keys in /var/lib/sbctl/keys
sudo sbctl create-keys

# Enroll custom keys + Microsoft OEM vendor certificates into UEFI NVRAM
sudo sbctl enroll-keys -m

Important: The -m flag is essential. It includes Microsoft's OEM certificates into the KEK and db, ensuring external displays, GPU Option ROMs, and Thunderbolt controllers function without issues.

Step 4: Sign Bootloader and Kernel Images

Sign all EFI binaries and register them in the sbctl database (via -s):

# systemd-boot binaries
sudo sbctl sign -s /boot/EFI/systemd/systemd-bootx64.efi
sudo sbctl sign -s /boot/EFI/BOOT/BOOTX64.EFI

# Unified Kernel Images (UKI)
sudo sbctl sign -s /boot/EFI/Linux/arch-linux-lts.efi
[ -f /boot/EFI/Linux/arch-linux-lts-fallback.efi ] && sudo sbctl sign -s /boot/EFI/Linux/arch-linux-lts-fallback.efi

# Linux kernel image
[ -f /boot/vmlinuz-linux-lts ] && sudo sbctl sign -s /boot/vmlinuz-linux-lts

Step 5: Verify Signatures

sudo sbctl verify

Confirm that all listed binaries report ✓ ... is signed.

Step 6: Enable Secure Boot in BIOS

  1. Reboot into firmware setup:
    systemctl reboot --firmware-setup
  2. Set Secure Boot -> Enabled.
  3. Save changes (F10) and boot into Arch Linux.

Step 7: Verify Secure Boot Status

In Arch Linux, verify active status:

sbctl status

Expected output:

Installed:    ✓ sbctl is installed
Setup Mode:   ✓ Disabled
Secure Boot:  ✓ Enabled
Vendor Keys:  microsoft

You can also check with bootctl status:

Secure Boot: enabled (user)

5. Automatic Maintenance (Pacman Hook)

sbctl includes an ALPM hook located at:

/usr/share/libalpm/hooks/zz-sbctl.hook

Whenever pacman updates linux-lts, mkinitcpio, or systemd, the hook automatically runs sbctl sign-all, ensuring newly generated UKIs and bootloaders are signed before the reboot.

To manually re-sign all tracked files at any time:

sudo sbctl sign-all

6. Troubleshooting & Recovery

Problem Cause Solution
prohibited by secure boot policy (GRUB error) GRUB shim_lock module Switch to systemd-boot (sudo bootctl install) and sign systemd-bootx64.efi.
Firmware is not in setup mode UEFI keys not cleared Reboot to BIOS (systemctl reboot --firmware-setup) and clear Secure Boot keys.
System won't boot after enabling Secure Boot Bootloader / UKI not signed Temporarily disable Secure Boot in BIOS, boot into Arch Linux, run sudo sbctl sign-all, verify with sudo sbctl verify, and re-enable Secure Boot.
External monitor / GPU doesn't show video Missing Microsoft OEM certs Re-enroll keys with -m: sudo sbctl enroll-keys -m.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment