Skip to content

Setting up secure boot while dual booting Windows 11 and Arch Linux

I currently have a dual boot set up with Windows 11 and Arch Linux that I use for work. The company policy now requires us to set up secure boot. I looked at the wiki and to be honest it seems quite complicated/chaotic, and I'm pretty sure it'd take me several tries before getting it right.

How feasible would it be to set this up? Or would it be better to just ditch the dual boot and run Arch on a different machine?

1 points8 comments
Open on Reddit
About this post
Posted
Archived
Score
1 · 67% up
Kind
Text
ID
13d7rec

Author

8
posts
23
comments
1
media
View profile

10 comments

By far the easiest is to use sbctl to generate, install and use keys to sign your efi images. You can use mkinitcpio to build the unified kernels automatically and a pacman trigger to rerun the sbctl signing when the kernel is updated. Pretty straightforward (once you've done it once).

8 points

sbctl also has a really neat feature that allows you to enroll checksums from the TPM event log, allowing you to get working hardware without using the Microsoft vendor keys. The only drawback is you have to manually sign the Windows boot files whenever they get updated (usually happens for the major monthly update that requires a reboot).

(disclaimer: it's an experimental feature and if it doesn't work you basically soft-brick your system, so you have to be sure you can restore the Microsoft keys or disable secure boot in some way. On my system I can just pull the battery from the motherboard, but YMMV).

1 points

If you're using GRUB you can follow the instructions in this post, it's pretty straightforward and you can set up secure boot in minutes.

5 points

I ended up going with this post. Would recommend to anyone with a similar set up. Thanks!

2 points

Hey, thanks for the guide.
I am a newbie, trying Arch Linux on Dual Boot.

When removing Arch Linux from Dual Boot, is it required to remove those keys manually from Linux to get rid of it safely?

1 points

There is a lot already written on this but to do this with minimal complications you can set up shim with refind.

Install refind, sbsigntools, mokutil from repos and shim-signed from the AUR.

Run: refind-install --shim /path/to/shimx64.efi --localkeys.

This will make MOK keys and run mokutil import. It will ask for a password to import the key on next boot.

Sign kernel with the key in /etc/refind.d/keys. Setup a pacman hook to sign kernels. There is an example in the arch wiki.

On your next boot the key used to sign refind and your kernels will be enrolled into MOK manager.

You can also do this with grub, but requires you to install grub with all the modules you need for booting embedded into the core image. Follow the arch wiki with how to do this but you may have issues with chainloading.

5 points

Bring it to your IT dept and tell them to set up dual boot...

I wasn't able to get shim working personally so I made my own signing keys and self sign my unified kernel image. That said, let your IT dept deal with it.

3 points

Dual booting is mid at best.

Maybe use a hypervisor inside one of the oses and be done with it?

Not hating on you for needing a working solution, just that dual boot is a pita.

Virtualbox emulates uefi and tpm. So if you use that inside windows which already has secure boot then you don't need to manage multiple keys and bootloaders.

1 points

In addition to /u/m2noid's excellent post, I offer a slightly different alternative. It still uses refind (because setting up GRUB with secure boot is a pain in the ass), but instead of using sbsigntools, mokutil, and shim-signed, I use sbctl to create and sign with my own keys.

Before you get started with the below instructions, go into your BIOS and under the Secure Boot options, select Clear Keys or whatever option that puts Secure Boot into Setup Mode instead of User Mode. You need this mode to register new keys to the BIOS.

After that, boot into Arch, create your keys and sign your boot chain:

# Install the necessary packages!
sudo pacman -Syu sbctl refind

# Install refind so that we can stop using GRUB
sudo refind-install

# Create keys
sudo sbctl create-keys

# Register them with BIOS, along with Microsoft vendor keys
sudo sbctl enroll-keys -m

# Sign the kernel and refind EFI files.
# Adjust paths accordingly! Your system WILL be different from mine
# My /boot is in my root partition and my EFI partition is mounted separately
sudo sbctl sign -s /boot/vmlinuz-linux
sudo sbctl sign -s /efi/EFI/refind/refind_x64.efi

# You also need to sign the appropriate refind FS driver
# I use btrfs so I sign the btrfs driver
sudo sbctl sign -s /efi/EFI/refind/drivers_x64/btrfs_x64.efi

# Verify everything has been signed and reboot
sudo sbctl verify
sudo reboot

# (Optional) Uninstall grub
sudo pacman -Rs grub os-prober

# Clean up left over grub files in /boot and EFI
# Reminder to adjust paths accordingly!!
sudo rm -rf /boot/grub
sudo rm -rf /efi/EFI/<GRUB EFI FOLDER>

The thing that I love about sbctl is that it automates the key signing for you in a very easy way. It even ships with a pacman hook by default that will make sbctl automatically resign all files that you told it to sign during the initial setup, making kernel upgrades stress free.

NOTE: Just like with grub, you do need to create a pacman hook for refind if you want the bootloader executables to be upgraded whenever the package gets upgraded. Here's my hook for reference. You can place it in /etc/pacman.d/hooks:

[Trigger]
Operation=Upgrade
Type=Package
Target=refind

[Action]
Description = Updating rEFInd on ESP
When=PostTransaction
Exec=/bin/sh -c '/usr/bin/refind-install --yes; /usr/bin/sbctl sign-all'

This triggers refind-install and says yes to all the interactive questions. Because refind-install will install new bootloader executables, they also need to be re-signed, in which case I just call sbctl sign-all which will re-sign all the files that you've registered to it.

Hope this helps!

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.