Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oliver-giersch/362a6a8393fac14ab88d0441db43fbe7 to your computer and use it in GitHub Desktop.
Save oliver-giersch/362a6a8393fac14ab88d0441db43fbe7 to your computer and use it in GitHub Desktop.
efistub setup
#!/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