Last active
September 8, 2017 18:53
-
-
Save owenthewizard/b6c84fa3a149fb10d88e3e8f893ae13a to your computer and use it in GitHub Desktop.
Script to add kernels in /boot (or another EFI directory) to efibootmgr.
This file contains 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/bash | |
# update-efibootmgr.sh | |
# Update UEFI boot entries using efibootmgr | |
# TODO: remove old entries, could use efibootmgr -v? | |
set -eu | |
set -o pipefail | |
distro="Funtoo Linux" | |
efidir="/boot" | |
partuuid=$(blkid -o value $(findmnt / -o source | tail -n1) | tail -n1) | |
disk=$(findmnt --target=/boot -o source | tail -n1) | |
part=${disk##*/} | |
part=${part#*sd[a-z]} | |
disk=${disk%[1-9]*} | |
for kernel in ${efidir}/vmlinuz*; do # Add kernels in $efidir | |
kernel=${kernel#${efidir}/} | |
efibootmgr -q -c -d ${disk} -p ${part} -L "${distro} ${kernel#vmlinuz-}" \ | |
-l /${kernel} -u root=PARTUUID=${partuuid} rw | |
efibootmgr -q -c -d ${disk} -p ${part} -L "${distro} ${kernel#vmlinuz-} (Rescue)" \ | |
-l /${kernel} -u root=PARTUUID=${partuuid} rw init=/bin/bash | |
done | |
efibootmgr # print boot entries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment