Skip to content

Commit

Permalink
feat: save minimal scripts in boot partition to easily create a new i…
Browse files Browse the repository at this point in the history
…nitramfs or efiboot entry
  • Loading branch information
oddlama committed Apr 16, 2022
1 parent eb067c5 commit f4040d9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,23 @@ function generate_initramfs() {
--add "bash ${modules[*]}" \
--force \
"$output"

# Create script to repeat initramfs generation
cat > "$(dirname "$output")/generate_initramfs.sh" <<EOF
#!/bin/bash
kver="\$1"
[[ -n "\$kver" ]] || { echo "usage \$0 <kernel_version>" >&2; exit 1; }
dracut \\
--conf "/dev/null" \\
--confdir "/dev/null" \\
--kver "\$kver" \\
--no-compress \\
--no-hostonly \\
--ro-mnt \\
--add "bash ${modules[*]}" \\
--force \\
"$output"
EOF
}

function get_cmdline() {
Expand Down Expand Up @@ -186,6 +203,12 @@ function install_kernel_efi() {
gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")" \
|| die "Could not resolve device with id=${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}"
try efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\vmlinuz.efi' --unicode 'initrd=\initramfs.img'" $(get_cmdline)"

# Create script to repeat adding efibootmgr entry
cat > "/boot/efi/efibootmgr_add_entry.sh" <<EOF
#!/bin/bash
efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\\vmlinuz.efi' --unicode 'initrd=\\initramfs.img'" $(get_cmdline)"
EOF
}

function generate_syslinux_cfg() {
Expand Down

0 comments on commit f4040d9

Please sign in to comment.