mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +08:00
core: 修复 efibootmgr 相关问题
1. 修复了创建 efi 引导项时没有指定分区号而导致无效 2. bootnum 是16进制,包含 A-F 3. 更精确地取出 bootnum
This commit is contained in:
parent
00d3eea434
commit
36b49d135f
33
reinstall.sh
33
reinstall.sh
@ -945,6 +945,17 @@ get_maybe_efi_dirs_in_linux() {
|
|||||||
mount | awk '$5=="vfat" {print $3}' | grep -E '/boot|/efi'
|
mount | awk '$5=="vfat" {print $3}' | grep -E '/boot|/efi'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_disk_by_part() {
|
||||||
|
dev_part=$1
|
||||||
|
install_pkg lsblk
|
||||||
|
lsblk -rn --inverse "$dev_part" | grep -w disk | awk '{print $1}'
|
||||||
|
}
|
||||||
|
|
||||||
|
get_part_num_by_part() {
|
||||||
|
dev_part=$1
|
||||||
|
grep -o '[0-9]*' <<<"$dev_part" | tail -1
|
||||||
|
}
|
||||||
|
|
||||||
add_efi_entry_in_linux() {
|
add_efi_entry_in_linux() {
|
||||||
source=$1
|
source=$1
|
||||||
|
|
||||||
@ -955,16 +966,22 @@ add_efi_entry_in_linux() {
|
|||||||
dist_dir=$efi_part/EFI/reinstall
|
dist_dir=$efi_part/EFI/reinstall
|
||||||
basename=$(basename $source)
|
basename=$(basename $source)
|
||||||
mkdir -p $dist_dir
|
mkdir -p $dist_dir
|
||||||
cp -f "$source" "$dist_dir/$basename"
|
|
||||||
|
if [[ "$source" = http* ]]; then
|
||||||
|
curl -Lo "$dist_dir/$basename" "$source"
|
||||||
|
else
|
||||||
|
cp -f "$source" "$dist_dir/$basename"
|
||||||
|
fi
|
||||||
|
|
||||||
# disk=$($grub-probe -t device "$dist")
|
# disk=$($grub-probe -t device "$dist")
|
||||||
install_pkg findmnt
|
install_pkg findmnt
|
||||||
disk=$(findmnt -T "$dist_dir" -no SOURCE)
|
dev_part=$(findmnt -T "$dist_dir" -no SOURCE)
|
||||||
efibootmgr --quiet --create-only \
|
efibootmgr --quiet --create-only \
|
||||||
--disk "$disk" \
|
--disk "/dev/$(get_disk_by_part $dev_part)" \
|
||||||
|
--part "$(get_part_num_by_part $dev_part)" \
|
||||||
--label "$(get_entry_name)" \
|
--label "$(get_entry_name)" \
|
||||||
--loader "\\EFI\\reinstall\\$basename"
|
--loader "\\EFI\\reinstall\\$basename"
|
||||||
id=$(efibootmgr | grep "$(get_entry_name)" | grep -oE '[0-9]{4}')
|
id=$(efibootmgr | grep "$(get_entry_name)" | awk -F '*' '{print $1}' | sed 's/Boot//')
|
||||||
efibootmgr --bootnext $id
|
efibootmgr --bootnext $id
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -1372,15 +1389,15 @@ if is_efi; then
|
|||||||
rm -f /cygdrive/$c/grub.cfg
|
rm -f /cygdrive/$c/grub.cfg
|
||||||
|
|
||||||
bcdedit /set '{fwbootmgr}' bootsequence '{bootmgr}'
|
bcdedit /set '{fwbootmgr}' bootsequence '{bootmgr}'
|
||||||
bcdedit /enum bootmgr | grep --text -B3 'reinstall.*' | awk '{print $2}' | grep '{.*}' |
|
bcdedit /enum bootmgr | grep --text -B3 'reinstall' | awk '{print $2}' | grep '{.*}' |
|
||||||
xargs -I {} cmd /c bcdedit /delete {}
|
xargs -I {} cmd /c bcdedit /delete {}
|
||||||
else
|
else
|
||||||
maybe_efi_dirs=$(get_maybe_efi_dirs_in_linux)
|
# shellcheck disable=SC2046
|
||||||
find $maybe_efi_dirs /boot -type f -name 'custom.cfg' -exec rm -f {} \;
|
find $(get_maybe_efi_dirs_in_linux) /boot -type f -name 'custom.cfg' -exec rm -f {} \;
|
||||||
|
|
||||||
install_pkg efibootmgr
|
install_pkg efibootmgr
|
||||||
efibootmgr | grep -q 'BootNext:' && efibootmgr --quiet --delete-bootnext
|
efibootmgr | grep -q 'BootNext:' && efibootmgr --quiet --delete-bootnext
|
||||||
efibootmgr | grep 'reinstall.*' | grep -oE '[0-9]{4}' |
|
efibootmgr | grep 'reinstall' | awk -F '*' '{print $1}' | sed 's/Boot//' |
|
||||||
xargs -I {} efibootmgr --quiet --bootnum {} --delete-bootnum
|
xargs -I {} efibootmgr --quiet --bootnum {} --delete-bootnum
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user