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

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

安装Windows 10后,每次我获得内核更新或运行update-grub2它总是显示Windows 7Windows Recovery Environment而不是Windows 10 。 如何永久修复此问题?

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


更新#2:如果您创建一个至少包含1GB持久文件的Ubuntu 14.04 LiveUSB,则此文件位置相同,并且持久文件将允许所做的更改保留。 只有在Try Ubuntu启动时将系统启动到USB驱动器后才能修改此文件。


它仍然显示Windows 7Windows 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 

注意:在修改文件之前,应始终备份文件!

 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 "Windows .1.0" "$2/$boot/$bcd"; then long="Windows 10 (loader)" elif grep -qs "Windows .8" "$2/$boot/$bcd"; then long="Windows 8 (loader)" elif grep -qs "Windows .7" "$2/$boot/$bcd"; then long="Windows 7 (loader)" 

if grep -qs "Windows .8" "$2/$boot/$bcd"; then上面的更改正在改变这一行if grep -qs "Windows .8" "$2/$boot/$bcd"; then if grep -qs "Windows .8" "$2/$boot/$bcd"; thenelif grep -qs "Windows .8" "$2/$boot/$bcd"; then elif grep -qs "Windows .8" "$2/$boot/$bcd"; then ,添加if grep -qs "Windows .1.0" "$2/$boot/$bcd"; then if grep -qs "Windows .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 

然后运行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 

希望这可以帮助!