Manually adding a new entry (e.g. Windows) to the GRUB2-EFI boot loader menu

I have installed both Windows 7 and OpenSUSE 12.2 in my new laptop, which uses UEFI, GPT. I installed Windows first. Upon installing OpenSUSE, Windows did not show up in the GRUB2-EFI boot loader menu. Scouring the internet, I found two ways of adding Windows to the boot loader menu that seem to work! In both cases, I had to add lines in /etc/grub.d/40_custom, and then execute

grub2-efi-mkconfig -o /boot/grub2-efi/grub.cfg

The added lines for Option 1 go like this:
menuentry “Windows 7” {
insmod part_gpt
insmod chain
set root=’(hd0,gpt1)’
chainloader /EFI/Microsoft/Boot/bootmgfw.efi

The lines for Option 2 go like this:
menuentry “Windows 7” {
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --no-floppy --set=root 080F-E6DA
chainloader (${root})/efi/Microsoft/Boot/bootmgfw.efi

where 080F-E6DA is the UUID of my ESP (/dev/sda1, mounted on /boot/efi), which I obtained using blkid.

Since I don’t really understand the menu entry lines themselves, for now my question is simple: which option is better, safer??

(p.s. I’d like to quote commands/codes properly in these forums, but I obviously haven’t figured out how to do that. Help?)

Second one is better. It makes sure grub2 will always find your partition even if move HDD around (or delete/add some more partitions). Of course, it does not necessarily mean Windows will find it as well … :slight_smile: so in this particular case it probably does not really matter.

To be on safe side, use grub2-probe to obtain UUID (it should be the same but who knows …)

bor@opensuse:~> sudo /usr/sbin/grub2-probe -t fs_uuid -d /dev/sda1

That is called CODE tags. You get them by using the # button in the toolbar above your post editor.

That one by far! Forget about the use of partition numbers in boot entries, even with GPT. Grub will also ignore this hint if it’s present and use the UUID instead.

And for what it is worth, I have found that grub2-efi does not create a working menu entry for Windows that it finds with OS Prober as there is some problem with how it works. This problem is not present in the standard grub2 it would appear.

Thank You,

See thread:

As it is very similiar.