Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Dual Boot Gentoo with Windows 7 (BIOS MBR)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
P1neapple
n00b
n00b


Joined: 18 Jul 2014
Posts: 35

PostPosted: Sun Jul 20, 2014 12:16 am    Post subject: [SOLVED] Dual Boot Gentoo with Windows 7 (BIOS MBR) Reply with quote

I have a straightforward setup for dual booting and if I do switch to Gentoo, I need to be able to setup GRUB2 to detect Windows.

The problem is I cannot find a straightforward method to ensure GRUB2 can see Windows 7, because a lot of the things I find on the Internet are either outdated or talk about UEFI.

Thanks for the help (source of the information would be great also) :)
_________________
Gentoo currently running in Virtualbox, hoping to switch to real hardware soon...


Last edited by P1neapple on Mon Jul 21, 2014 6:22 am; edited 1 time in total
Back to top
View user's profile Send private message
ct85711
Veteran
Veteran


Joined: 27 Sep 2005
Posts: 1696

PostPosted: Sun Jul 20, 2014 12:44 am    Post subject: Reply with quote

From what I've seen, and my experience, you don't have to use UEFI. I believe if you tell grug2 to use PC platform, it use the old bios boot system. The big thing is, is finding out which mode windows 7 is using, bios or UEFI, and use the same system for linux. A way to check which method windows is using, is check the drive label that has the windows partition. If the label says gpt, it's using UEFI, and it's rather straight forward to duel boot already.
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2574

PostPosted: Sun Jul 20, 2014 12:50 am    Post subject: Reply with quote

Since this is off the unanswered list, there is document for this here.

There are also alternatives like syslinux and grub legacy that are much easer to configure. Unfortunately I have no personal experience using grub2.
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
P1neapple
n00b
n00b


Joined: 18 Jul 2014
Posts: 35

PostPosted: Sun Jul 20, 2014 3:26 am    Post subject: Reply with quote

OK, maybe I was unclear. I am confused on how I should configure GRUB2 to detect Windows.

If I install os-prober, will that setup everything for me if I run grub2-mkconfig right (if I also get ntfs3g)? Because the wiki page that The Doctor linked talks about grub2-probe and that is what confuses me.

Thanks for any explanations.
_________________
Gentoo currently running in Virtualbox, hoping to switch to real hardware soon...
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2574

PostPosted: Sun Jul 20, 2014 3:39 am    Post subject: Reply with quote

P1neapple wrote:
OK, maybe I was unclear. I am confused on how I should configure GRUB2 to detect Windows.
I don't believe you where unclear at all.
P1neapple wrote:
If I install os-prober, will that setup everything for me if I run grub2-mkconfig right (if I also get ntfs3g)? Because the wiki page that The Doctor linked talks about grub2-probe and that is what confuses me.

Thanks for any explanations.
This is my interpretation of the article as well (if you add the step "mount windows partition"). As I said, I don't use grub so I'm not 100% sure. If it is any consolation you will not harm windows if grub fails to detect it. The worst case scenario is that no OSs appear in the grub menu although the most likely failure is that only Gentoo will appear.

One note about mounting windows partitions. Under Linux you should always mount them read only if possible. Due to the proprietary nature of the MS file systems there is a high risk of damaging them if any writes are attempted.
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
schorsch_76
Guru
Guru


Joined: 19 Jun 2012
Posts: 450

PostPosted: Sun Jul 20, 2014 7:08 am    Post subject: Reply with quote

If you use grub2 and want to boot Windows and Linux from EFI, you need the following:

Code:
 cat /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# 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 "Windows x86_64 UEFI-GPT" {
    search --fs-uuid --no-floppy --set=root D48B-AA0B
    chainloader (${root})/efi/Microsoft/Boot/bootmgfw.efi
}


Replace D48B-AA0B with the block id if the ESP Partition

Linux Grub Entry:
Code:

menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-/dev/mapper/desktop-gentoo' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='hd1,gpt2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  058c5e95-60de-42a1-a48d-e7d4500ce1b8
        else
          search --no-floppy --fs-uuid --set=root 058c5e95-60de-42a1-a48d-e7d4500ce1b8
        fi
        echo    'Linux 3.14.13-slim wird geladen …'
        linux   /vmlinuz-3.14.13-slim root=/dev/mapper/desktop-gentoo ro keymap=de net.ifnames=0 root=/dev/desktop/gentoo crypt_root=UUID=2ed8e7d4-366d-432c-911c-800c0fb79dbd dolvm radeon.audio=0 quiet
        echo    'Initiale Ramdisk wird geladen …'
        initrd  /initramfs-genkernel-x86_64-3.14.13-slim
}


