Repair Windows Boot Loader after installing Ubuntu on MacBook Pro

11,105

Solution 1

Your problem is that your Windows installation is in EFI mode, but your disk is configured with a hybrid MBR, which forces Windows to treat the disk as an MBR disk. The Mac boot loader might also be taking this as a signal to attempt a BIOS-mode boot of Windows, but there's no BIOS-mode boot loader on the disk. Since Windows will boot in EFI mode only from a GPT disk, this configuration results in a failed boot. There may be other problems, too, but this one is the first issue I see, and it will definitely cause a failure to boot, so you should fix this problem.

Fortunately, the solution is fairly straightforward, albeit non-intuitive:

  1. Boot to Ubuntu. (You can also do this from OS X, but you'd need to install gdisk and use a different disk device filename.)
  2. Open a Terminal window.
  3. Type sudo gdisk /dev/sda. After you're prompted for your password, gdisk should launch and tell you, among other things, MBR: hybrid.
  4. Type p to view the partition table. Assuming you know enough about your partitions, you should be able to verify that you're looking at the right disk. If not, type q to quit and try another disk device.
  5. Type x to enter the experts' menu.
  6. Type n to create a fresh protective MBR to replace your existing hybrid MBR.
  7. Type p again to verify that your partitions are all still in place. This is just a precaution to ensure you didn't accidentally hit the wrong key.
  8. Type w to save your partition table. You'll be asked to verify this action. Do so.

With any luck, this should fix your problem.

Solution 2

If Bootrec shows the “The requested system device cannot be found” error, the following steps will help build a new BCD:

  1. Type this command:

    bcdedit /export D:\BCDBackup
    
  2. Type

    d:
    

    where d: is where your Windows is installed

  3. Type

    cd boot
    
  4. Type this command:

    attrib bcd -s -h -r
    
  5. Type this command:

    ren d:\boot\bcd bcd.old
    
  6. Type this command:

    bootrec /RebuildBcd
    

Hope this helps.

Credit

Share:
11,105

Related videos on Youtube

Yingbo Wang
Author by

Yingbo Wang

An Apple user. Exploring Linux (Ubuntu), and iOS developing for fun.

Updated on September 18, 2022

Comments

  • Yingbo Wang
    Yingbo Wang over 1 year

    I installed Ubuntu 14.04.2 LTS on MacBookPro11,5 (Retina) with Mac OS X Yosemite following this guide: https://help.ubuntu.com/community/MacBookPro11-1/Saucy

    The thing is that I already have Windows 8.1 Pro installed via Boot Camp, so the Disk Utility on Mac OS cannot be used for re-partitioning the SSD. I used resizeStack in Terminal to shrink the OS X partition (guide here). Now the SSD is partitioned as:

    • /dev/sda1: EFI partition
    • /dev/sda2: OS X Yosemite
    • /dev/sda3: OS X Recovery HD
    • /dev/sda4: Boot Camp Windows 8
    • /dev/sda5: Ubuntu Disk mounted to /
    • /dev/sda6: Ubuntu Swap

    The Ubuntu boot loader is selected to install to /dev/sda1, but the installer notified that the Windows Boot Loader also exists in sda1. After installation, Ubuntu and Mac OS successfully booted from GRUB2, but the Windows cannot be booted either from GRUB2 or from the native Apple boot manager (pressing option when booting). I used Parallels Desktop to load the Boot Camp partition as a Virtual Machine and the Windows works.

    Solution #1

    I installed Boot Repair on Ubuntu and used the Recommended Repair, no luck; more entries are added to the Grub2 menu after repair. GRUB worked and Mac OS could be booted. Here is the Boot Info page created: http://paste.ubuntu.com/11897269/

    Solution #2

    I plugged in the Windows Installation flash drive and tried the automatic Startup Repair, which did not work. Then I attempted to repair the Master Boot Record by Command Prompt: bootrec /fixmbr

    After the repair Mac OS was set to be the first system to boot, so Grub menu did not appear while starting the computer. I used efibootmgr on the Ubuntu Installation flash drive to set back Ubuntu to be the first boot drive and Mac OS to be the second. Windows still cannot be booted.

    The weird thing is that this time the Apple boot manager did not attempt to boot Windows after the "Windows" disk icon is clicked; both the "Macintosh HD" and "Windows" icon will lead to Mac OS being booted. So the repair must have changed the Apple boot manager.

    Several Questions

    1. Seems that the Windows Boot Loader in /dev/sda1 is overwritten by Grub. So is there a way to make the Windows Boot Loader and Linux boot loader (it is Grub now, right?) coexist?

    2. A thing to notice is that the Boot Camp Windows 8 boots in EFI mode on MacBook Pro, as the setupact.log shows Callback_BootEnvironmentDetect: Detected boot environment: EFI. guide I also checked Grub that it works in EFI mode. Therefore does Windows also use GUID Partition Table (GPT) similar as Mac OS, instead of MBR? If so repairing MBR may not be useful.

    3. I am not sure where does the Apple boot switch reside, and how it can be changed by the Windows Installation drive? Is it also in /dev/sda1?

    I am a beginner on the subject. Thanks a lot for your answers!


    Updates:

    I tried the following commands in Windows Installation Command Prompt:

    • bootrec /fixmbr: Successful
    • bootrec /fixboot: Successful
    • bootrec /scanos: Identified 1 Windows Installation on D:\Windows
    • bootrec /rebuildbcd: Identified 1 Windows Installation on D:\Windows; The requested system device cannot be found.
    • bcdedit: The requested system device cannot be found.

    Windows cannot be booted, with error code 0xc000000e.

    Updates #2

    I followed Rod Smith's answer to convert my EFI partition from MBR: MBR only to MBR: protective and GPT: present, but then the 'Windows' option disappears from Apple boot manager and Grub cannot be booted.

    Also I followed Terrance's answer to rebuildbcd but did not succeed. See comments on their answers.

  • Yingbo Wang
    Yingbo Wang almost 9 years
    gdisk showed my /dev/sda1/ to be MBR: MBR only, and it was successfully converted to MBR: protective and GPT: present. However then the "Windows" option in Apple boot manager disappears. Also Grub does not start though it is selected in efibootmgr to be first booted. Mac OS can be booted correctly. I suspect that both the Boot Camp Windows 8 and Ubuntu are installed via BIOS, though they show themselves to be booted from EFI. Guess I have to reformat the SSD and reinstall Mac OS... Thanks!
  • Yingbo Wang
    Yingbo Wang almost 9 years
    Followed these operations but the 1st and 6th commands still could not be completed: The requested system device cannot be found. I guess the problem is highly possible to be in BCD. Thanks!
  • Rod Smith
    Rod Smith almost 9 years
    If you really operated on /dev/sda1, you erred; it should be /dev/sda (the whole disk, not a partition). Saving the results probably damaged your EFI System Partition (ESP) on the first partition, so you may need to run dosfsck on it or even take more drastic action. This would explain why the Windows boot option has disappeared. I strongly recommend you try to recover your ESP rather than re-install OS X (or any other OS).
  • therobyouknow
    therobyouknow over 4 years
    "If you really operated on /dev/sda1, you erred; it should be /dev/sda". I get an error when I try /dev/sda: sudo gdisk /dev/sda [sudo] password for robdavishome: GPT fdisk (gdisk) version 1.0.3 Problem opening /dev/sda for reading! Error is 2. The specified file does not exist!
  • Rod Smith
    Rod Smith over 4 years
    @therobyouknow, your problem is completely unrelated to this question. Please ask a new question.