Chr*_*ell 4 dual-boot ubuntu boot-loader windows grub2
我已经通过修改 40_custom 并添加以下内容,完成了将 Windows 添加到引导加载程序选项的通常步骤:
menuentry "Windows 10" {
insmod part_gpt
insmod chain
set root='(hd0,msdos2)'
chainloader +1
}
Run Code Online (Sandbox Code Playgroud)
但是,当我在引导加载程序中选择 Windows 时,它会显示“错误:签名无效。按任意键继续”。我不知道为什么会出现此错误。我该如何解决?编辑:它说这里有语法错误,但我看不到任何错误。
if [ "${grub_platform}" == "pc" ]; then
menuentry "Microsoft Windows Vista/7/8/8.1/10 BIOS/MBR" {
insmod part_msdos
insmod ntfs
insmod search_fs_uuid
insmod ntldr
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 XXXXXXXXXXXXXXXX
ntldr /bootmgr
}
fi
EDIT2: sudo fdisk -l 的输出
~$ sudo fdisk -l
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x71b1e4fb
Device Boot Start End Sectors Size Id Type
/dev/sda1 63 80324 80262 39.2M de Dell Utility
/dev/sda2 * 223580160 286285823 62705664 29.9G 83 Linux
/dev/sda3 30801920 223580159 192778240 91.9G 7 HPFS/NTFS/exFAT
/dev/sda4 286287870 625141759 338853890 161.6G 5 Extended
/dev/sda5 571742208 573741055 1998848 976M 82 Linux swap / Solaris
/dev/sda6 573743104 625141759 51398656 24.5G 83 Linux
/dev/sda7 286287872 345180159 58892288 28.1G 83 Linux
Partition table entries are not in disk order.
Disk /dev/sdb: 7.5 GiB, 8004829184 bytes, 15634432 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x037cbc77
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 15634431 15632384 7.5G c W95 FAT32 (LBA)
Run Code Online (Sandbox Code Playgroud)
看起来您遵循了希望 Windows 使用 MBR 分区的旧指南。
“无效签名”错误表明已启用安全启动。启用安全引导后,所有引导加载程序都必须使用私钥进行签名,并且固件 NVRAM 的安全引导变量中必须包含匹配的公钥。GRUB 正在尽职尽责地读取您指定的分区的第一个扇区,但由于它不包含适当的安全启动签名,固件拒绝执行它。
安全启动需要本机 UEFI 式启动作为先决条件。您或许可以在您的系统上禁用安全启动,但由于 GRUB 已经为您启动,因此可能没有必要这样做。
您insmod part_gpt
建议您希望磁盘具有 GPT 样式的分区,该分区通常与 UEFI 引导样式一起使用,但另一方面,set root=(hd0,msdos2)
需要 MBR 分区。
在我的带有 GPT 分区的 Debian 系统上,该set root
行显示为:set root='hd0,gpt1'
. 如果您的系统使用 GPT 分区,请使用gptN
分区标识符而不是msdosN
.
还chainloader +1
告诉 GRUB 从分区的第一个块读取引导块;在 UEFI 本机启动中,没有这样的事情。要在 UEFI 模式下启动 Windows,该set root
行应指向包含 Windows 引导加载程序的 EFI 系统分区,而链加载程序行应为chainloader /EFI/Microsoft/Boot/bootmgfw.efi
.
您可以通过编辑 将自定义条目添加到 GRUB2 /etc/grub.d/40_custom
。如果该文件已经是工作配置的条目,请更改40
为 /etc/grub.d/ 中尚未使用的另一个数字 [首先加载较低的数字]。如果您正在编辑现有的配置文件,请进行备份!
我曾经Grub-Customizer
添加新的 grub 配置。它自动生成的条目不起作用,所以我根据 telcoM 的建议将其编辑为自定义脚本。
这是我的40_custom
文件。
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Windows 10 (loader)"{
insmod part_gpt
search --no-floppy --set=root --fs-uuid 109C-D028
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
Run Code Online (Sandbox Code Playgroud)
然后,运行 ubdate-grub
您可以禁用任何不使用(但想要保存)的配置条目,使用chmod -x /path/to/file
或+x
启用它。这会将它们留在应有的位置,同时将其从 GRUB2 菜单中隐藏起来。
关于我的系统的一些相关信息: 运行 Arch Linux(2019 年 3 月)和 Windows 10,每个都在自己的单独驱动器上。每个都有 GPT。显然,如果在 UEFI 中运行,GRUB2 将不会加载 BIOS 分区(或者如果在 BIOS 模式下启动则是 UEFI 磁盘)。
小智 0
您应该安装os-prober
并运行一次
sudo apt-get install os-prober
sudo os-prober
Run Code Online (Sandbox Code Playgroud)
生成grub配置文件
sudo grub-mkconfig -o /boot/grub/grub.cfg
Run Code Online (Sandbox Code Playgroud)
不要手动编辑文件
归档时间: |
|
查看次数: |
45283 次 |
最近记录: |