Generate -fallback variant of boot entries for systemd-boot (#1583)

* Generate -fallback variant of boot entries for systemd-boot

---------

Co-authored-by: Anton Hvornum <anton@hvornum.se>
This commit is contained in:
Escape0707 2023-03-10 19:50:24 +09:00 committed by GitHub
parent 6c87996201
commit 5669f3ba46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 48 additions and 40 deletions

View File

@ -839,11 +839,12 @@ class Installer:
os.makedirs(f'{self.target}/boot/loader/entries') os.makedirs(f'{self.target}/boot/loader/entries')
for kernel in self.kernels: for kernel in self.kernels:
for variant in ("", "-fallback"):
# Setup the loader entry # Setup the loader entry
with open(f'{self.target}/boot/loader/entries/{self.init_time}_{kernel}.conf', 'w') as entry: with open(f'{self.target}/boot/loader/entries/{self.init_time}_{kernel}{variant}.conf', 'w') as entry:
entry.write('# Created by: archinstall\n') entry.write('# Created by: archinstall\n')
entry.write(f'# Created on: {self.init_time}\n') entry.write(f'# Created on: {self.init_time}\n')
entry.write(f'title Arch Linux ({kernel})\n') entry.write(f'title Arch Linux ({kernel}{variant})\n')
entry.write(f"linux /vmlinuz-{kernel}\n") entry.write(f"linux /vmlinuz-{kernel}\n")
if not is_vm(): if not is_vm():
vendor = cpu_vendor() vendor = cpu_vendor()
@ -853,7 +854,7 @@ class Installer:
entry.write("initrd /intel-ucode.img\n") entry.write("initrd /intel-ucode.img\n")
else: else:
self.log(f"Unknown CPU vendor '{vendor}' detected. Archinstall won't add any ucode to systemd-boot config.", level=logging.DEBUG) self.log(f"Unknown CPU vendor '{vendor}' detected. Archinstall won't add any ucode to systemd-boot config.", level=logging.DEBUG)
entry.write(f"initrd /initramfs-{kernel}.img\n") entry.write(f"initrd /initramfs-{kernel}{variant}.img\n")
# blkid doesn't trigger on loopback devices really well, # blkid doesn't trigger on loopback devices really well,
# so we'll use the old manual method until we get that sorted out. # so we'll use the old manual method until we get that sorted out.
root_fs_type = get_mount_fs_type(root_partition.filesystem) root_fs_type = get_mount_fs_type(root_partition.filesystem)
@ -880,7 +881,7 @@ class Installer:
kernel_options = f"options" kernel_options = f"options"
if self._disk_encryption and self._disk_encryption.hsm_device: if self._disk_encryption.hsm_device:
# Note: lsblk UUID must be used, not PARTUUID for sd-encrypt to work # Note: lsblk UUID must be used, not PARTUUID for sd-encrypt to work
kernel_options += f" rd.luks.name={real_device.uuid}=luksdev" kernel_options += f" rd.luks.name={real_device.uuid}=luksdev"
# Note: tpm2-device and fido2-device don't play along very well: # Note: tpm2-device and fido2-device don't play along very well:
@ -890,6 +891,13 @@ class Installer:
kernel_options += f" cryptdevice=PARTUUID={real_device.part_uuid}:luksdev" kernel_options += f" cryptdevice=PARTUUID={real_device.part_uuid}:luksdev"
entry.write(f'{kernel_options} root=/dev/mapper/luksdev {options_entry}') entry.write(f'{kernel_options} root=/dev/mapper/luksdev {options_entry}')
if self._disk_encryption and self._disk_encryption.hsm_device:
# Note: lsblk UUID must be used, not PARTUUID for sd-encrypt to work
kernel_options += f" rd.luks.name={real_device.uuid}=luksdev"
# Note: tpm2-device and fido2-device don't play along very well:
# https://github.com/archlinux/archinstall/pull/1196#issuecomment-1129715645
kernel_options += f" rd.luks.options=fido2-device=auto,password-echo=no"
else: else:
log(f"Identifying root partition by PARTUUID on {root_partition}, looking for '{root_partition.part_uuid}'.", level=logging.DEBUG) log(f"Identifying root partition by PARTUUID on {root_partition}, looking for '{root_partition.part_uuid}'.", level=logging.DEBUG)
entry.write(f'options root=PARTUUID={root_partition.part_uuid} {options_entry}') entry.write(f'options root=PARTUUID={root_partition.part_uuid} {options_entry}')