Added dracut cmdline generation
This commit is contained in:
parent
2b323d0c0d
commit
f2909a7c72
|
@ -25,6 +25,8 @@ USED_LUKS=false
|
||||||
|
|
||||||
# An array of disk related actions to perform
|
# An array of disk related actions to perform
|
||||||
DISK_ACTIONS=()
|
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
|
# An associative array from disk id to a resolvable string
|
||||||
declare -A DISK_ID_TO_RESOLVABLE
|
declare -A DISK_ID_TO_RESOLVABLE
|
||||||
# An associative array from disk id to parent gpt disk id (only for partitions)
|
# 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]}"
|
local new_id="${arguments[new_id]}"
|
||||||
create_resolve_entry "$new_id" mdadm "${DISK_ID_TO_UUID[$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" "$@" ";")
|
DISK_ACTIONS+=("action=create_raid" "$@" ";")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +178,11 @@ create_luks() {
|
||||||
create_new_id new_id
|
create_new_id new_id
|
||||||
verify_existing_id id
|
verify_existing_id id
|
||||||
|
|
||||||
|
local id="${arguments[id]}"
|
||||||
local new_id="${arguments[new_id]}"
|
local new_id="${arguments[new_id]}"
|
||||||
local name="${arguments[name]}"
|
local name="${arguments[name]}"
|
||||||
create_resolve_entry "$new_id" luks "$name"
|
create_resolve_entry "$new_id" luks "$name"
|
||||||
|
DISK_DRACUT_CMDLINE+=("rd.luks.uuid=$id")
|
||||||
DISK_ACTIONS+=("action=create_luks" "$@" ";")
|
DISK_ACTIONS+=("action=create_luks" "$@" ";")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,12 +139,9 @@ generate_initramfs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_cmdline() {
|
get_cmdline() {
|
||||||
local cmdline=()
|
local rootdev="$(resolve_device_by_id "$DISK_ID_ROOT")"
|
||||||
cmdline+=("root=UUID=$rootuuid")
|
local rootuuid="$(get_blkid_field_by_device 'UUID' "$rootdev")"
|
||||||
# TODO in order....
|
echo -n "${DISK_DRACUT_CMDLINE[*]} root=UUID=$rootuuid"
|
||||||
cmdline+=("rd.md.uuid=$todo")
|
|
||||||
cmdline+=("rd.luks.uuid=$todo")
|
|
||||||
echo -n "${cmdline[*]}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_kernel_efi() {
|
install_kernel_efi() {
|
||||||
|
@ -166,11 +163,10 @@ install_kernel_efi() {
|
||||||
|
|
||||||
# Create boot entry
|
# Create boot entry
|
||||||
einfo "Creating efi 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 efipartdev="$(resolve_device_by_id "$DISK_ID_EFI")"
|
||||||
local efipartnum="${efipartdev: -1}"
|
local efipartnum="${efipartdev: -1}"
|
||||||
local gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")"
|
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() {
|
install_kernel_bios() {
|
||||||
|
@ -188,6 +184,17 @@ install_kernel_bios() {
|
||||||
einfo "Installing syslinux"
|
einfo "Installing syslinux"
|
||||||
local biosdev="$(resolve_device_by_id "$DISK_ID_BIOS")"
|
local biosdev="$(resolve_device_by_id "$DISK_ID_BIOS")"
|
||||||
syslinux --install "$biosdev"
|
syslinux --install "$biosdev"
|
||||||
|
|
||||||
|
# Create syslinux.cfg
|
||||||
|
cat >/boot/syslinux/syslinux.cfg <<EOF
|
||||||
|
DEFAULT gentoo
|
||||||
|
PROMPT 0
|
||||||
|
TIMEOUT 0
|
||||||
|
|
||||||
|
LABEL gentoo
|
||||||
|
LINUX ../vmlinuz-gentoo
|
||||||
|
APPEND initrd=initramfs.img $(get_cmdline)
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
install_kernel() {
|
install_kernel() {
|
||||||
|
|
|
@ -116,17 +116,31 @@ download() {
|
||||||
wget --quiet --https-only --secure-protocol=PFS --show-progress -O "$2" -- "$1"
|
wget --quiet --https-only --secure-protocol=PFS --show-progress -O "$2" -- "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_blkid_field_by_device() {
|
||||||
|
local blkid_field="$1"
|
||||||
|
local device="$2"
|
||||||
|
blkid -g \
|
||||||
|
|| die "Error while executing blkid -g"
|
||||||
|
local val
|
||||||
|
val="$(blkid -o export "$device")" \
|
||||||
|
|| die "Error while executing blkid '$device'"
|
||||||
|
val="$(grep -- "$blkid_field" <<< "$val")" \
|
||||||
|
|| die "Could not find $blkid_field=... in blkid output"
|
||||||
|
val="${val#"$blkid_field="}"
|
||||||
|
echo -n "$val"
|
||||||
|
}
|
||||||
|
|
||||||
get_device_by_blkid_field() {
|
get_device_by_blkid_field() {
|
||||||
local blkid_field="$1"
|
local blkid_field="$1"
|
||||||
local field_value="$2"
|
local field_value="$2"
|
||||||
blkid -g \
|
blkid -g \
|
||||||
|| die "Error while executing blkid"
|
|| die "Error while executing blkid -g"
|
||||||
local dev
|
local dev
|
||||||
dev="$(blkid -o export -t "$blkid_field=$field_value")" \
|
dev="$(blkid -o export -t "$blkid_field=$field_value")" \
|
||||||
|| die "Error while executing blkid to find $blkid_field=$field_value"
|
|| die "Error while executing blkid to find $blkid_field=$field_value"
|
||||||
dev="$(grep DEVNAME <<< "$dev")" \
|
dev="$(grep DEVNAME <<< "$dev")" \
|
||||||
|| die "Could not find DEVNAME=... in blkid output"
|
|| die "Could not find DEVNAME=... in blkid output"
|
||||||
dev="${dev:8}"
|
dev="${dev#"DEVNAME="}"
|
||||||
echo -n "$dev"
|
echo -n "$dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,10 +164,15 @@ get_device_by_ptuuid() {
|
||||||
echo -n "$dev"
|
echo -n "$dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_device_by_mdadm_uuid() {
|
uuid_to_mduuid() {
|
||||||
local mduuid="${1,,}"
|
local mduuid="${1,,}"
|
||||||
mduuid="${mduuid//-/}"
|
mduuid="${mduuid//-/}"
|
||||||
mduuid="${mduuid:0:8}:${mduuid:8:8}:${mduuid:16:8}:${mduuid:24:8}"
|
mduuid="${mduuid:0:8}:${mduuid:8:8}:${mduuid:16:8}:${mduuid:24:8}"
|
||||||
|
echo -n "$mduuid"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_device_by_mdadm_uuid() {
|
||||||
|
local mduuid="$(uuid_to_mduuid "$1")"
|
||||||
local dev
|
local dev
|
||||||
dev="$(mdadm --examine --scan)" \
|
dev="$(mdadm --examine --scan)" \
|
||||||
|| die "Error while executing mdadm to find array with UUID=$mduuid"
|
|| die "Error while executing mdadm to find array with UUID=$mduuid"
|
||||||
|
|
Loading…
Reference in New Issue