alpine: add support for nvram writing

This commit is contained in:
Nico Schottelius 2023-09-11 18:27:57 +02:00
parent 0084b0897e
commit 8d00a1afcf
1 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh
if [ $# -ne 3 ]; then
echo "$0 disk ssh-keyfile [efi|bios]"
echo "$0 disk ssh-keyfile [efi|bios|efinvram]"
echo " disk: which disk to install to"
echo " ssh-keyfile: ssh keys to add into the image"
echo " use efi or bios partitioning"
@ -65,7 +65,7 @@ EOF
sudo mkfs.ext4 -F ${partition1}
sudo mount -t ext4 ${partition1} $rootfs_tmpdir
;;
efi)
efi*)
sudo sfdisk "$DISK" <<EOF
label: gpt
,500MiB,U
@ -151,7 +151,7 @@ case "$BOOT_VIA" in
run_root grub-install --target=i386-pc ${DISK}
echo "UUID=$UUID_1 / ext4 defaults 0 1" >> ${rootfs_tmpdir}/etc/fstab
;;
efi)
efi*)
eval $(blkid | grep ^${DISK}2 | awk '{ print $2 }')
UUID_2=$UUID
@ -166,6 +166,15 @@ case "$BOOT_VIA" in
;;
esac
# Actually do add us to the bios
if [ $BOOT_VIA = "efinvram" ]; then
dir=/sys/firmware/efi/efivars/
sudo mount --bind ${dir} ${rootfs_tmpdir}${dir}
run_root apk add efibootmgr
run_root grub-install --efi-directory=/boot
fi
# Debug
run_root cat /etc/fstab
@ -182,6 +191,3 @@ rmdir ${rootfs_tmpdir}
echo "${DISK} has been setup with Alpine Linux"
exit 0
apk add grub-efi
grub-install --no-nvram --efi-directory /boot/