Skip to content

Commit 8a6264f

Browse files
committed
Add Secure Boot support
Fixes #246
1 parent 42440f3 commit 8a6264f

File tree

3 files changed

+57
-21
lines changed

3 files changed

+57
-21
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ For new features, improvements and bugs, fill an issue in GitHub or make a pull
7272
* **Periodic TRIM** for SSD storage
7373
* Intel and AMD **processors microcode**
7474
* Optional **swap file**
75-
* **VirtualBox guest additions** and **VMware tools** support
75+
* **PipeWire** support
76+
* **Secure Boot** support
7677
* **Kernel compression** and **custom parameters**
7778
* **Users creation** and **add to sudoers**
7879
* **systemd units enable or disable**
7980
* **systemd-homed** support
8081
* **systemd GPT partition automounting** support
81-
* **PipeWire** support
8282
* **Multilib** support
8383
* **Files provision** support
84+
* **VirtualBox guest additions** and **VMware tools** support
8485
* **SSH install** and **cloud-init** support
8586
* Arch Linux custom **packages installation** and **repositories installation**
8687
* Flatpak utility installation and **Flatpak packages installation**
@@ -324,6 +325,7 @@ https://www.archlinux.org/download/
324325
* https://wiki.archlinux.org/title/Qtile
325326
* https://wiki.archlinux.org/title/REFInd
326327
* https://wiki.archlinux.org/title/Reflector
328+
* https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/Secure_Boot
327329
* https://wiki.archlinux.org/title/Solid_state_drive/NVMe
328330
* https://wiki.archlinux.org/title/Solid_State_Drives
329331
* https://wiki.archlinux.org/title/Swap

alis.conf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Some variables values are preceded by a ! character, this means that the value is ignored.
44
# Some variables accept a single value others accept multiple values as annotated in the comments.
55
# Some variables are boolean with a value of true or false.
6+
# Some variables are experimental feature (use it and report in case of errors)
67
#
78
# Read the Arch Linux wiki pages to learn more about the variables values.
89
# https://github.com/picodotdev/alis/blob/master/README.md
@@ -123,7 +124,7 @@ USER_PASSWORD_RETYPE="ask"
123124
ADDITIONAL_USERS=() # eg. ("user1=password1" "user2=password2")
124125

125126
## systemd-homed
126-
### SYSTEMD_HOMED "true" value requires interactivity to set user password
127+
### SYSTEMD_HOMED (experimental) "true" value requires interactivity to set user password
127128
SYSTEMD_HOMED="false"
128129
SYSTEMD_HOMED_STORAGE="!auto !luks !subvolume directory !fscrypt !cifs"
129130
SYSTEMD_HOMED_STORAGE_LUKS_TYPE="auto !ext4 !btrfs !xfs"
@@ -133,7 +134,7 @@ SYSTEMD_HOMED_STORAGE_CIFS_SERVICE=""
133134
# mkinitcpio
134135
## HOOKS are the system hooks to execute to build the initial ramdisk.
135136
## MODULES are used to specify the modules to load before anything to execute to build the initial ramdisk.
136-
## UKI generate and use a Unified Kernel Image.
137+
## UKI (experimental) generate and use a Unified Kernel Image.
137138
### Generally, it is not necessary to modify, alis enables or disables some hooks
138139
### taking in account other variables values like bootloader or device encryption.
139140
HOOKS="base !udev !usr !resume !systemd !btrfs autodetect keyboard !keymap !consolefont !sd-vconsole modconf block !net !dmraid !mdadm !mdadm_udev !encrypt !sd-encrypt !lvm2 fsck filesystems"
@@ -143,7 +144,9 @@ UKI="false"
143144
# bootloader
144145
## BOOTLOADER system boot loader.
145146
### With auto value grub is used for BIOS system, systemd for UEFI system.
147+
## SECURE_BOOT (experimental) use secure boot.
146148
BOOTLOADER="auto !grub !refind !systemd !efistub" # (single)
149+
SECURE_BOOT="false"
147150

148151
# shell
149152
## CUSTOM_SHELL configures an alternative custom shell interpreter.
@@ -162,7 +165,7 @@ DISPLAY_MANAGER="auto !gdm !sddm !lightdm !lxdm" # (single)
162165
### It is recommended to install packages after base installation and reboot.
163166
PACKAGES_MULTILIB="false"
164167
PACKAGES_INSTALL="false"
165-
PACKAGES_PIPEWIRE="false"
168+
PACKAGES_PIPEWIRE="true"
166169

