if [ "$grub_platform" == "pc" ]; then set default=0; fi
if [ "$grub_platform" == "efi" ]; then
getenv -t uint8 SecureBoot grub_secureboot;
if [ "$grub_secureboot" == "1" ]; then
sbpolicy -i
fi
set default=1
fi
上面的语句表示 grub2 会判断当前硬件是从 BIOS 还是从 UEFI 启动,从而自动选择相应的方式来启动 Windows 系统。
一开始使用了 ntboot 模块来引导系统。
set root=(hd0,gpt2)
menuentry 'Boot Windows Server 2022 (BIOS)' --unrestricted {
ntboot --efi=/bootmgr.exe --win (hd0,gpt3)
}
menuentry 'Boot Windows Server 2022 (UEFI)' --unrestricted {
ntboot --efi=/EFI/Microsoft/Boot/bootmgfw.efi --win (hd0,gpt3)
}