GRUB2 shows Windows 7 or Windows Recovery Environment instead of Windows 10

6,536

Update: I just performed a clean install of Xubuntu 14.04 and the entries to the file that is listed below were already there. Looks like the GRUB Team has now included the update. I will leave this here for anyone that might stumble across this without the update on their system yet.


Update #2: If you create an Ubuntu 14.04 LiveUSB with at least a 1GB Persistent file on it, this file location is the same and the persistent file will allow the changes that are made to stay. This file should only be modified after booting the system to the USB drive in Try Ubuntu boot.


The reason why it still shows Windows 7 or Windows Recovery Environment instead of Windows 10 is that the file /usr/lib/os-probes/mounted/20microsoft does not contain the label for Windows 10, so during the os-prober detection of the OS it falls back to Windows 7 or Windows Recovery Environment.

To correct this, you need to make the following changes to the following file (I am going to put gedit as the editor, but use what you want):

sudo gedit /usr/lib/os-probes/mounted/20microsoft

NOTE: You should always make a backup of a file before modifying it!

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)"

the changes above are changing the line if grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then to elif grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then, and adding if grep -qs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; then and long="Windows 10 (loader)" above that line and saving it.

Once saved, then running os-prober now looks like this:

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

then running update-grub2 it will now make the updates to your /boot/grub/grub.cfg permanent anytime you get a kernel update so it will show the correct version of Windows now (example below):

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

Hope this helps!

Share:
6,536

Related videos on Youtube

Terrance
Author by

Terrance

I've been working in the computer industry for the past 27+ years. For the past 11 years I have been working in an eBay Data Center as a software technician systems administrator. Have worked for Packard Bell/NEC, Intel/Dayna Communications, Computer City/CompUSA and Cyber-Net Slash Support. I don't know everything about Linux as it is ever changing and always so much to learn. But I do love everything about Ubuntu that I know so far. I am always willing to help where I can, and I am eager to learn.

Updated on September 18, 2022

Comments

  • Terrance
    Terrance over 1 year

    This is a Q&A that I recently have figured out, so I have posted the answer below.

    After installing Windows 10, every time I get a kernel update or I run the update-grub2 it always shows Windows 7 or Windows Recovery Environment instead of Windows 10. How do I fix this permanently?

    • cdg
      cdg over 4 years
      Those changes already exist in (my Mint 19.2) /usr/lib/os-probes/mounted/20microsoft, but it still returns "Windows Vista". Note that, when the dual-boot system was Windows 7, it returned the correct value, so it appears it is the source of the information that is missing.
    • Terrance
      Terrance over 4 years
      @cdg This should be asked at Linux&Unix as this site is for official Ubuntu flavors only. Also, you should file a bug report with Mint Development if you already have all this as they may not be detecting it correctly.
  • david6
    david6 over 8 years
    Has this been posted upstream (as bug/fix), for Grub2 maintainers?
  • david6
    david6 over 8 years
    The '20microsoft' scripts looks messy, and may need other improvements.