From a8b427c49207a8a4a589332660392c30a08f398b Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 12 Aug 2024 19:57:14 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E8=AE=BE=E7=BD=AE=20efibootmgr=20--bootnext?= =?UTF-8?q?=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #132 --- reinstall.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index a9d5f80..5ae636a 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1918,8 +1918,25 @@ get_part_num_by_part() { grep -oE '[0-9]*$' <<<"$dev_part" } +grep_efi_entry() { + # efibootmgr + # BootCurrent: 0002 + # Timeout: 1 seconds + # BootOrder: 0000,0002,0003,0001 + # Boot0000* sles-secureboot + # Boot0001* CD/DVD Rom + # Boot0002* Hard Disk + # Boot0003* sles-secureboot + # MirroredPercentageAbove4G: 0.00 + # MirrorMemoryBelow4GB: false + + # 根据文档,* 表示 active,也就是说有可能没有*(代表inactive) + # https://manpages.debian.org/testing/efibootmgr/efibootmgr.8.en.html + grep -E '^Boot[0-9a-fA-F]{4}' +} + grep_efi_index() { - awk -F '*' '{print $1}' | sed 's/Boot//' + awk '{print $1}' | sed -e 's/Boot//' -e 's/\*//' } add_efi_entry_in_linux() { @@ -1955,7 +1972,7 @@ add_efi_entry_in_linux() { --part "$(get_part_num_by_part $dev_part)" \ --label "$(get_entry_name)" \ --loader "\\EFI\\reinstall\\$basename" | - tail -1 | grep_efi_index) + grep_efi_entry | tail -1 | grep_efi_index) efibootmgr --bootnext $id return fi @@ -3007,7 +3024,7 @@ if is_efi; then install_pkg efibootmgr efibootmgr | grep -q 'BootNext:' && efibootmgr --quiet --delete-bootnext - efibootmgr | grep 'reinstall' | grep_efi_index | + efibootmgr | grep_efi_entry | grep 'reinstall' | grep_efi_index | xargs -I {} efibootmgr --quiet --bootnum {} --delete-bootnum fi fi