How to add Windows7 to grub2 boot menu on new install of EFI/GPT system ?

How do I install Windows7 into the boot menu of grub2 on a dual boot system with both Windows7 and a 64-bit openSUSE-13.1 ? This is an EFI/GPT system. Normally this is done by default by the openSUSE installer, but in this case, the installer did not find the MS-Win7.

As part of my failed effort to figure this out, I spent a small amount of time trying to add Windows7 by using the YaST boot menu item, and even tried the updateGrub2 script (which added a 05_menu_colour theme that caused worse boot problems, until file removed).

os-prober does not detect windows7. But if I press F12 upon booting, select windows7 in the firmware boot menu, then windows7 boots fine.

I manually created the EFI partition myself , prior to the win7 install, which ‘may’ have caused the problem < not sure >

The PC has an HD which is sda and an SSD which is SSD. All executeables are on SSD. The EFI partition is locate /sdb1 . The MS-Windows is sdb3. The openSUSE-13.1 is sdb5.

Some info supporting the above words:


4770:/home/oldcpu # gdisk /dev/sdb -l
GPT fdisk (gdisk) version 0.8.7

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdb: 500118192 sectors, 238.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): B4EBD075-E09E-4F8D-92A7-39903D1A5DB8
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 500118158
Partitions will be aligned on 2048-sector boundaries
Total free space is 154727021 sectors (73.8 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          534527   260.0 MiB   0700  
   2          534528          796671   128.0 MiB   0C01  
**   3          796672       140060671   66.4 GiB    0700  Basic data partition**
   4       140060672       140593151   260.0 MiB   0700  
**   5       140593152       242993151   48.8 GiB    8300  **
   6       242993152       294193151   24.4 GiB    8300  
   7       294193152       345393151   24.4 GiB    8300 

I note this from efibootmgr -v :


4770:/home/oldcpu # efibootmgr -v
BootCurrent: 0004
Timeout: 1 seconds
BootOrder: 0004,0003,0005,0009,000A,0002,0001,0000
Boot0000* TSSTcorp CDDVDW SH-222BB      BIOS(3,0,00)AMBO
Boot0001* ST2000DM001-1CH164    BIOS(2,0,00)AMBO
Boot0002* SanDisk SD6SB1M256G1022I      BIOS(2,0,00)AMBO
**Boot0003* opensuse      HD(1,800,82000,4fc1f61d-b032-4cbd-9eda-3dc1a71c5908)File(\EFI\opensuse\grubx64.efi)
Boot0004* opensuse-secureboot   HD(1,800,82000,4fc1f61d-b032-4cbd-9eda-3dc1a71c5908)File(\EFI\opensuse\shim.efi)
Boot0005* Windows Boot Manager   HD(1,800,82000,4fc1f61d-b032-4cbd-9eda-3dc1a71c5908)File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...a................
**Boot0009* UEFI: ST2000DM001-1CH164       ACPI(a0341d0,0)PCI(1f,2)03120a000000ffff0000HD(1,800,80000,cde86124-7fda-4269-bb4d-ccc36efdf3b9)AMBO
Boot000A* UEFI: SanDisk SD6SB1M256G1022I         ACPI(a0341d0,0)PCI(1f,2)03120a000100ffff0000HD(4,8592800,82000,a7f589cf-be23-44a2-9725-0738d992c876)AMBO

By default the desktop PC boots to openSUSE.

But there is no Win7 entry in the grub2 menu. I currently can only boot to win7 if I press F12 immediately upon booting, to obtain the UEFI boot menu, and select from win7 there.

I note win7 does not show up when os-prober is run. In that case all I get is:


4770:/home/oldcpu # os-prober
  No volume groups found

where nominally I think I should expect to see something under the “No volume groups found” entry. I’m wondering if my custom FAT32 as EFI hack caused this hiccup ?

I don’t know enough about grub2 to fix this. This is also definitely NOT a ‘drama’ as I rarely boot to windows. Rather its more a point of curiousity and also my wanting to learn, and to better tune the system.
.

Please post /var/log/messages at the time you run os-prober. You may check timestamp of last message, run os-prober and copy all messages since last timestamp.

The /var/log/messages is quite large for the running of os-prober, likely because I have many partitions (albeit few OS). I copied the output to susepaste:
http://susepaste.org/12316363

again , the Win7 is on /dev/sdb3 … where I can see the ntfs detected, but thats all … (the sdb2 which is the microsoft reserved partition gets LOTS of errors)

I’ve come across others with that problem. It seems that Win7 in EFI mode is not being recognized.

Here’s my grub.cfg entry for Win8, followed by my commentary. You could edit it in (maybe in /etc/grub.d/40_custom) until the software gets fixed.


menuentry 'Windows Boot Manager (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-efi-960A-3282' {
        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  960A-3282
        else
          search --no-floppy --fs-uuid --set=root 960A-3282
        fi
        chainloader /efi/Microsoft/Boot/bootmgfw.efi
}

Commentary:
The string “960A-3282” is the UUID of the EFI partition (as checked using “blkid”).

The path “/efi/Microsoft/Boot/bootmgfw.efi” on the chainloader line is the path to the Windows boot loader efi file (should be the same file as shown by “efibootmgr -v” output). My EFI partition is partition 1 on “/dev/sda”, which I think corresponds to that set “root=‘hd0,gpt1’”

You can probably omit all of those hints, as long as you get the UUID right.

Thanks I’ll give that a try . I previous tried an edit to the /etc/grub.d/40_custom with this:


menuentry 'Windows 7' --class windows --class os $menuentry_id_option {
             exit
}

but it did not work. I also sent ‘grub-mkconfig’ after to apply (I think < not sure > something like that is needed to apply 40_custom file edits) but it did not appear to work (at least I believe that necsesary).

I’ll give your suggestion a try. Thanks.

It does not matter. On UEFI os-prober arranges for chainloading Windows bootloader from ESP

20microsoft: debug: Skipping legacy bootloaders on UEFI system
According to your log and gdisk output, you do not have any ESP (at least, partition, that has ESP GUID). That’s against specs. The simplest fix is to set GUID of your ESP partition to the correct value (EF00 if using gdisk).

it was ef00 originally when I created the partition. I wonder if removing the boot flag caused that to change ?

Some detail on this … when I first tried to install win7, it insisted on a 100MB EFI. I wanted a 256MB EFI, but to do so, I needed to 1st create the 256MB EFI with GUID of ef00 with gparted. I did that.

But win7 refused to recognize that, unless I flagged it as active (ie flagged it with the gparted ‘boot’ flag). After win7 was installed, I removed the ‘boot’ flag and win7 still booted. But it appears removing the ‘boot’ flag chagned the GUID ? < not sure >

So I backed up the EFI partition, and then rebooted to a gparted liveCD and flagged the /dev/sdb1 EFI with the ‘boot’ flag. I rebooted to openSUSE and I now note the following;

Output of " efibootmgr -v "


4770:/home/oldcpu # efibootmgr -v
BootCurrent: 0004
Timeout: 1 seconds
BootOrder: 0004,0003,0005,0009,000A,000B,0002,0001,0000
Boot0000* TSSTcorp CDDVDW SH-222BB      BIOS(3,0,00)AMBO
Boot0001* ST2000DM001-1CH164    BIOS(2,0,00)AMBO
Boot0002* SanDisk SD6SB1M256G1022I      BIOS(2,0,00)AMBO
**Boot0003* opensuse      HD(1,800,82000,4fc1f61d-b032-4cbd-9eda-3dc1a71c5908)File(\EFI\opensuse\grubx64.efi)
Boot0004* opensuse-secureboot   HD(1,800,82000,4fc1f61d-b032-4cbd-9eda-3dc1a71c5908)File(\EFI\opensuse\shim.efi)**
**Boot0005* Windows Boot Manager  HD(1,800,82000,4fc1f61d-b032-4cbd-9eda-3dc1a71c5908)File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...a................**
Boot0009* UEFI: ST2000DM001-1CH164      ACPI(a0341d0,0)PCI(1f,2)03120a000000ffff0000HD(1,800,80000,cde86124-7fda-4269-bb4d-ccc36efdf3b9)AMBO
Boot000A* UEFI: SanDisk SD6SB1M256G1022I        ACPI(a0341d0,0)PCI(1f,2)03120a000100ffff0000HD(4,8592800,82000,a7f589cf-be23-44a2-9725-0738d992c876)AMBO
**Boot000B* Windows Boot Manager  HD(4,8592800,82000,a7f589cf-be23-44a2-9725-0738d992c876)File(\EFI\Microsoft\Boot\bootmgfw.efi)**

ie there is now an additional Windows Boot manager entry .

and now if I run os-prober :


4770:/home/oldcpu # os-prober
  No volume groups found
**/dev/sdb1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi**

which is better.

I’ll re-run YaST > System > Boot Loader … reboot and see if that makes any difference.

That did the trick ! I now have a Windows7 option in grub2.

Its interesting that restoring the ‘boot flag’ (ie changing the partition to being ‘active’) with gparted fixed the problem.

nrickert and arvidjaar - many thanks for your support on this thread.