Created
March 24, 2025 15:52
-
-
Save oliver-giersch/362a6a8393fac14ab88d0441db43fbe7 to your computer and use it in GitHub Desktop.
efistub setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
readonly bootdev=$1 | |
readonly bootpar=${2:-"1"} | |
set -eo nounset pipefail | |
function error_exit() { | |
echo "$@" >&2 | |
exit 1 | |
} | |
if [ -z "$bootdev" ]; then | |
error_exit "usage: $0 <bootdev> [bootpar]" | |
fi | |
if [ ! -b "$bootdev" ]; then | |
error_exit "$bootdev is not a valid boot device" | |
fi | |
if ! expr "$bootpar" + 0 > /dev/null 2>&1; then | |
error_exit "$bootpar is not a valid boot partition number" | |
fi | |
echo "Query offset of swapfile for resume from hibernation ..." | |
offset=$(btrfs inspect-internal map-swapfile -r /swap/swapfile) || exit $? | |
readonly offset | |
readonly resume="resume=LABEL=ROOT resume_offset=$offset" | |
readonly kargs="cryptdevice=LABEL=LUKS:root root=LABEL=ROOT rootflags=subvol=@root $resume rw quiet" | |
readonly cmd="efibootmgr --create \ | |
--disk $bootdev --part $bootpar \ | |
--label \"Arch Linux\" \ | |
--loader /vmlinuz-linux \ | |
--unicode \"initrd=\intel-ucode.img initrd=\initramfs-linux.img $kargs\"" | |
echo "$cmd | |
Proceed with this command? [y|N]" | |
read confirm | |
case "$confirm" in | |
"y"|"yes") ;; | |
*) echo "Exiting..."; exit 0; | |
esac | |
echo "Proceeding with command ..." | |
eval $cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment