Boot Repair为Windows创建了太多的Grub菜单项
我最近在惠普笔记本电脑上安装了双启动Ubuntu和Windows 10。 最初我无法使用grub启动Windows,因为选择Windows选项只会循环回grub。
然后我执行了一个启动修复,所有这些额外的选项出现在grub菜单中。
我可以使用“Windows UEFI bootmgfw.efi”选项打开Windows,但不能使用“Windows启动管理器”(在/ dev / sda1上)的标准选项。
如何减少这些条目以及为什么我不能使用后一个选项启动Windows?
这是grub的图像。 第一个选项是Ubuntu:
https://ibb.co/ecT625
Windows在这里是偏离主题的, 但答案是这是非常古老的技术,引导扇区只有512字节,因此它不足以容纳我们希望它保留的所有东西。
要轻松地在grub中添加和删除条目,请:
- 使用CloneZilla Live对整个计算机(包括其他操作系统)进行完整的系统备份
- 不,我不是在开玩笑! 首先进行完整的系统备份 ! 🙂
- 每当有人告诉你安装PPA时要非常谨慎,如果这是你真正想要的,那就去做你自己的研究,然后才继续
-
执行以下命令安装grub-customizer :
sudo add-apt-repository ppa:danielrichter2007/grub-customizer sudo apt update sudo apt install grub-customizer
-
启动
grub-customizer
并自定义地狱: -
如果遇到严重问题,请恢复系统备份。
每次我运行boot-repair
它都会在我的主grub
菜单中添加5个额外的Windows启动选项,这些选项不起作用。 在你的情况下,它增加了11个额外的条目!
grub.cfg
显示了这个问题
秘密可以在/etc/grub/grub.cfg
文件中找到:
### BEGIN /etc/grub.d/25_custom ### menuentry "Windows UEFI bootmgfw.efi" { search --fs-uuid --no-floppy --set=root D656-F2A8 chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi } menuentry "Windows Boot UEFI loader" { search --fs-uuid --no-floppy --set=root D656-F2A8 chainloader (${root})/EFI/Boot/bkpbootx64.efi } menuentry "EFI/ubuntu/fwupx64.efi" { search --fs-uuid --no-floppy --set=root D656-F2A8 chainloader (${root})/EFI/ubuntu/fwupx64.efi } menuentry "Windows UEFI bootmgfw.efi sda1" { search --fs-uuid --no-floppy --set=root 9478-B6E2 chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi } menuentry "Windows Boot UEFI loader sda1" { search --fs-uuid --no-floppy --set=root 9478-B6E2 chainloader (${root})/EFI/Boot/bkpbootx64.efi ### END /etc/grub.d/25_custom ### ### BEGIN /etc/grub.d/30_os-prober ### menuentry 'Windows Boot Manager (on /dev/nvme0n1p2)' --class windows --class os $menuentry_id_option 'osprober-efi-D656-F2A8' { savedefault insmod part_gpt insmod fat if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root D656-F2A8 else search --no-floppy --fs-uuid --set=root D656-F2A8 fi chainloader /EFI/Microsoft/Boot/bootmgfw.efi } menuentry 'Windows Boot Manager (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-efi-9478-B6E2' { savedefault insmod part_gpt insmod fat set root='hd0,gpt1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 9478-B6E2 else search --no-floppy --fs-uuid --set=root 9478-B6E2 fi chainloader /efi/Microsoft/Boot/bootmgfw.efi } ### END /etc/grub.d/30_os-prober ###
30_os-prober
部分包含您要保留的“好”Windows grub
菜单项。 Section 25_custom
包含boot-repair
创建的虚假条目。 您无法编辑grub配置文件,因为下次update-grub
运行时它将被覆盖。
第25_custom
节是由Boot Repair创建的
在我的系统上:
$ locate 25_custom /boot/efi/boot-repair/log/20171111_224241/nvme0n1p5/25_custom /boot/efi/boot-repair/log/20171208_030854/nvme0n1p5/25_custom /etc/grub.d/25_custom
看看设置的额外Windows选项(并且不起作用):
$ cat /boot/efi/boot-repair/log/20171208_030854/nvme0n1p5/25_custom #!/bin/sh exec tail -n +3 $0 menuentry "Windows UEFI bootmgfw.efi" { search --fs-uuid --no-floppy --set=root D656-F2A8 chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi } menuentry "Windows Boot UEFI loader" { search --fs-uuid --no-floppy --set=root D656-F2A8 chainloader (${root})/EFI/Boot/bkpbootx64.efi } menuentry "EFI/ubuntu/fwupx64.efi" { search --fs-uuid --no-floppy --set=root D656-F2A8 chainloader (${root})/EFI/ubuntu/fwupx64.efi } menuentry "Windows UEFI bootmgfw.efi sda1" { search --fs-uuid --no-floppy --set=root 9478-B6E2 chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi } menuentry "Windows Boot UEFI loader sda1" { search --fs-uuid --no-floppy --set=root 9478-B6E2 chainloader (${root})/EFI/Boot/bkpbootx64.efi
这些是在/etc/grub.d/25_custom
中创建的错误条目boot-repair
,随后编译到\boot\grub\grub.cfg
。
反向启动修复更改为25_custom
您想要编辑文件/etc/grub.d/25_custom
并删除除前三行之外的所有内容:
#!/bin/sh exec tail -n +3 $0
- 该文件现在包含两行文本和一行空行。
- 保存文件。
- 运行
sudo update-grub
。 - 重启。
现在,您的菜单不再臃肿,有五个虚假的Windows菜单条目不起作用。
仔细检查25_custom
中有25_custom
运行此命令并validation25_custom
有三行:
$ cat /etc/grub.d/25_custom | wc 3 6 30 # ^ ^ ^ # | | +--- Number of characters # | +----------- Number of words # +------------------- Number of lines
我将wc
添加到解密wc
(字数)输出中。