Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _get_kernel_params() #2064

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 40 additions & 51 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,44 @@ def _get_root_partition(self) -> Optional[disk.PartitionModification]:
return root
return None

def _get_kernel_params(self, root_partition: disk.PartitionModification) -> List[str]:
kernel_parameters = []

if root_partition in self._disk_encryption.partitions:
# TODO: We need to detect if the encrypted device is a whole disk encryption,
# or simply a partition encryption. Right now we assume it's a partition (and we always have)
debug('Root partition is an encrypted device, identifying by PARTUUID: {root_partition.partuuid}')

if self._disk_encryption and self._disk_encryption.hsm_device:
# Note: lsblk UUID must be used, not PARTUUID for sd-encrypt to work
kernel_parameters.append(f'rd.luks.name={root_partition.uuid}=luksdev')
# Note: tpm2-device and fido2-device don't play along very well:
# https://github.com/archlinux/archinstall/pull/1196#issuecomment-1129715645
kernel_parameters.append('rd.luks.options=fido2-device=auto,password-echo=no')
else:
kernel_parameters.append(f'cryptdevice=PARTUUID={root_partition.partuuid}:luksdev')

kernel_parameters.append('root=/dev/mapper/luksdev')
else:
debug(f'Identifying root partition by PARTUUID: {root_partition.partuuid}')
kernel_parameters.append(f'root=PARTUUID={root_partition.partuuid}')

# Zswap should be disabled when using zram.
# https://github.com/archlinux/archinstall/issues/881
if self._zram_enabled:
kernel_parameters.append('zswap.enabled=0')

for sub_vol in root_partition.btrfs_subvols:
if sub_vol.is_root():
kernel_parameters.append(f'rootflags=subvol={sub_vol.name}')
break

kernel_parameters.append('rw')
kernel_parameters.append(f'rootfstype={root_partition.safe_fs_type.fs_type_mount}')
kernel_parameters.extend(self._kernel_params)

return kernel_parameters

def _add_systemd_bootloader(
self,
boot_partition: disk.PartitionModification,
Expand Down Expand Up @@ -798,42 +836,7 @@ def _add_systemd_bootloader(
"Archinstall won't add any ucode to systemd-boot config.",
)

options_entry = []

if root_partition in self._disk_encryption.partitions:
# TODO: We need to detect if the encrypted device is a whole disk encryption,
# or simply a partition encryption. Right now we assume it's a partition (and we always have)
debug('Root partition is an encrypted device, identifying by PARTUUID: {root_partition.partuuid}')

if self._disk_encryption and self._disk_encryption.hsm_device:
# Note: lsblk UUID must be used, not PARTUUID for sd-encrypt to work
options_entry.append(f'rd.luks.name={root_partition.uuid}=luksdev')
# Note: tpm2-device and fido2-device don't play along very well:
# https://github.com/archlinux/archinstall/pull/1196#issuecomment-1129715645
options_entry.append('rd.luks.options=fido2-device=auto,password-echo=no')
else:
options_entry.append(f'cryptdevice=PARTUUID={root_partition.partuuid}:luksdev')

options_entry.append('root=/dev/mapper/luksdev')
else:
debug(f'Identifying root partition by PARTUUID: {root_partition.partuuid}')
options_entry.append(f'root=PARTUUID={root_partition.partuuid}')

# Zswap should be disabled when using zram.
# https://github.com/archlinux/archinstall/issues/881
if self._zram_enabled:
options_entry.append('zswap.enabled=0')

for sub_vol in root_partition.btrfs_subvols:
if sub_vol.is_root():
options_entry.append(f'rootflags=subvol={sub_vol.name}')
break

options_entry.append('rw')
options_entry.append(f'rootfstype={root_partition.safe_fs_type.fs_type_mount}')
options_entry.extend(self._kernel_params)

options = 'options ' + ' '.join(options_entry) + '\n'
options = 'options ' + ' '.join(self._get_kernel_params(root_partition)) + '\n'

for kernel in self.kernels:
for variant in ("", "-fallback"):
Expand Down Expand Up @@ -1058,21 +1061,7 @@ def _add_efistub_bootloader(
else:
debug(f"Unknown CPU vendor '{vendor}' detected. Archinstall won't add any ucode to firmware boot entry.")

kernel_parameters = []

if root_partition in self._disk_encryption.partitions:
# TODO: We need to detect if the encrypted device is a whole disk encryption,
# or simply a partition encryption. Right now we assume it's a partition (and we always have)
debug(f'Root partition is an encrypted device identifying by PARTUUID: {root_partition.partuuid}')
kernel_parameters.append(f'cryptdevice=PARTUUID={root_partition.partuuid}:luksdev')
kernel_parameters.append('root=/dev/mapper/luksdev')
else:
debug(f'Identifying root partition by PARTUUID: {root_partition.partuuid}')
kernel_parameters.append(f'root=PARTUUID={root_partition.partuuid}')

kernel_parameters.append('rw')
kernel_parameters.append(f'rootfstype={root_partition.safe_fs_type.value}')
kernel_parameters.extend(self._kernel_params)
kernel_parameters = self._get_kernel_params(root_partition)

parent_dev_path = disk.device_handler.get_parent_device_path(boot_partition.safe_dev_path)

Expand Down