NOTE: Using this guide on Arch Linux requires a few changes
sudo -i
sed -Ei '/EnableAUR=true/s/^#//' /etc/pacman.conf
pamac build shim-signed
mv /boot/efi/EFI/boot/bootx64.efi /boot/efi/EFI/boot/grubx64.efi
cp /usr/share/shim-signed/shimx64.efi /boot/efi/EFI/boot/bootx64.efi
cp /usr/share/shim-signed/mmx64.efi /boot/efi/EFI/boot/
fdisk -l | grep "EFI System" | awk '{print $1}'
- Eg: If the command prints
/dev/sdaX/dev/sdais device &Xis partition number
efibootmgr --unicode --disk /dev/vda --part 1 --create --label "Shim" --loader /EFI/boot/bootx64.efi
mkdir -p /usr/share/secureboot/keys/
openssl req -newkey rsa:4096 -nodes -keyout /usr/share/secureboot/keys/MOK.key -new -x509 -sha256 -days 3650 -subj "/CN=Manjaro MOK/" -out /usr/share/secureboot/keys/MOK.crt
openssl x509 -outform DER -in /usr/share/secureboot/keys/MOK.crt -out /usr/share/secureboot/keys/MOK.cer
mkdir /boot/efi/keys
cp /usr/share/secureboot/keys/MOK.cer /boot/efi/keys/
sudo pacman -Sy sbsigntools
find /boot/ -maxdepth 1 -name 'vmlinuz-*' -exec sh -c \
'if ! sbverify --list {} 2>/dev/null | grep -q "signature certificates"; then
sbsign --key /usr/share/secureboot/keys/MOK.key --cert /usr/share/secureboot/keys/MOK.crt --output {} {}
fi' \;
MODULES="all_video
boot
btrfs
cat
chain
configfile
cpuid
cryptodisk
echo
efifwsetup
efinet
ext2
fat
font
gcry_arcfour
gcry_blowfish
gcry_camellia
gcry_cast5
gcry_crc
gcry_des
gcry_dsa
gcry_idea
gcry_md4
gcry_md5
gcry_rfc2268
gcry_rijndael
gcry_rmd160
gcry_rsa
gcry_seed
gcry_serpent
gcry_sha1
gcry_sha256
gcry_sha512
gcry_tiger
gcry_twofish
gcry_whirlpool
gettext
gfxmenu
gfxterm
gfxterm_background
gzio
halt
help
hfsplus
iso9660
jpeg
keystatus
linux
loadenv
loopback
ls
lsefi
lsefimmap
lsefisystab
lssal
luks
luks2
lvm
mdraid09
mdraid1x
memdisk
minicmd
normal
ntfs
part_apple
part_gpt
part_msdos
password_pbkdf2
play
png
probe
raid5rec
raid6rec
reboot
regexp
search
search_fs_file
search_fs_uuid
search_label
serial
sleep
smbios
squash4
test
tpm
true
video
xfs
zfs
zfscrypt
zfsinfo"
grub-install --target=x86_64-efi --efi-directory=/boot/efi --modules="${MODULES}" --sbat /usr/share/grub/sbat.csv
sbsign --key /usr/share/secureboot/keys/MOK.key --cert /usr/share/secureboot/keys/MOK.crt --output /boot/efi/EFI/Manjaro/grubx64.efi /boot/efi/EFI/Manjaro/grubx64.efi
cp /boot/efi/EFI/Manjaro/grubx64.efi /boot/efi/EFI/boot/
This may require updating in future versions. Refer to https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/build-efi-images for latest modules
Note: Does not work [broken]. Your system will still probably boot with errors.
Default Manjaro GRUB configuration files inserts insmod * to /boot/grub/grub.cfg
Edit /etc/grub.d/* & /usr/share/grub/grub-mkconfig_lib files to comment out any instances of insmod * or echo insmod *.
Do the same for /etc/default/grub & comment out GRUB_PRELOAD_MODULES=* line.
Download 999-signKernel.hook & 1000-signGrub.hook from this gist and place it into /etc/pacman.d/hooks
- Create the directory if if does not exist
- Also
1000-signGrub.hookis probably not required. Asgrubx64.efiis created only once.
Download signGrub.sh from this gist and place it into /usr/share/secureboot/
- Omit this step if you skipped sign Grub hook.
Run
chmod a+x /etc/pacman.d/hooks/{999-signKernel.hook,1000-signGrub.hook} /usr/share/secureboot/signGrub.sh
Reboot the system & Enable SecureBoot from the UEFI
An error will be displayed about security violation. Ignore this and press Enter twice, to enter MOK Management.
Now Enroll the MOK from keys/MOK.cer of the device ESP on the MOK Management screen.
Reboot the system and your Manjaro install is ready with secure-boot working.
With newer kernels, it could be that kernel signatures end up broken, so you will correctly boot into grub, but you won't be able to get into the actual OS with an error like "bad shim lock signature". To debug, for example (adapt depending on your kernel versions):
if you see:
this comment applies to you. The issue is that sbsign from the guide does an in-place sign (--output {} {}) which corrupts the signature when the PE/COFF sections have gaps (which is common with modern Linux kernels). The signature covers the wrong byte range.
You will need to re-sign everything properly:
this has fixed it for me.