|
| 1 | +# Setup Sprout for Fedora with Secure Boot |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +- Modern Fedora release: tested on Fedora 43 x86_64. |
| 6 | +- EFI System Partition mounted on `/boot/efi` (the default) |
| 7 | +- You will need the following packages installed: `openssl`, `mokutil`, `sbsigntools`, `efibootmgr` |
| 8 | + |
| 9 | +**NOTE**: Fedora on ARM64 itself does not support Secure Boot consistently. |
| 10 | + |
| 11 | +## Step 1: Generate and Install Secure Boot Key |
| 12 | + |
| 13 | +```bash |
| 14 | +# Create a directory to store the Secure Boot MOK key and certificates. |
| 15 | +$ mkdir -p /etc/sprout/secure-boot |
| 16 | +# Change to the created directory. |
| 17 | +$ cd /etc/sprout/secure-boot |
| 18 | +# Generate a MOK key and certificate. |
| 19 | +$ openssl req \ |
| 20 | + -newkey rsa:4096 -nodes -keyout mok.key \ |
| 21 | + -new -x509 -sha256 -days 3650 -subj '/CN=Sprout Secure Boot/' \ |
| 22 | + -out mok.crt |
| 23 | +# Generate a DER encoded certificate for enrollment. |
| 24 | +$ openssl x509 -outform DER -in mok.crt -out mok.cer |
| 25 | +# Import the certificate into the Secure Boot environment. |
| 26 | +# This will ask you to make a password that will be used during enrollment. |
| 27 | +$ mokutil --import mok.cer |
| 28 | +# Reboot your machine. |
| 29 | +# During boot, MOK enrollment should appear. If it doesn't, ensure you are booting into the shim. |
| 30 | +# Press any key to begin MOK management. Select "Enroll MOK". |
| 31 | +# Select "View key 0", and ensure the subject says "CN=Sprout Secure Boot". |
| 32 | +# If the subject does not match, something has gone wrong with MOK enrollment. |
| 33 | +# Press Enter to continue, then select the "Continue" option. |
| 34 | +# When it asks to enroll the key, select the "Yes" option. |
| 35 | +# Enter the password that you created during the mokutil --import step. |
| 36 | +# Select "Reboot" to boot back into your Operating System. |
| 37 | +``` |
| 38 | + |
| 39 | +## Step 2: Prepare the Secure Boot Environment |
| 40 | + |
| 41 | +```bash |
| 42 | +# Create a directory for Sprout EFI artifacts. |
| 43 | +$ mkdir -p /boot/efi/EFI/sprout |
| 44 | + |
| 45 | +# For x86_64, copy the following artifacts to the Sprout EFI directory. |
| 46 | +$ cp /boot/efi/EFI/fedora/shimx64.efi /boot/efi/EFI/sprout/shimx64.efi |
| 47 | +$ cp /boot/efi/EFI/fedora/mmx64.efi /boot/efi/EFI/sprout/mmx64.efi |
| 48 | + |
| 49 | +# For aarch64, copy the following artifacts to the Sprout EFI directory. |
| 50 | +$ cp /boot/efi/EFI/fedora/shimaa64.efi /boot/efi/EFI/sprout/shimaa64.efi |
| 51 | +$ cp /boot/efi/EFI/fedora/mmaa64.efi /boot/efi/EFI/sprout/mmaa64.efi |
| 52 | +``` |
| 53 | + |
| 54 | +## Step 3: Install Unsigned Sprout |
| 55 | + |
| 56 | +Download the latest sprout.efi release from the [GitHub releases page](https://github.com/edera-dev/sprout/releases). |
| 57 | +For x86_64 systems, download the `sprout-x86_64.efi` file, and for ARM64 systems, download the `sprout-aarch64.efi` file. |
| 58 | +Copy the downloaded `sprout.efi` file to `/boot/efi/EFI/sprout/sprout.unsigned.efi` on your EFI System Partition. |
| 59 | + |
| 60 | +## Step 4: Sign Sprout for Secure Boot |
| 61 | + |
| 62 | +```bash |
| 63 | +# For x86_64, sign the unsigned Sprout artifact and name it grubaa64.efi which is what the shim will call. |
| 64 | +$ sbsign \ |
| 65 | + --key /etc/sprout/secure-boot/mok.key \ |
| 66 | + --cert /etc/sprout/secure-boot/mok.crt \ |
| 67 | + --output /boot/efi/EFI/sprout/grubx64.efi \ |
| 68 | + /boot/efi/EFI/sprout/sprout.unsigned.efi |
| 69 | + |
| 70 | +# For aarch64, sign the unsigned Sprout artifact and name it grubaa64.efi which is what the shim will call. |
| 71 | +$ sbsign \ |
| 72 | + --key /etc/sprout/secure-boot/mok.key \ |
| 73 | + --cert /etc/sprout/secure-boot/mok.crt \ |
| 74 | + --output /boot/efi/EFI/sprout/grubaa64.efi \ |
| 75 | + /boot/efi/EFI/sprout/sprout.unsigned.efi |
| 76 | +``` |
| 77 | + |
| 78 | +## Step 5: Install and Sign EFI Drivers |
| 79 | + |
| 80 | +You will need a filesystem EFI driver if `/boot` is not FAT32 or ExFAT. |
| 81 | + |
| 82 | +### ext4 |
| 83 | + |
| 84 | +Most Fedora systems use an ext4 filesystem for `/boot`, if that is the case, use the ext4 instructions here: |
| 85 | + |
| 86 | +Install the necessary `edk2-ext4` package: |
| 87 | + |
| 88 | +```bash |
| 89 | +# Install the ext4 driver from the package manager. |
| 90 | +$ dnf install edk2-ext4 |
| 91 | +``` |
| 92 | + |
| 93 | +Copy the ext4 driver to `/boot/efi/EFI/sprout/ext4.unsigned.efi`: |
| 94 | + |
| 95 | +```bash |
| 96 | +# For x86_64, copy the ext4x64.efi driver to the Sprout EFI directory. |
| 97 | +$ cp /usr/share/edk2/drivers/ext4x64.efi /boot/efi/EFI/sprout/ext4.unsigned.efi |
| 98 | + |
| 99 | +# For aarch64, copy the ext4aa64.efi driver to the Sprout EFI directory. |
| 100 | +$ cp /usr/share/edk2/drivers/ext4aa64.efi /boot/efi/EFI/sprout/ext4.unsigned.efi |
| 101 | +``` |
| 102 | + |
| 103 | +```bash |
| 104 | +# Sign the ext4 driver at ext4.unsigned.efi, placing it at ext4.efi, which will be used in the configuration. |
| 105 | +$ sbsign \ |
| 106 | + --key /etc/sprout/secure-boot/mok.key \ |
| 107 | + --cert /etc/sprout/secure-boot/mok.crt \ |
| 108 | + --output /boot/efi/EFI/sprout/ext4.efi \ |
| 109 | + /boot/efi/EFI/sprout/ext4.unsigned.efi |
| 110 | +``` |
| 111 | + |
| 112 | +### Other Filesystems |
| 113 | + |
| 114 | +If you need another driver, you can download EFI filesystem drivers from [EfiFs releases](https://github.com/pbatard/EfiFs/releases). |
| 115 | +Copy the driver to `/boot/efi/EFI/sprout/DRIVER_NAME.unsigned.efi` for signing, then sign it like this: |
| 116 | + |
| 117 | +```bash |
| 118 | +# Sign your driver, placing it at DRIVER_NAME.efi, which will be used in the configuration. |
| 119 | +$ sbsign \ |
| 120 | + --key /etc/sprout/secure-boot/mok.key \ |
| 121 | + --cert /etc/sprout/secure-boot/mok.crt \ |
| 122 | + --output /boot/efi/EFI/sprout/DRIVER_NAME.efi \ |
| 123 | + /boot/efi/EFI/sprout/DRIVER_NAME.unsigned.efi |
| 124 | +``` |
| 125 | + |
| 126 | +You will add the driver in your Sprout configuration below, like this: |
| 127 | + |
| 128 | +```toml |
| 129 | +[drivers.DRIVER_NAME] |
| 130 | +path = "\\EFI\\sprout\\DRIVER_NAME.efi" |
| 131 | +``` |
| 132 | + |
| 133 | +## Step 6: Create Sprout Configuration |
| 134 | + |
| 135 | +Write the following to the file `/boot/efi/sprout.toml`: |
| 136 | + |
| 137 | +```toml |
| 138 | +# sprout configuration: version 1 |
| 139 | +version = 1 |
| 140 | + |
| 141 | +# load an ext4 EFI driver. |
| 142 | +# skip this if you do not have a filesystem driver. |
| 143 | +# if your filesystem driver is not named ext4, change accordingly. |
| 144 | +[drivers.ext4] |
| 145 | +path = "\\EFI\\sprout\\ext4.efi" |
| 146 | + |
| 147 | +# global options. |
| 148 | +[options] |
| 149 | +# enable autoconfiguration by detecting bls enabled |
| 150 | +# filesystems and generating boot entries for them. |
| 151 | +autoconfigure = true |
| 152 | +``` |
| 153 | + |
| 154 | +Ensure you add the signed driver paths to the configuration, not the unsigned ones. |
| 155 | +If you do not have any drivers, exclude the drivers section entirely. |
| 156 | + |
| 157 | +## Step 7: Configure Sprout Boot Entry |
| 158 | + |
| 159 | +In the following commands, replace /dev/BLOCK_DEVICE with the device that houses your GPT partition table, |
| 160 | +and PARTITION_NUMBER with the partition number of the EFI System Partition. For example, if your EFI System Partition is |
| 161 | +`/dev/sda1`, the BLOCK_DEVICE would be `/dev/sda` and the PARTITION_NUMBER would be `1` |
| 162 | + |
| 163 | +```bash |
| 164 | +# For x86_64, run this command to add Sprout as the default boot entry. |
| 165 | +$ efibootmgr -d /dev/BLOCK_DEVICE -p PARTITION_NUMBER -c -L 'Sprout' -l '\EFI\sprout\shimx64.efi' |
| 166 | + |
| 167 | +# For aarch64, run this command to add Sprout as the default boot entry. |
| 168 | +$ efibootmgr -d /dev/BLOCK_DEVICE -p PARTITION_NUMBER -c -L 'Sprout' -l '\EFI\sprout\shimaa64.efi' |
| 169 | +``` |
| 170 | + |
| 171 | +Reboot your machine and it should boot into Sprout. |
| 172 | +If Sprout fails to boot, it should boot into the original bootloader. |
0 commit comments