Skip to main content

Refined Boot for Qubes OS: Minimal USB Key, Dual Boot, Secure Boot

I've been running Qubes OS on Machine A alongside Windows for a while. My setup involved storing the unencrypted /boot partition and the LUKS header on an external USB drive.

Recently, I planned to install Qubes on Machine B, also in a dual-boot configuration. However, the complexity jumped significantly:

  • Machine B has Secure Boot enabled because BitLocker requires it. On previous installs, I grew tired of toggling Secure Boot in the BIOS every time I switched operating systems.

  • I only have one USB drive. Managing separate /boot partitions for two different Qubes installations on a single thumb drive is messy.

After some experimentation, I found a way to solve both problems.

Sharing One USB Drive for Multiple Qubes Installations

The solution is elegant: Don't store /boot on the USB drive. Instead, move /boot to the encrypted internal disk partition. The USB drive's only job is to unlock that partition and hand over control to the system. Once I grasped this concept, implementation was relatively straightforward using the Arch Wiki and AI.

Some notes:

  • The USB drive only needs an EFI partition containing the GRUB binary and the LUKS header files. In my case, these total less than 30MB.
  • While recent GRUB versions support LUKS2, but only very recent commits supports Argon2. Fedora's version was too old, but the packages in Debian Sid worked. Arch shoud also work.
  • I wrote a simple grub.cfg that loads the necessary modules (GPT, LUKS2), unlocks the partition via cryptomount using the header file on the USB, and then passes control using configfile.
  • For this setup, usually, /boot can just be a folder in the root directory/filesystem. However, because my root is on a thin-provisioned LVM logical volume (which GRUB does not yet support), I had to create a separate, standard LVM logical volume specifically for /boot.
  • I used grub-mkstandalone to create a bundled GRUB binary and efibootmgr to register it with the UEFI firmware.
  • When the kernel/initramfs boots from the now-unlocked /boot, it doesn't "inherit" the unlocked state. To avoid typing the password twice, I embedded a LUKS keyfile into the initramfs to automate the second unlock.
  • To support both machines, I copied both LUKS headers to the USB. I then modified grub.cfg to detect the machine's UUID via smbios, allowing it to automatically select the correct header and partition.

The Benefits

Compared to the standard "detached USB" method, this stores significantly less data on the unencrypted drive, making backups easier and security tighter.

It also solved a major headache: updates. Previously, I had to manually mount /boot before updating dom0 and remember to unmount it before rebooting. If I forgot and triggered a reboot of sys-usb, the system would often hang. Now, those days are over. I can update the system without the USB drive even being plugged in; the drive itself rarely needs updates.

Make Qubes OS Play Nice with Secure Boot

It turned out I misunderstood "Qubes OS doesn't support Secure Boot." What that actually means is that Qubes doesn't provide an out-of-the-box way to verify the entire chain (Xen, kernels, etc.).

However, if our goal is simply to allow Qubes to boot without disabling Secure Boot in the BIOS, it’s actually quite easy:

  • Set up shim, register the entry with UEFI, and point it to my GRUB EFI binary.
  • Ensure my GRUB binary contains an SBAT section. I used objcopy to extract this from Debian GRUB binary, then included it via grub-mkstandalone.
  • Disable MOK validation mokutil --disable-validation. The MOK Manager actually refers to it by "Disable Secure Boot", but it doesn't actually affect UEFI or Windows.
  • Enroll my GRUB binary hash during the first boot.

That's it!

I was surprised by the simplicity. I expected to be wrestling with PK/KEK keys and accidentally bricking my Windows bootloader. Instead, learning how shim and MOK interact made the process painless.

Security Implications

To be clear: this method allows Qubes to run alongside Secure Boot, but it does not (yet) cryptographically verify the Xen image or Linux kernels.

However, since that data resides on an encrypted partition and the bootloader is on a detached USB, it meets my personal threat model. In the future, I may look into creating my own keys to sign the images properly.

I’m also considering moving the GRUB binary to an internal partition. If I embed the LUKS header directly into the GRUB binary and enroll its hash, the shim would theoretically notify me if the binary was tampered with. It’s not a perfect defense against physical access, but it's a significant step up from a standard unencrypted boot.

Comments

Popular posts from this blog

Exploring Immutable Distros and Declarative Management

My current server setup, based on Debian Stable and Docker, has served me reliably for years. It's stable, familiar, and gets the job done. However, an intriguing article I revisited recently about Fedora CoreOS, rpm-ostree, and OSTree native containers sparked my curiosity and sent me down a rabbit hole exploring alternative approaches to system management. Could there be a better way? Core Goals & Requirements Before diving into new technologies, I wanted to define what "better" means for my use case: The base operating system must update automatically and reliably. Hosted services (applications) should be updatable either automatically or manually, depending on the service. Configuration and data files need to be easy to modify, and crucially, automatically tracked and backed up. Current Setup: Debian Stable + Docker My current infrastructure consists of several servers, all running Debian Stable. System Updates are andled automatically via unattended-upgrades. Se...

A Rocky Migration: Moving from docker-compose to Podman and gVisor

I've been running a few containers for several years. They were all running under rootless Docker with a single user. Initially, I planned to  migrate the containers to VMs , but I couldn't get a stable workflow after about two months of effort. Later,  gVisor caught my attention , and I decided to migrate to Podman with gVisor instead. The new plan is to run each container with  --userns=auto  and use Quadlet for systemd integration. This approach provides better isolation and makes writing firewall rules easier. I'm now close to migrating all my containers. Here are a couple of rough edges I'd like to share. Network Layout I compared  various networking options  and spent a few hours trying the one-interface-per-group approach before giving up. I settled on a single macvlan network and decided to use static IP addresses for my containers. To prevent a randomly assigned IP address from conflicting with a predefined one, I allocated a large IP range for my ...

Determine Perspective Lines With Off-page Vanishing Point

In perspective drawing, a vanishing point represents a group of parallel lines, in other words, a direction. For any point on the paper, if we want a line towards the same direction (in the 3d space), we simply draw a line through it and the vanishing point. But sometimes the vanishing point is too far away, such that it is outside the paper/canvas. In this example, we have a point P and two perspective lines L1 and L2. The vanishing point VP is naturally the intersection of L1 and L2. The task is to draw a line through P and VP, without having VP on the paper. I am aware of a few traditional solutions: 1. Use extra pieces of paper such that we can extend L1 and L2 until we see VP. 2. Draw everything in a smaller scale, such that we can see both P and VP on the paper. Draw the line and scale everything back. 3. Draw a perspective grid using the Brewer Method. #1 and #2 might be quite practical. #3 may not guarantee a solution, unless we can measure distances/p...