Jump to content
Read the Funtoo Newsletter: Summer 2023 ×
  • 0

New install, grub/grub2 cannot achieve dual-boot with Windows7


stamasd

Question

Background info: new install of Win7 and Funtoo on a laptop (HP Elitebook 8470p, core i7-3720, 16GB RAM, 500GB SSD).

Partitioned as follows. The partition scheme is classic BIOS/MBR, not UEFI.

/dev/sda1  *         2048     206847    204800   100M  7 HPFS/NTFS/exFAT
/dev/sda2          206848  747522047 747315200 356.4G  7 HPFS/NTFS/exFAT
/dev/sda3       747522048  957237247 209715200   100G 83 Linux
/dev/sda4       957237248 1000215215  42977968  20.5G 82 Linux swap / Solaris

Win7 installed first, Funtoo second in the unpartitioned space that was divided into sda3 and sda4. No separate boot and home partitions. Used sysrescd 4.9.0 for the install. No problems until setting grub for dual boot.

I do have os-prober installed.

 

The same issue occurs with both grub-legacy and grub2. Installed grub on /dev/sda. I want to dual boot Funtoo and Win7 with Funtoo being the default, and a timeout of 10s.

1. Using either 'ego boot update' or just boot-update, a /boot/grub/grub.cfg is installed that allows me to boot Funtoo only, no entry for Windows. os-prober when run separately does find the Windows installation but apparently that doesn't get funneled into boot-update. Adding an entry for Windows in /etc/grub.d/40_custom with chainloading also gets ignored.

With that I can boot Funtoo, but not WIndows

 

2. Using grub or grub2's 'grub-mkconfig -o /boot/grub/grub.cfg' results in a config that has entries for Funtoo and Win7 but only Windows can be booted from it. Attempting to boot Funtoo results in a kernel panic because sda3 cannot be mounted as root partition.

 

I'm pasting below the two grub.cfg files; notice that the root partitions are defined differently in the files. I don't want to edit grub.cfg manually if I can help it.

Any ideas appreciated.

 

1. grub.cfg generated by boot-update (boots Funtoo correctly but no entry for Windows)

	set timeout=10
	if [ -s $prefix/grubenv ]; then
    load_env
