GRUB2 显示 Windows 7 或 Windows 恢复环境而不是 Windows 10

Ter*_*nce 9 grub2 dual-boot 14.04 windows-10

这是我最近发现的一个问答,所以我在下面发布了答案。

安装 Windows 10 后,每次我获得内核更新或运行update-grub2它时,它总是显示Windows 7Windows Recovery Environment代替Windows 10. 我如何永久解决这个问题?

Ter*_*nce 10

更新: 我刚刚执行了 Xubuntu 14.04 的全新安装,下面列出的文件条目已经存在。看起来 GRUB 团队现在已经包含了更新。我会把这个留在这里给那些可能在没有更新他们的系统的情况下偶然发现的人。


更新 #2: 如果你创建一个 Ubuntu 14.04 LiveUSB,上面至少有一个 1GB 的持久文件,这个文件位置是相同的,持久文件将允许所做的更改保留。这个文件只能在系统引导到 U 盘后进行修改Try Ubuntu


它仍然显示Windows 7orWindows Recovery Environment而不是的原因Windows 10是该文件/usr/lib/os-probes/mounted/20microsoft不包含 标签Windows 10,因此在os-prober检测到操作系统期间它会回退到Windows 7Windows Recovery Environment

要更正此问题,您需要对以下文件进行以下更改(我将 gedit 作为编辑器,但使用您想要的):

sudo gedit /usr/lib/os-probes/mounted/20microsoft
Run Code Online (Sandbox Code Playgroud)

注意:在修改文件之前,您应该始终对其进行备份!

if item_in_dir -q bootmgr "$2"; then
        # there might be different boot directories in different case as:
        # boot Boot BOOT
        for boot in $(item_in_dir boot "$2"); do
                bcd=$(item_in_dir bcd "$2/$boot")
                if [ -n "$bcd" ]; then
                        if grep -qs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; then
                                long="Windows 10 (loader)"
                        elif grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then
                                long="Windows 8 (loader)"
                        elif grep -qs "W.i.n.d.o.w.s. .7" "$2/$boot/$bcd"; then
                                long="Windows 7 (loader)"
Run Code Online (Sandbox Code Playgroud)

上面的更改将行更改if grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; thenelif grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; thenif grep -qs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; thenlong="Windows 10 (loader)"在该行上方添加并保存它。

保存后,os-prober现在运行如下所示:

terrance@terrance-ubuntu:~$ sudo os-prober
[sudo] password for terrance: 
/dev/sdf1:Windows 10 (loader):Windows:chain
Run Code Online (Sandbox Code Playgroud)

然后运行update-grub2它现在将在/boot/grub/grub.cfg您获得内核更新时对您的永久更新进行更新,因此它现在将显示正确的 Windows 版本(以下示例):

terrance@terrance-ubuntu:~$ sudo update-grub2
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.19.0-26-generic
Found initrd image: /boot/initrd.img-3.19.0-26-generic
Found linux image: /boot/vmlinuz-3.13.0-58-generic
Found initrd image: /boot/initrd.img-3.13.0-58-generic
Found linux image: /boot/vmlinuz-3.13.0-57-generic
Found initrd image: /boot/initrd.img-3.13.0-57-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 10 (loader) on /dev/sdf1
done
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!

  • 对于 Grub2 维护者,这是否已发布到上游(作为错误/修复)? (4认同)