167170
# provision
168171
## PROVISION provisions the files placed in files directory on the installed system (preserving directory structure). This is useful to copy some configuration files.

alis.sh

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ function check_variables() {
204204
check_variables_value "HOOKS" "$HOOKS"
205205
check_variables_boolean "UKI" "$UKI"
206206
check_variables_list "BOOTLOADER" "$BOOTLOADER" "auto grub refind systemd efistub" "true" "true"
207+
check_variables_boolean "SECURE_BOOT" "$SECURE_BOOT"
207208
check_variables_list "CUSTOM_SHELL" "$CUSTOM_SHELL" "bash zsh dash fish" "true" "true"
208209
check_variables_list "DESKTOP_ENVIRONMENT" "$DESKTOP_ENVIRONMENT" "gnome kde xfce mate cinnamon lxde i3-wm i3-gaps deepin budgie bspwm awesome qtile openbox leftwm dusk" "false" "true"
209210
check_variables_list "DISPLAY_MANAGER" "$DISPLAY_MANAGER" "auto gdm sddm lightdm lxdm" "true" "true"
@@ -316,6 +317,10 @@ function check_facts() {
316317
if [ "$BIOS_TYPE" == "bios" ]; then
317318
check_variables_list "BOOTLOADER" "$BOOTLOADER" "grub" "true" "true"
318319
fi
320+
321+
if [ "$SECURE_BOOT" == "true" ]; then
322+
check_variables_list "BOOTLOADER" "$BOOTLOADER" "grub refind systemd" "true" "true"
323+
fi
319324
}
320325

321326
function prepare() {
@@ -802,7 +807,7 @@ function mkinitcpio_configuration() {
802807
fi
803808

804809
if [ "$UKI" == "true" ]; then
805-
mkdir -p "${MNT_DIR}$ESP_DIRECTORY/EFI/linux"
810+
mkdir -p "${MNT_DIR}${ESP_DIRECTORY}/EFI/linux"
806811

807812
mkinitcpio_preset "linux"
808813
if [ -n "$KERNELS" ]; then
@@ -1140,9 +1145,9 @@ ALL_microcode=(/boot/*-ucode.img)
11401145
11411146
PRESETS=('default' 'fallback')
11421147
1143-
default_uki="$ESP_DIRECTORY/EFI/linux/archlinux-$KERNEL.efi"
1148+
default_uki="${ESP_DIRECTORY}/EFI/linux/archlinux-$KERNEL.efi"
11441149
1145-
fallback_uki="$ESP_DIRECTORY/EFI/linux/archlinux-$KERNEL-fallback.efi"
1150+
fallback_uki="${ESP_DIRECTORY}/EFI/linux/archlinux-$KERNEL-fallback.efi"
11461151
fallback_options="-S autodetect"
11471152
EOT
11481153
}
@@ -1229,6 +1234,15 @@ function bootloader() {
12291234

12301235
CMDLINE_LINUX=$(trim_variable "$CMDLINE_LINUX")
12311236

1237+
if [ "$SECURE_BOOT" == "true" ]; then
1238+
curl --output PreLoader.efi https://blog.hansenpartnership.com/wp-uploads/2013/PreLoader.efi
1239+
curl --output HashTool.efi https://blog.hansenpartnership.com/wp-uploads/2013/HashTool.efi
1240+
md5sum PreLoader.efi > PreLoader.efi.md5
1241+
md5sum HashTool.efi > HashTool.efi.md5
1242+
echo "4f7a4f566781869d252a09dc84923a82 PreLoader.efi" | md5sum -c -
1243+
echo "45639d23aa5f2a394b03a65fc732acf2 HashTool.efi" | md5sum -c -
1244+
fi
1245+
12321246
case "$BOOTLOADER" in
12331247
"grub" )
12341248
bootloader_grub
@@ -1265,21 +1279,26 @@ function bootloader_grub() {
12651279
echo ""
12661280
echo "# alis"
12671281
echo "GRUB_DISABLE_SUBMENU=y"
1268-
}>> "${MNT_DIR}"/etc/default/grub
1282+
}>> "${MNT_DIR}"/etc/default/grub
12691283

12701284
if [ "$BIOS_TYPE" == "uefi" ]; then
12711285
pacman_install "efibootmgr"
1272-
arch-chroot "${MNT_DIR}" grub-install --target=x86_64-efi --bootloader-id=grub --efi-directory="$ESP_DIRECTORY" --recheck
1273-
#arch-chroot "${MNT_DIR}" efibootmgr --create --disk $DEVICE --part $PARTITION_BOOT_NUMBER --loader /EFI/grub/grubx64.efi --label "GRUB Boot Manager" --verbose
1286+
arch-chroot "${MNT_DIR}" grub-install --target=x86_64-efi --bootloader-id=grub --efi-directory="${ESP_DIRECTORY}" --recheck
12741287
fi
12751288
if [ "$BIOS_TYPE" == "bios" ]; then
12761289
arch-chroot "${MNT_DIR}" grub-install --target=i386-pc --recheck "$DEVICE"
12771290
fi
12781291

1279-
arch-chroot "${MNT_DIR}" grub-mkconfig -o "$BOOT_DIRECTORY/grub/grub.cfg"
1292+
arch-chroot "${MNT_DIR}" grub-mkconfig -o "${BOOT_DIRECTORY}/grub/grub.cfg"
1293+
1294+
if [ "$SECURE_BOOT" == "true" ]; then
1295+
cp {PreLoader,HashTool}.efi "${MNT_DIR}${ESP_DIRECTORY}/EFI/grub"
1296+
cp "${ESP_DIRECTORY}/EFI/grub/grubx64.efi" "${MNT_DIR}${ESP_DIRECTORY}/EFI/systemd/loader.efi"
1297+
arch-chroot "${MNT_DIR}" efibootmgr --unicode --disk "$DEVICE" --part 1 --create --label "Arch Linux (PreLoader)" --loader "/EFI/grub/PreLoader.efi"
1298+
fi
12801299

12811300
if [ "$VIRTUALBOX" == "true" ]; then
1282-
echo -n "\EFI\grub\grubx64.efi" > "${MNT_DIR}$ESP_DIRECTORY/startup.nsh"
1301+
echo -n "\EFI\grub\grubx64.efi" > "${MNT_DIR}${ESP_DIRECTORY}/startup.nsh"
12831302
fi
12841303
}
12851304

@@ -1288,9 +1307,15 @@ function bootloader_refind() {
12881307
arch-chroot "${MNT_DIR}" refind-install
12891308

12901309
arch-chroot "${MNT_DIR}" rm /boot/refind_linux.conf
1291-
arch-chroot "${MNT_DIR}" sed -i 's/^timeout.*/timeout 5/' "$ESP_DIRECTORY/EFI/refind/refind.conf"
1292-
arch-chroot "${MNT_DIR}" sed -i 's/^#scan_all_linux_kernels.*/scan_all_linux_kernels false/' "$ESP_DIRECTORY/EFI/refind/refind.conf"
1293-
#arch-chroot "${MNT_DIR}" sed -i 's/^#default_selection "+,bzImage,vmlinuz"/default_selection "+,bzImage,vmlinuz"/' "$ESP_DIRECTORY/EFI/refind/refind.conf"
1310+
arch-chroot "${MNT_DIR}" sed -i 's/^timeout.*/timeout 5/' "${ESP_DIRECTORY}/EFI/refind/refind.conf"
1311+
arch-chroot "${MNT_DIR}" sed -i 's/^#scan_all_linux_kernels.*/scan_all_linux_kernels false/' "${ESP_DIRECTORY}/EFI/refind/refind.conf"
1312+
#arch-chroot "${MNT_DIR}" sed -i 's/^#default_selection "+,bzImage,vmlinuz"/default_selection "+,bzImage,vmlinuz"/' "${ESP_DIRECTORY}/EFI/refind/refind.conf"
1313+
1314+
if [ "$SECURE_BOOT" == "true" ]; then
1315+
cp {PreLoader,HashTool}.efi "${ESP_DIRECTORY}/EFI/refind"
1316+
cp "${ESP_DIRECTORY}/EFI/refind/refind_x64.efi" "${MNT_DIR}${ESP_DIRECTORY}/EFI/refind/loader.efi"
1317+
arch-chroot "${MNT_DIR}" efibootmgr --unicode --disk "$DEVICE" --part 1 --create --label "Arch Linux (PreLoader)" --loader "/EFI/refind/PreLoader.efi"
1318+
fi
12941319

12951320
if [ "$UKI" == "false" ]; then
12961321
bootloader_refind_entry "linux"
@@ -1329,6 +1354,12 @@ When = PostTransaction
13291354
Exec = /usr/bin/systemctl restart systemd-boot-update.service
13301355
EOT
13311356

1357+
if [ "$SECURE_BOOT" == "true" ]; then
1358+
cp {PreLoader,HashTool}.efi "${ESP_DIRECTORY}/EFI/systemd"
1359+
cp "${ESP_DIRECTORY}/EFI/systemd/systemd-bootx64.efi" "${MNT_DIR}${ESP_DIRECTORY}/EFI/systemd/loader.efi"
1360+
arch-chroot "${MNT_DIR}" efibootmgr --unicode --disk "$DEVICE" --part 1 --create --label "Arch Linux (PreLoader)" --loader "/EFI/systemd/PreLoader.efi"
1361+
fi
1362+
13321363
if [ "$UKI" == "true" ]; then
13331364
cat <<EOT > "${MNT_DIR}${ESP_DIRECTORY}/loader/loader.conf"
13341365
# alis
@@ -1343,7 +1374,7 @@ default archlinux.conf
13431374
editor 0
13441375
EOT
13451376

1346-
arch-chroot "${MNT_DIR}" mkdir -p "$ESP_DIRECTORY/loader/entries/"
1377+
arch-chroot "${MNT_DIR}" mkdir -p "${ESP_DIRECTORY}/loader/entries/"
13471378

13481379
bootloader_systemd_entry "linux"
13491380
if [ -n "$KERNELS" ]; then
@@ -1433,15 +1464,15 @@ function bootloader_efistub_entry() {
14331464
local MICROCODE=""
14341465

14351466
if [ "$UKI" == "true" ]; then
1436-
arch-chroot "${MNT_DIR}" efibootmgr --disk "$DEVICE" --part 1 --create --label "Arch Linux ($KERNEL fallback)" --loader "EFI\linux\archlinux-$KERNEL-fallback.efi" --unicode --verbose
1437-
arch-chroot "${MNT_DIR}" efibootmgr --disk "$DEVICE" --part 1 --create --label "Arch Linux ($KERNEL)" --loader "EFI\linux\archlinux-$KERNEL.efi" --unicode --verbose
1467+
arch-chroot "${MNT_DIR}" efibootmgr --unicode --disk "$DEVICE" --part 1 --create --label "Arch Linux ($KERNEL fallback)" --loader "EFI\linux\archlinux-$KERNEL-fallback.efi" --unicode --verbose
1468+
arch-chroot "${MNT_DIR}" efibootmgr --unicode --disk "$DEVICE" --part 1 --create --label "Arch Linux ($KERNEL)" --loader "EFI\linux\archlinux-$KERNEL.efi" --unicode --verbose
14381469
else
14391470
if [ -n "$INITRD_MICROCODE" ]; then
14401471
local MICROCODE="initrd=\\$INITRD_MICROCODE"
14411472
fi
14421473

1443-
arch-chroot "${MNT_DIR}" efibootmgr --disk "$DEVICE" --part 1 --create --label "Arch Linux ($KERNEL)" --loader /vmlinuz-"$KERNEL" --unicode "$CMDLINE_LINUX $CMDLINE_LINUX_ROOT rw $MICROCODE initrd=\initramfs-$KERNEL.img" --verbose
1444-
arch-chroot "${MNT_DIR}" efibootmgr --disk "$DEVICE" --part 1 --create --label "Arch Linux ($KERNEL fallback)" --loader /vmlinuz-"$KERNEL" --unicode "$CMDLINE_LINUX $CMDLINE_LINUX_ROOT rw $MICROCODE initrd=\initramfs-$KERNEL-fallback.img" --verbose
1474+
arch-chroot "${MNT_DIR}" efibootmgr --unicode --disk "$DEVICE" --part 1 --create --label "Arch Linux ($KERNEL)" --loader /vmlinuz-"$KERNEL" --unicode "$CMDLINE_LINUX $CMDLINE_LINUX_ROOT rw $MICROCODE initrd=\initramfs-$KERNEL.img" --verbose
1475+
arch-chroot "${MNT_DIR}" efibootmgr --unicode --disk "$DEVICE" --part 1 --create --label "Arch Linux ($KERNEL fallback)" --loader /vmlinuz-"$KERNEL" --unicode "$CMDLINE_LINUX $CMDLINE_LINUX_ROOT rw $MICROCODE initrd=\initramfs-$KERNEL-fallback.img" --verbose
14451476
fi
14461477
}
14471478

0 commit comments

Comments
 (0)