fi
	function savedefault {
    if [ -z "{boot_once}" ]; then
        saved_entry="${chosen}"
        save_env saved_entry
    fi
}
	  insmod part_msdos
  insmod ext2
  set root=(hostdisk//dev/sda,msdos3)
  search --no-floppy --fs-uuid --set 38c0a8f9-0e12-462c-92f6-650e5748eba3
if loadfont /boot/grub/fonts/unicode.pf2; then
   set gfxmode=text
   insmod all_video
   terminal_output gfxterm
fi
	set menu_color_normal=cyan/blue
set menu_color_highlight=blue/cyan
	menuentry "Funtoo Linux genkernel - kernel-debian-sources-lts-x86_64-4.9.161_p1" {
  insmod part_msdos
  insmod ext2
  set root=(hostdisk//dev/sda,msdos3)
  search --no-floppy --fs-uuid --set 38c0a8f9-0e12-462c-92f6-650e5748eba3
  linux /boot/kernel-debian-sources-lts-x86_64-4.9.161_p1 real_root=/dev/sda3 rootfstype=ext4 rand_id=L0AGZ8KL
  initrd /boot/early_ucode.cpio /boot/initramfs-debian-sources-lts-x86_64-4.9.161_p1
  set gfxpayload=keep
}
	menuentry "Funtoo Linux genkernel - kernel-debian-sources-lts-x86_64-4.9.130-2" {
  insmod part_msdos
  insmod ext2
  set root=(hostdisk//dev/sda,msdos3)
  search --no-floppy --fs-uuid --set 38c0a8f9-0e12-462c-92f6-650e5748eba3
  linux /boot/kernel-debian-sources-lts-x86_64-4.9.130-2 real_root=/dev/sda3 rootfstype=ext4 rand_id=AFRCNQ3V
  initrd /boot/early_ucode.cpio /boot/initramfs-debian-sources-lts-x86_64-4.9.130-2
  set gfxpayload=keep
}
	if [ ! "${next_entry}" = "" ] ; then
    set default="${next_entry}"
    set next_entry=
    save_env next_entry
    set boot_once=true
elif [ ! "${saved_entry}" = "" ]; then
    set default="${saved_entry}"
else
    set default=0
fi

 

2. grub.cfg generated by grub-mkconfig (boots windows but kernel panic on booting Funtoo because it can't mount /dev/sda3)

	#
# 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
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi
	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 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
}
	if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod ext2
set root='hd0,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3  38c0a8f9-0e12-462c-92f6-650e5748eba3
else
  search --no-floppy --fs-uuid --set=root 38c0a8f9-0e12-462c-92f6-650e5748eba3
fi
    font="/usr/share/grub/unicode.pf2"
fi
	if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_output gfxterm
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###
	### BEGIN /etc/grub.d/10_linux ###
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-38c0a8f9-0e12-462c-92f6-650e5748eba3' {
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3  38c0a8f9-0e12-462c-92f6-650e5748eba3
    else
      search --no-floppy --fs-uuid --set=root 38c0a8f9-0e12-462c-92f6-650e5748eba3
    fi
    echo    'Loading Linux x86_64-4.9.161_p1 ...'
    linux    /boot/kernel-debian-sources-lts-x86_64-4.9.161_p1 root=/dev/sda3 ro  
    echo    'Loading initial ramdisk ...'
    initrd    /boot/early_ucode.cpio
}
submenu 'Advanced options for Gentoo GNU/Linux' $menuentry_id_option 'gnulinux-advanced-38c0a8f9-0e12-462c-92f6-650e5748eba3' {
    menuentry 'Gentoo GNU/Linux, with Linux x86_64-4.9.161_p1' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-4.9.161_p1-advanced-38c0a8f9-0e12-462c-92f6-650e5748eba3' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3  38c0a8f9-0e12-462c-92f6-650e5748eba3
        else
          search --no-floppy --fs-uuid --set=root 38c0a8f9-0e12-462c-92f6-650e5748eba3
        fi
        echo    'Loading Linux x86_64-4.9.161_p1 ...'
        linux    /boot/kernel-debian-sources-lts-x86_64-4.9.161_p1 root=/dev/sda3 ro  
        echo    'Loading initial ramdisk ...'
        initrd    /boot/early_ucode.cpio
    }
    menuentry 'Gentoo GNU/Linux, with Linux x86_64-4.9.161_p1 (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-4.9.161_p1-recovery-38c0a8f9-0e12-462c-92f6-650e5748eba3' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3  38c0a8f9-0e12-462c-92f6-650e5748eba3
        else
          search --no-floppy --fs-uuid --set=root 38c0a8f9-0e12-462c-92f6-650e5748eba3
        fi
        echo    'Loading Linux x86_64-4.9.161_p1 ...'
        linux    /boot/kernel-debian-sources-lts-x86_64-4.9.161_p1 root=/dev/sda3 ro single
        echo    'Loading initial ramdisk ...'
        initrd    /boot/early_ucode.cpio
    }
    menuentry 'Gentoo GNU/Linux, with Linux x86_64-4.9.130-2' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-4.9.130-2-advanced-38c0a8f9-0e12-462c-92f6-650e5748eba3' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3  38c0a8f9-0e12-462c-92f6-650e5748eba3
        else
          search --no-floppy --fs-uuid --set=root 38c0a8f9-0e12-462c-92f6-650e5748eba3
        fi
        echo    'Loading Linux x86_64-4.9.130-2 ...'
        linux    /boot/kernel-debian-sources-lts-x86_64-4.9.130-2 root=/dev/sda3 ro  
        echo    'Loading initial ramdisk ...'
        initrd    /boot/early_ucode.cpio
    }
    menuentry 'Gentoo GNU/Linux, with Linux x86_64-4.9.130-2 (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-4.9.130-2-recovery-38c0a8f9-0e12-462c-92f6-650e5748eba3' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3  38c0a8f9-0e12-462c-92f6-650e5748eba3
        else
          search --no-floppy --fs-uuid --set=root 38c0a8f9-0e12-462c-92f6-650e5748eba3
        fi
        echo    'Loading Linux x86_64-4.9.130-2 ...'
        linux    /boot/kernel-debian-sources-lts-x86_64-4.9.130-2 root=/dev/sda3 ro single
        echo    'Loading initial ramdisk ...'
        initrd    /boot/early_ucode.cpio
    }
}
	### 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 ###
menuentry 'Windows 7 (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-704278994278662E' {
    insmod part_msdos
    insmod ntfs
    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  704278994278662E
    else
      search --no-floppy --fs-uuid --set=root 704278994278662E
    fi
    parttool ${root} hidden-
    chainloader +1
}
### END /etc/grub.d/30_os-prober ###
	### 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.
#menuentry "Win7" {
#    root (hd0,msdos1)
#    chainloader +1
#    boot
#    }
	### 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 ###
	

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

The way I did was to generate the boot update first, copy the section of Funtoo menuentry and after that you do the grub-mkconfig and paste the Funtoo entry in the end of the cfg file generated by the grub-mkconfig. Seems that boot update does not execute os-prober like grub-mkconfig.

Link to comment
Share on other sites

  • 0

Yeah I figured that I would have to manually edit grub.cfg. For some reason adding an entry to boot.conf didn't work. But I copied the entry for win7 from the grub.cfg that would boot Windows only, and added it to the one that would boot Funtoo only. Now I have dual boot working. Thank you all for your help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...