See
Code:
gdisk -l /dev/sdb
GPT fdisk (gdisk) version 0.8.10

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdb: 625142448 sectors, 298.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 80A358A5-BFC3-4C02-97E3-5C48C1AEA897
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 625142414
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1128447   550.0 MiB   EF00  efi-boot
   2         1128448         3225599   1024.0 MiB  8300  boot
   3         3225600       625142414   296.6 GiB   0700  Windows 7


You need the boot partition for Linux on the same drive as the ESP Partiton. Otherwise the EFI Loader wont find the additional files like grub.cfg. In my case sdb2 (boot). The Root partiton can be where you like it to be.

Configure grub with with
Code:
# UEFI
GRUB_PLATFORMS="efi-64 pc"


and install it like
Code:

grub2-install --target=x86_64-efi
with everything mounted. inside your installation chroot. /boot and /boot/efi mounted.

Inside the ESP partition you will find such a tree:
Code:

/boot/efi/
└── EFI
    ├── Boot
    │   └── bootx64.efi
    ├── Microsoft
    │   └── Boot
    │       ├── BCD
    │       ├── BCD.LOG
    │       ├── BCD.LOG1
    │       ├── BCD.LOG2
    │       ├── BOOTSTAT.DAT
    │       ├── Fonts
    │       │   ├── chs_boot.ttf
    │       │   ├── cht_boot.ttf
    │       │   ├── jpn_boot.ttf
    │       │   ├── kor_boot.ttf
    │       │   └── wgl4_boot.ttf
    │       ├── bootmgfw.efi
    │       ├── bootmgr.efi
    │       ├── cs-CZ
.....
    │       ├── zh-HK
    │       │   ├── bootmgfw.efi.mui
    │       │   └── bootmgr.efi.mui
    │       └── zh-TW
    │           ├── bootmgfw.efi.mui
    │           └── bootmgr.efi.mui
    └── gentoo
        └── grubx64.efi


You need for the Linux Kernel Following configs set:
Code:

CONFIG_EFI_PARTITION=y
CONFIG_EFI=y
# CONFIG_EFI_STUB is not set
CONFIG_FB_EFI=y
# EFI (Extensible Firmware Interface) Support
CONFIG_EFI_VARS=y
CONFIG_EFIVAR_FS=y
Back to top
View user's profile Send private message
P1neapple
n00b
n00b


Joined: 18 Jul 2014
Posts: 35

PostPosted: Sun Jul 20, 2014 9:00 am    Post subject: Reply with quote

I am quite sure the title of this topic says BIOS MBR so I am currently not interested in UEFI issues.
_________________
Gentoo currently running in Virtualbox, hoping to switch to real hardware soon...
Back to top
View user's profile Send private message
schorsch_76
Guru
Guru


Joined: 19 Jun 2012
Posts: 450

PostPosted: Sun Jul 20, 2014 10:10 am    Post subject: Reply with quote

P1neapple wrote:
I am quite sure the title of this topic says BIOS MBR so I am currently not interested in UEFI issues.


Ok, i was just under the impression, that you had trouble installing under EFI and try to install in BIOS Mode. So just ignore it ;)
Back to top
View user's profile Send private message
creaker
l33t
l33t


Joined: 14 Jul 2012
Posts: 651

PostPosted: Sun Jul 20, 2014 10:47 am    Post subject: Reply with quote

P1neapple, do not worry, Grub2 works just fine.
At my box I have 3 Gentoo installation + Windows XP + Windows 7 + LinuxMint Live iso system simultaneously. Grub2 works with this herd just fine.
Of course, os-prober and ntfs-3g should be installed.

If you have a doubt, you can save current mbr copy into the file before running grub2-install
Code:
dd if=/dev/sdX of=/path/to/save/sdX.mbr bs=512 count=1


If you will mess something, you will be able to restore initial mbr. Just save a mbr copy, somewhere you can access it later.
Back to top
View user's profile Send private message
janga8
n00b
n00b


Joined: 14 Jul 2014
Posts: 32

PostPosted: Sun Jul 20, 2014 1:16 pm    Post subject: Reply with quote

Install os-prober and ntfs3g.

when they are installed type:
Code:
 os-prober


then run
Code:
 grub2-mkconfig -o /boot/grub/grub.cfg


this works fine on my dualboot laptop
Back to top
View user's profile Send private message
P1neapple
n00b
n00b


Joined: 18 Jul 2014
Posts: 35

PostPosted: Mon Jul 21, 2014 6:21 am    Post subject: Reply with quote

@janga8 Judging by the README in the sources of os-prober, os-prober does nothing but output strings based on the operating systems in detects. So other software i.e. GRUB2 have to depend on it and call it and capture their strings to determine the setup of the configuration of GRUB.

TL;DR os-prober is called by GRUB2 so it does not have to be called separately AFAIK
_________________
Gentoo currently running in Virtualbox, hoping to switch to real hardware soon...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum