I have an SSD and a HDD, on a UEFI Motherboard. I can switch OS by changing boot order in BIOS, but I would prefer it if Grub2 simply listed Windows7 as a boot option.
Solving should help anyone who has more than one drive on a UEFI motherboard. Have seen Booting multiple OSs from multiple disks with UEFI and rEFInd looks to be a good alternative; this question is about how to correctly configure Grub2 to see the bootloader for Windows7 (or any OS), if at all possible - without using Grub-legacy or another tool such as rEFInd.
I am using Ubuntu 12.10 with Grub2 is on the SSD, the primary boot device, and Windows7 is on the HDD, which it decided to split into three partitions as it installed.
Boot info script gives a lengthy breakdown:
Boot Info Script 0.61 [1 April 2012]
============================= Boot Info Summary: ===============================
=> Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 1 of
the same hard drive for core.img. core.img is at this location and looks
in partition 72 for .
=> No boot loader is installed in the MBR of /dev/sdb.
sda1: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System: Ubuntu 12.10
Boot files: /boot/grub/grub.cfg /etc/fstab
sda2: __________________________________________________________________________
File system: swap
Boot sector type: -
Boot sector info:
sdb1: __________________________________________________________________________
File system: vfat
Boot sector type: Windows 7: FAT32
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files: /efi/Boot/bootx64.efi
sdb2: __________________________________________________________________________
File system:
Boot sector type: -
Boot sector info:
Mounting failed: mount: unknown filesystem type ''
sdb3: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System: Windows 7
Boot files: /Windows/System32/winload.exe
============================ Drive/Partition Info: =============================
Drive: sda _____________________________________________________________________
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sda1 * 2,048 218,439,679 218,437,632 83 Linux
/dev/sda2 218,439,680 234,440,703 16,001,024 82 Linux swap / Solaris
Drive: sdb _____________________________________________________________________
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
256 heads, 63 sectors/track, 121126 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sdb1 1 4,294,967,295 4,294,967,295 ee GPT
/dev/sdb1 ends after the last sector of /dev/sdb
GUID Partition Table detected.
Partition Start Sector End Sector # of Sectors System
/dev/sdb1 2,048 206,847 204,800 EFI System partition
/dev/sdb2 206,848 468,991 262,144 Microsoft Reserved Partition (Windows)
/dev/sdb3 468,992 1,953,523,711 1,953,054,720 Data partition (Windows/Linux)
"blkid" output: ________________________________________________________________
Device UUID TYPE LABEL
/dev/sda1 e20b187a-c3b0-45e1-98df-c955b3cffdde ext4
/dev/sda2 7663b629-19c9-49fc-a744-2beb2dcdb317 swap
/dev/sdb1 F428-FB77 vfat
/dev/sdb3 162C36632C363DD5 ntfs
================================ Mount points: =================================
Device Mount_Point Type Options
/dev/sda1 / ext4 (rw,errors=remount-ro)
=========================== sda1/boot/grub/grub.cfg: ===========================
--------------------------------------------------------------------------------
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
set default="0"
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
terminal_input console
terminal_output console
if [ "${recordfail}" = 1 ]; then
set timeout=-1
else
set timeout=6
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
clear
fi
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
set gfxpayload="${1}"
if [ "${1}" = "keep" ]; then
set vt_handoff=vt.handoff=7
else
set vt_handoff=
fi
}
if [ "${recordfail}" != 1 ]; then
if [ -e ${prefix}/gfxblacklist.txt ]; then
if hwmatch ${prefix}/gfxblacklist.txt 3; then
if [ ${match} = 0 ]; then
set linux_gfx_mode=keep
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=keep
fi
else
set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-e20b187a-c3b0-45e1-98df-c955b3cffdde' {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 e20b187a-c3b0-45e1-98df-c955b3cffdde
else
search --no-floppy --fs-uuid --set=root e20b187a-c3b0-45e1-98df-c955b3cffdde
fi
linux /boot/vmlinuz-3.5.0-27-generic root=UUID=e20b187a-c3b0-45e1-98df-c955b3cffdde ro quiet splash $vt_handoff
initrd /boot/initrd.img-3.5.0-27-generic
}
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-e20b187a-c3b0-45e1-98df-c955b3cffdde' {
menuentry 'Ubuntu, with Linux 3.5.0-27-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.0-27-generic-advanced-e20b187a-c3b0-45e1-98df-c955b3cffdde' {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 e20b187a-c3b0-45e1-98df-c955b3cffdde
else
search --no-floppy --fs-uuid --set=root e20b187a-c3b0-45e1-98df-c955b3cffdde
fi
echo 'Loading Linux 3.5.0-27-generic ...'
linux /boot/vmlinuz-3.5.0-27-generic root=UUID=e20b187a-c3b0-45e1-98df-c955b3cffdde ro quiet splash $vt_handoff
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.5.0-27-generic
}
menuentry 'Ubuntu, with Linux 3.5.0-27-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.0-27-generic-recovery-e20b187a-c3b0-45e1-98df-c955b3cffdde' {
recordfail
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 e20b187a-c3b0-45e1-98df-c955b3cffdde
else
search --no-floppy --fs-uuid --set=root e20b187a-c3b0-45e1-98df-c955b3cffdde
fi
echo 'Loading Linux 3.5.0-27-generic ...'
linux /boot/vmlinuz-3.5.0-27-generic root=UUID=e20b187a-c3b0-45e1-98df-c955b3cffdde ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.5.0-27-generic
}
menuentry 'Ubuntu, with Linux 3.5.0-26-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.0-26-generic-advanced-e20b187a-c3b0-45e1-98df-c955b3cffdde' {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 e20b187a-c3b0-45e1-98df-c955b3cffdde
else
search --no-floppy --fs-uuid --set=root e20b187a-c3b0-45e1-98df-c955b3cffdde
fi
echo 'Loading Linux 3.5.0-26-generic ...'
linux /boot/vmlinuz-3.5.0-26-generic root=UUID=e20b187a-c3b0-45e1-98df-c955b3cffdde ro quiet splash $vt_handoff
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.5.0-26-generic
}
menuentry 'Ubuntu, with Linux 3.5.0-26-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.0-26-generic-recovery-e20b187a-c3b0-45e1-98df-c955b3cffdde' {
recordfail
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 e20b187a-c3b0-45e1-98df-c955b3cffdde
else
search --no-floppy --fs-uuid --set=root e20b187a-c3b0-45e1-98df-c955b3cffdde
fi
echo 'Loading Linux 3.5.0-26-generic ...'
linux /boot/vmlinuz-3.5.0-26-generic root=UUID=e20b187a-c3b0-45e1-98df-c955b3cffdde ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.5.0-26-generic
}
menuentry 'Ubuntu, with Linux 3.5.0-17-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.0-17-generic-advanced-e20b187a-c3b0-45e1-98df-c955b3cffdde' {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 e20b187a-c3b0-45e1-98df-c955b3cffdde
else
search --no-floppy --fs-uuid --set=root e20b187a-c3b0-45e1-98df-c955b3cffdde
fi
echo 'Loading Linux 3.5.0-17-generic ...'
linux /boot/vmlinuz-3.5.0-17-generic root=UUID=e20b187a-c3b0-45e1-98df-c955b3cffdde ro quiet splash $vt_handoff
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.5.0-17-generic
}
menuentry 'Ubuntu, with Linux 3.5.0-17-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.0-17-generic-recovery-e20b187a-c3b0-45e1-98df-c955b3cffdde' {
recordfail
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 e20b187a-c3b0-45e1-98df-c955b3cffdde
else
search --no-floppy --fs-uuid --set=root e20b187a-c3b0-45e1-98df-c955b3cffdde
fi
echo 'Loading Linux 3.5.0-17-generic ...'
linux /boot/vmlinuz-3.5.0-17-generic root=UUID=e20b187a-c3b0-45e1-98df-c955b3cffdde ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.5.0-17-generic
}
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
--------------------------------------------------------------------------------
=============================== sda1/etc/fstab: ================================
--------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=e20b187a-c3b0-45e1-98df-c955b3cffdde / ext4 errors=remount-ro 0 1
# swap was on /dev/sda2 during installation
UUID=7663b629-19c9-49fc-a744-2beb2dcdb317 none swap sw 0 0
--------------------------------------------------------------------------------
=================== sda1: Location of files loaded by Grub: ====================
GiB - GB File Fragment(s)
= boot/grub/grub.cfg 1
= boot/initrd.img-3.5.0-17-generic 1
= boot/initrd.img-3.5.0-26-generic 1
= boot/initrd.img-3.5.0-27-generic 1
= boot/vmlinuz-3.5.0-17-generic 1
= boot/vmlinuz-3.5.0-26-generic 1
= boot/vmlinuz-3.5.0-27-generic 2
= initrd.img 1
= initrd.img.old 1
= vmlinuz 2
= vmlinuz.old 2
=============================== StdErr Messages: ===============================
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
In summary, Ubuntu has a swap partition (sda2) in addition to its root partition (sda1) where it resides. Everything is fine there. Windows7 made 3 partitions, the first (sdb1) being for EFI, the second (sdb2) being reserved for windows which is not relevant, the third (sdb3) being the actual windows installation.
The file hierarchy of sdb1 is
> ls -aR
.:
. .. EFI
./EFI:
. .. Boot Microsoft
./EFI/Boot:
. .. bootx64.efi
./EFI/Microsoft:
. .. Boot
./EFI/Microsoft/Boot:
. BCD BCD.LOG1 bootmgfw.efi BOOTSTAT.DAT da-DK el-GR es-ES Fonts hu-HU ja-JP memtest.efi nl-NL pt-BR ru-RU tr-TR zh-HK
.. BCD.LOG BCD.LOG2 bootmgr.efi cs-CZ de-DE en-US fi-FI fr-FR it-IT ko-KR nb-NO pl-PL pt-PT sv-SE zh-CN zh-TW
etc
Through using
grub-mkdevicemap
The file "device.map" was generated in "/boot/grub" which identified that the SSD is (hd0) and the HDD is (hd1). hd0 is primary boot device, Grub2 lives here.
In grub-customizer I tried to create an entry which would direct grub2 to the Windows7 bootloader:
set root='(hd1,1)'
search-no-floppy-fs-uuid-set F428-FB77
drivemap -s (hd1) ${root}
chainloader +1
However selecting it from grub on restart gave this error:
error: no such device: F428-FB77.
error: invalid signature.
Press any key to continue..._
Am I close?