Sakaki's EFI Install Guide/Configuring Secure Boot/Using KeyTool
Configuring Secure Boot using KeyTool
If you encountered the "wrong filesystem permissions" issue when trying to use efi-updatevar and you cannot add keys with your BIOS, there is another solution: the KeyTool EFI application that comes with efitools. As a prerequisite, I recommend using this script to generate new keys, as it ensures you have .esl files for all your own keys. Before running that script, copy the Windows keys to a different directory (like /etc/efikeys/old), as the script will probably erase them. After generating keys with that script, follow these steps to install them, as well as the original keys, to your system:
- Mount the EFI flash drive using a command like:
mount -o rw /dev/sdZn /mnt
- Copy the keys to the drive:
mkdir -v -p /mnt/keys/old
cp *.esl *.crt *.auth /mnt/keys/
cp *.esl *.crt *.auth /mnt/keys/old
- Back up the old bootx64.efi on your flash drive and copy the KeyTool in its place:
mv /mnt/EFI/Boot/bootx64.efi /mnt/EFI/Boot/bootx64.efi.gentoo
cp /usr/share/efitools/efi/KeyTool.efi /mnt/EFI/Boot/bootx64.efi
- Reboot to BIOS and reset your keys (enter Setup Mode) again
- Using your BIOS's boot menu or your favorite equivalent, boot to the USB drive (not to the Gentoo entry, but instead to the generic entry)
- You'll be presented with a blue screen with a menu in the middle. Select "Edit Keys".
- Starting with the Key Exchange Key (notably not the Platform Key) and working your way down, select each key type (except for Machine Owner Key) and do two things:
- Replace key(s) with the original keys, navigating the directory tree until you find where you put them.Note
With some BIOSes, you may encounter problems inserting your db.crt under KeyTool, once your KEK has been inserted. If this occurs, try appending (in KeyTool) your db.auth file instead (creation of this file was described in a note in the main text).
- Add New Key with your key, navigating the directory tree until you find them. You don't need to do this for the Forbidden signatures.
- Replace key(s) with the original keys, navigating the directory tree until you find where you put them.
- Once you've done this for all the keys other than the PK, select that one and replace it with your own key.
- Press ESC until you get back to the main menu, then select "Exit". You're done!