booting windows from secondary mbr harddisk not working

2013-11-01
2014-05-22
  • With the limitations of hybrid and protective mbr to only 4 partitions I've added a second disk to my mbp to run triple boot with os x, windows and Ubuntu and get the space for data-exchange partitions.

    Booting into Ubuntu works, its installed using grub2 boot-loader on the partition rather than the mbr - though I can boot it with either efi64 or shim efi loaders via refind.

    Unfortunate Windows (w7) is still refusing to boot with refind, selecting to boot it with refind results in black screen with operating system not found. If I use the apple boot-loader it comes up properly.

    I've tried having a efi partition on the secondary disk with and without, neither worked. Any suggestions of how I can configure this setup to boot windows 7 with refind?

     
  • I recommend against booting Linux in BIOS mode on a Mac; instead, I recommend using rEFInd and, if necessary, an EFI filesystem driver, to boot a Linux kernel directly in EFI mode. This eliminates GRUB and it eliminates the need for a hybrid MBR for Linux (albeit not for Windows in a triple-boot configuration). See the rEFInd Linux documentation for more on this approach.

    Note also that neither Linux nor OS X relies on the hybrid MBR. In theory, all you need in the hybrid MBR is the Windows partition and any shared-data partition(s) that Windows must be able to read. Thus, a triple-boot on a single disk is possible -- but you'll need to know how to set up the hybrid MBR. (Both Boot Camp and rEFIt's version of gptsync hybridize partitions that needn't be hybridized, which can make it impossible to hybridize those that need to be hybridized. rEFInd's gptsync and gdisk are both better at this.)

    As to Windows, I've seen a couple of reports of Windows not booting from a second hard disk, but this seems to be fairly recent. If you could try some older versions of rEFInd to see if they work better, that would be helpful. In particular, I need to know the first version to exhibit the problem, so that I can do a code comparison between it and the final working version. That will give me some chance of identifying what change caused the problem.

     
  • Finally got to write down what my investigation turned out. I guess its all about the design choices we make when setting up a system.

    I've tried several versions of refind though neither worked booting windows from my secondary hard drive. That led me to believe the issue is actually not found with refind, in my system I've opted to format the secondary disk as mbr without a 100 MB EFI partition. While booting into Ubunutu linux works well with efi boot, Windows refuses to boot. Investigating that further it appears Windows 7 is not able to boot efi from a MBR formatted disk, it defaults to BIOS boot. One can only Windows7 EFI boot if the disk is formatted as GPT...

     
  • Joe van Tunen
    Joe van Tunen
    2014-03-19

    Is your goal to boot Windows using EFI or BIOS?

    Was the error message "operating system not found" or was it "Missing operating system"? Does it match the error message in the MBR? I'm trying to figure out where the error message came from. You can see the contents of the MBR using the following command (check both disks):

    sudo dd if=/dev/disk0 count=1 | xxd
    

    By "apple boot-loader", do you mean the Startup Manager? http://support.apple.com/kb/ht1310

    What was the name of the option you chose in the apple boot-loader? If it was "Windows", then it probably is booting using BIOS. How many "Windows" options were there? There could be two if both hard drives have boot code in their MBRs.

    If you're booting using BIOS, make sure the BootCampHD NVRAM variable is set correctly. Since you have more than one disk, it could be pointing to the wrong disk. To fix it, select the Windows partition in the Startup Disk preferences panel in System Preferences. Then leave Startup Disk to write the change to NVRAM. Then go back to Startup Disk and select your Mac OS X partition. You'll have to rebless rEFInd if you're not using something like rEFItBlesser to do it automatically.

    Check the BootCampHD NVRAM parameter before and after fixing it using the following command:

    ioreg -w 0 -n AppleEFINVRAM | sed -n -E "/^[ \|]+[ ]+(\".*)$/s//\1/p;"
    

    rEFIt had code to set the BootCampHD parameter for you when you select a legacy OS to boot. rEFInd does not have that code.

    If you want to boot Windows 7 using EFI or BIOS, but EFI doesn't work with a hybrid disk, then it would be useful for rEFInd to have an option to set the disk as hybrid (for BIOS) or not hybrid (for EFI). The hybrid option would require rEFInd to have stanzas for Legacy boot items. The hybrid option would include a list of up to 3 partitions of the GPT to include in the MBR.

     
  • Luke M
    Luke M
    2014-03-27

    I found that I can only do a BIOS boot from refind from the first HD in the system. Otherwise I get "Reboot and Select proper Boot Device or Insert Boot Media in selected Boot device and press a key" (this is a BIOS message that normally indicates an inability to load an MBR)

     
    • Joe van Tunen
      Joe van Tunen
      2014-03-27

      Which BIOS - Mac or PC? Which model? If it's a Mac then you should be able to use the Mac's built in Startup Manager (hold option key at startup) and select the "Windows" option that corresponds to the other HD. If that doesn't work then rEFInd won't be able to do any better even if it is fixed to support other HD's.

       
  • Luke M
    Luke M
    2014-04-04

    It's an AMI BIOS. For some reason, there's only one drive in the EFI boot order, and it's the wrong one (revealed by using efibootmgr -v). And changing the BIOS boot order in the BIOS settings has no effect.

    Q: What happens when you use efibootmgr to delete the automatically generated entries? Do they permanently disappear, or are new ones generated, or what? I'm a little hesitant to experiment...

     
  • Luke M
    Luke M
    2014-04-05

    I found out that my BIOS is checking for a bootable partition on the MBR and using that as a signal to determine whether to treat the disk as a "BIOS disk" or a "EFI disk". If it's a "BIOS disk", then it's invisible to EFI (rEFInd shows nothing). If an "EFI disk", then it will refuse to execute the MBR code, giving the "reboot and select proper Boot Device..." message.

     
  • Luke M
    Luke M
    2014-04-06

    Correction...I found that after installing grub in the MBR, the state of the boot flag no longer mattered! I can boot the (GPT) drive in either BIOS or EFI mode, no problem. So I don't know what the BIOS is looking for really.

    Incidentally, grub2 fully supports >2TB drives. Not only can /boot be located above 2TB (on both EFI and BIOS systems), the grub partition on GPT drives can be located above 2TB. It uses 64-bit sector numbers throughout, including in the MBR code.

     
  • Luke, it sounds like you're using a PC, not a Mac. Unfortunately, rEFInd's BIOS boot code is even more primitive and flaky for PCs than it is for Macs. I've looked into this, but I've not had much luck with improving it as of yet. Your best bet is to stick to EFI-mode booting whenever possible, and if you need to boot something in BIOS/CSM/legacy mode, arrange your hard disks such that the BIOS-mode booting can be controlled by a single BIOS-mode boot loader on the first hard disk. That might get it working -- but even then, EFI-to-EFI variations can make it hard to get everything to work the way you want.

     
  • Luke M
    Luke M
    2014-05-02

    Yes, I came to the same conclusion. I've got grub2 installed in BIOS mode, in addition to EFI. Works fine, and I can launch linuxes in either mode (maybe there is some subtle danger in doing so, but I don't think so...everything seems to work perfectly).

     
  • FWIW, rEFInd 0.8.0 includes significant improvements to the UEFI-side BIOS/CSM/legacy boot support. In particular, rEFInd can now boot from more than just the first disk of a given type.

    That said, I still recommend booting Linux in EFI mode whenever possible.

     
  • Luke M
    Luke M
    2014-05-15

    Hey! It works now! (v0.8.0)

    One strange problem, though: I get duplicate legacy BIOS boot entries ("WDC WD30EZRX-00D8PB0") permanently added whenever I do a BIOS boot (but oddly, only when booting from the other drive).

    I doubt rEFInd is adding them...it's probably a bug in my (AMI) BIOS.

     
  • Actually, it is rEFInd adding them. Are you seeing the multiple entries in rEFInd's menu, or only in the firmware's menu? I've only seen it in the firmware's menu, and even then not consistently; in rEFInd, I've only ever seen one entry per disk. I'm not sure what's causing the problem. (The relevant code is taken from Tianocore with few changes, so I'm not as familiar with it as I am with code I've written myself.)

     
  • Luke M
    Luke M
    2014-05-16

    In the firmware menu. There's no duplication in rEFInd menu.

    If I use rEFInd to BIOS boot from drive 1, there's no duplicates created. Only when booting from drive 2...and it's drive 1 that gets duplicated, not drive 2.

    You probably can't answer this, but is it safe to delete legacy BIOS entries using efibootmgr? Will they be automatically regenerated?

     
  • Yes, you can delete legacy BIOS entries using efibootmgr. They will probably be regenerated, but the details depend on what you're doing. Normally, your firmware will add entries back, but if you've configured rEFInd for BIOS-mode booting, it will delete the firmware-generated entries and create its own. (This is admittedly a bit crazy, but it's the only way I know of to get rEFInd to reliably detect all the available disks.)

     
  • Luke M
    Luke M
    2014-05-16

    rEFInd is deleting and adding entries? Ah, well one thing I've noticed about my firmware is that delete doesn't always work. You can delete a boot entry with efibootmgr, and verify that it's deleted, but when you reboot it mysteriously reappears. So maybe this is the same problem.

     
  • I've created a test version of rEFInd that adds a new refind.conf token, uefi_deep_legacy_scan. In this version, the default behavior is to not update the legacy entries in the NVRAM, but if you uncomment the uefi_deep_legacy_scan option, it will behave as it does now. Leaving this setting uncommented might help prevent entries from multiplying, if that's becoming a problem. Here's the binary:

    http://www.rodsbooks.com/refind-bin-0.8.1.1.zip

    The source code is in git.

     
  • Luke M
    Luke M
    2014-05-22

    Here's some info that might clarify things a little bit. First, efibootmgr -v starting fresh:

    [code]
    BootCurrent: 000B
    Timeout: 0 seconds
    BootOrder: 000E,0010,000B,0004,0007,000F
    Boot0004 Windows Boot Manager HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(\EFI\Microsoft\ Boot\bootmgfw.efi)
    Boot0007
    Fedora HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(\EFI\fedora\grubx64.efi
    )
    Boot000B ubuntu HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(EFI\Ubuntu\grubx64.efi)
    Boot000E
    CD/DVD Drive BIOS(3,0,00)AMGOAMNO........m.A.T.A.P.I. . . .i.H.B.S.1.1.2. . . .2...............
    .....A.........................>..Gd-.;.A..MQ..L.B.B.0.D.L.C.8.0.3.0.9.4. . . . . . . . ......AMBO
    Boot000F UEFI: SanDisk ACPI(a0341d0,0)PCI(1d,0)USB(1,0)USB(6,0)USB(4,0)HD(1,20,ee6be0,00000000)AMBO
    Boot0010
    Hard Drive BIOS(2,0,00)AMGOAMNO........m.W.D.C. .W.D.1.5.E.A.R.S.-.0.0.M.V.W.B.0.............
    .......A.........................>..Gd-.;.A..MQ..L. . . . .W. .-.D.M.W.Z.A.2.A.1.3.4.3.5.2......AMBOAMNO..
    ......m.W.D.C. .W.D.3.0.E.Z.R.X.-.0.0.D.8.P.B.0....................A.........................>..Gd-.;.A..M
    Q..L. . . . .W. .-.D.M.W.4.C.1.N.1.6.5.8.1.4......AMBOAMNO.......].S.a.n.D.i.s.k....................A.....
    ..............................$..Gd-.;.A..MQ..L.S.a.n.D.i.s.k......AMBO
    [/code]

    Now efibootmgr -v after running refind with uefi_deep_legacy_scan:

    [code]
    BootCurrent: 000F
    Timeout: 0 seconds
    BootOrder: 000B,0004,0007,000F,0000,0001,0003,0002
    Boot0000 SATA SM: WDC WD30EZRX-00D8PB0 BIOS(2,0,534154412020534d3a205744432057443330455a52582d303
    0443850423000)...............................................................s.......
    Boot0001
    SATA SS: WDC WD15EARS-00MVWB0 BIOS(2,0,53415441202053533a205744432057443135454152532d303
    04d5657423000)..............................................................Mp.......
    Boot0002 SATA SM: ATAPI iHBS112 2 2 BIOS(3,0,534154412020534d3a2041544150492020206948425331313
    22020203220203200)...............................................................h.......
    Boot0003
    SanDisk BIOS(2,500,53616e4469736b00)........................4.]...........................
    .................
    Boot0004 Windows Boot Manager HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(\EFI\Microsoft\ Boot\bootmgfw.efi)
    Boot0007
    Fedora HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(\EFI\fedora\grubx64.efi
    )
    Boot000B ubuntu HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(EFI\Ubuntu\grubx64.efi)
    Boot000F
    UEFI: SanDisk ACPI(a0341d0,0)PCI(1d,0)USB(1,0)USB(6,0)USB(4,0)HD(1,20,ee6be0,00000000)AMBO
    [/code]

    Nice and clean! Note that entry 10 has been deleted. And refind works perfectly. But after rebooting, things get messy:

    [code]
    BootCurrent: 000B
    Timeout: 0 seconds
    BootOrder: 000B,0004,0007,000F,0000,0001,0003
    Boot0000 Hard Drive BIOS(2,0,00)AMGOAMNO........+.S.A.T.A. . .S.M.:. .W.D.C. .W.D.3.0.E.Z.R.X.-.0.0.D.
    8.P.B.0.....'.....SATA SM: WDC WD30EZRX-00D8PB0....AMBO..................................................
    .............s.......
    Boot0001
    SATA SS: WDC WD15EARS-00MVWB0 BIOS(2,0,53415441202053533a205744432057443135454152532d303
    04d5657423000)..............................................................Mp.......
    Boot0002 CD/DVD Drive BIOS(3,0,00)AMGOAMNO........-.S.A.T.A. . .S.M.:. .A.T.A.P.I. . . .i.H.B.S.1.1.2. .
    . .2. . .2.....).....SATA SM: ATAPI iHBS112 2 2....AMBO............................................
    ...................h.......AMNO........m.A.T.A.P.I. . . .i.H.B.S.1.1.2. . . .2....................A.......
    ..................>..Gd-.;.A..MQ..L.B.B.0.D.L.C.8.0.3.0.9.4. . . . . . . . ......AMBO
    Boot0003
    WDC WD30EZRX-00D8PB0 BIOS(2,0,00)AMGOAMNO........m.W.D.C. .W.D.1.5.E.A.R.S.-.0.0.M.V.W.B.0.....
    ...............A.........................>..Gd-.;.A..MQ..L. . . . .W. .-.D.M.W.Z.A.2.A.1.3.4.3.5.2......AM
    BOAMNO.......].S.a.n.D.i.s.k....................A...................................$..Gd-.;.A..MQ..L.S.a.
    n.D.i.s.k......AMBO
    Boot0004 Windows Boot Manager HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(\EFI\Microsoft\ Boot\bootmgfw.efi)
    Boot0007
    Fedora HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(\EFI\fedora\grubx64.efi
    )
    Boot000B ubuntu HD(2,40800,fa000,0a97c9c9-e25d-4eed-b0a4-316b9323ca66)File(EFI\Ubuntu\grubx64.efi)
    Boot000F
    UEFI: SanDisk ACPI(a0341d0,0)PCI(1d,0)USB(1,0)USB(6,0)USB(4,0)HD(1,20,ee6be0,00000000)AMBO
    [/code]

    Basically the problem seems to be that after a reboot, the firmware adds its own legacy boot entries back that were deleted by refind, and this results in duplication (WD30 appears in boot menu 4 times). But in this state, I can use refind without uefi_deep_legacy_scan and it still works.

     

    Related

    Code: code