From f2909a7c7239a8beb1d289d088e4e3bdbed1cef1 Mon Sep 17 00:00:00 2001 From: oddlama Date: Sat, 25 Apr 2020 15:12:35 +0200 Subject: [PATCH] Added dracut cmdline generation --- scripts/internal_config.sh | 5 +++++ scripts/main.sh | 23 +++++++++++++++-------- scripts/utils.sh | 25 ++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/scripts/internal_config.sh b/scripts/internal_config.sh index c487c2d..8cd52ac 100644 --- a/scripts/internal_config.sh +++ b/scripts/internal_config.sh @@ -25,6 +25,8 @@ USED_LUKS=false # An array of disk related actions to perform DISK_ACTIONS=() +# An array of dracut parameters needed to boot the selected configuration +DISK_DRACUT_CMDLINE=() # An associative array from disk id to a resolvable string declare -A DISK_ID_TO_RESOLVABLE # An associative array from disk id to parent gpt disk id (only for partitions) @@ -159,6 +161,7 @@ create_raid() { local new_id="${arguments[new_id]}" create_resolve_entry "$new_id" mdadm "${DISK_ID_TO_UUID[$new_id]}" + DISK_DRACUT_CMDLINE+=("rd.md.uuid=$(uuid_to_mduuid "$new_id")") DISK_ACTIONS+=("action=create_raid" "$@" ";") } @@ -175,9 +178,11 @@ create_luks() { create_new_id new_id verify_existing_id id + local id="${arguments[id]}" local new_id="${arguments[new_id]}" local name="${arguments[name]}" create_resolve_entry "$new_id" luks "$name" + DISK_DRACUT_CMDLINE+=("rd.luks.uuid=$id") DISK_ACTIONS+=("action=create_luks" "$@" ";") } diff --git a/scripts/main.sh b/scripts/main.sh index b25dbb8..bff9949 100755 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -139,12 +139,9 @@ generate_initramfs() { } get_cmdline() { - local cmdline=() - cmdline+=("root=UUID=$rootuuid") - # TODO in order.... - cmdline+=("rd.md.uuid=$todo") - cmdline+=("rd.luks.uuid=$todo") - echo -n "${cmdline[*]}" + local rootdev="$(resolve_device_by_id "$DISK_ID_ROOT")" + local rootuuid="$(get_blkid_field_by_device 'UUID' "$rootdev")" + echo -n "${DISK_DRACUT_CMDLINE[*]} root=UUID=$rootuuid" } install_kernel_efi() { @@ -166,11 +163,10 @@ install_kernel_efi() { # Create boot entry einfo "Creating efi boot entry" - local linuxdev="$(resolve_device_by_id "$DISK_ID_ROOT")" local efipartdev="$(resolve_device_by_id "$DISK_ID_EFI")" local efipartnum="${efipartdev: -1}" local gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")" - try efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\EFI\vmlinuz.efi' --unicode 'initrd=\EFI\initramfs.img' + try efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\EFI\vmlinuz.efi' --unicode 'initrd=\EFI\initramfs.img'" $(get_cmdline)" } install_kernel_bios() { @@ -188,6 +184,17 @@ install_kernel_bios() { einfo "Installing syslinux" local biosdev="$(resolve_device_by_id "$DISK_ID_BIOS")" syslinux --install "$biosdev" + + # Create syslinux.cfg + cat >/boot/syslinux/syslinux.cfg <