Bootcamp – Fix for ‘No Bootable Device’ Error

bootcampdisk-utilitypartition

I installed Windows 7 on my 2011 MacBook Pro (MacOS High Sierra) successfully. It was recognized at boot time by the computer and had no problems.

Then I used Disk Utility to create some free space on the hard drive shared by MacOS and Windows. Now I get this message on boot to windows: no bootable device – insert boot disk and press any key

Using Finder, I can see that my Windows 7 files are all intact, but I cannot boot from Bootcamp!

Below is the output from the command diskutil list.

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage HARDISK                 600.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             87.8 GB    disk0s3
   4:       Microsoft Basic Data BOOTCAMP                120.0 GB   disk0s4 

Below is the output from fdisk /dev/disk0 in MacOS Recovery:

-bash-3.2# fdisk /dev/disk0
Disk: /dev/disk0 geometry: 121601/255/63 [1953525168 sectors]
Signature: 0xAA55
     Starting       Ending
#: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
1: EE 1023 254  63 - 1023 254  63 [         1 - 1953525167] <Unknown ID>
2: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
4: 00    0   0   0 -    0   0   0 [         0 -          0] unused  

Below is the output of ls -d /Volumes/BOOTCAMP/Boot in MacOS Recovery:

/Volumes/BOOTCAMP/Boot

Best Answer

With the release of High Sierra, Apple has forgotten about the needs of Windows 7 users. The right (or is it wrong) combination of commands causes eraser of the values stored in the Master Boot Record (MBR) table. Windows 7 uses these values to determine the partitioning of the drive. Fortunately, these values are duplicated in the GUID partition table (GPT). Unfortunately, you will have to preform the tedious task of reentering the missing values.

Unless you disable System Integrity Protection (SIP), the solutions given below requires booting to macOS Recovery via the internet, built-in recovery or an USB flash drive macOS installer. Once booted to macOS Recovery, open a Terminal application window.

Note: The Terminal application can be found under "Utilities" on the menu bar.

Solution without Using Third Party Tools

The answer given below is based on my answer to the question How to convert a drive from the GPT format to the hybrid GPT/MBR format when using High Sierra (macOS 10.13.2). You should read this question and answer before proceeding. The command given below can be used to partially display the information contained in GUID partition table (GPT) stored on disk0. You will need this information when editing the Master Boot Record (MBR) table.

gpt -r show /dev/disk0 

Here are the steps involving in editing the MBR table to create a hybrid partitioning scheme. You will be preforming the same steps as given in this answer, except for the changes given below.

  1. The interactive command to edit the MBR partition table is given below. All changes will be not be entered in CHS mode.

    fdisk -e /dev/disk0
    

    Entering this command produced the following output

    fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
    Enter 'help' for information
    fdisk: 1> 
    

    Note: The control+C key can be pressed at anytime to terminate the fdisk command without saving any changes.

  2. The only entry, in the initial MBR table, defines a "Protective Partition". This partition needs to be truncated to the end of the first partition in the GPT with the GUID of C12A7328-F81F-11D2-BA4B-00A0C93EC93B. This means the start value should remain 1, but the size value should be reduced to the value start + size - 1. The values use in this equation should be taken from GPT. The computed value usually is 409639.

    Below are the correct values to enter into fdisk for the first partition of the MBR table. Replace <start + size - 1 of GPT partition with index=1> with the computed integer value.

    edit 1
    EE
    N
    1
    <start + size - 1 of GPT partition with index=1>
    
  3. Next, enter the correct values for second partition of the MBR table. The command is edit and the id is AC. The start and size values are the same as shown in the GPT. Doing so, results in what is shown below.

    edit 2
    AC
    N
    <start of GPT partition with index=2>
    <size of GPT partition with index=2>
    
  4. Repeat the previous step to update MBR table partitions 3 and 4. This is shown below. The id for partition 3 is AB and for partition 4 is 07.

    edit 3
    AB
    N
    <start of GPT partition with index=3>
    <size of GPT partition with index=3>
    edit 4
    07
    N
    <start of partition with index=4>
    <size of partition with index=4>
    
  5. The next command flags the fourth MBR partition as bootable. This partition was chosen because this is where the Windows resides.

    flag 4
    
  6. The next command to enter is print. This command displays what the updated MBR table would look like. You can use the output to verify your changes.

    Note: The descriptions such as <Unknown ID>, Xenix BBT and HPFS/QNX/AUX are either wrong and/or outdated. Also, the cyl, hd and sec values are no longer used by macOS or Windows so you can ignore these values.

  7. The final command quit writes the table back to the MBR, then quit fdisk. This is shown below.

    fdisk:*1> quit
    Writing current MBR to disk.
    Device could not be accessed exclusively.
    A reboot will be needed for changes to take effect. OK? [n] Y
    

    As the above message suggests, it would be a good idea to restart the Mac.

Solution Using a Third Party Tool

The command gdisk is a third party tool that can be used to avoid having to manually enter the partition values from the GPT. You can download gdisk from this SourceForge website. Once booted to macOS Recovery, you would need to enter the command given below.

/Volumes/HARDISK/usr/local/bin/gdisk  /dev/disk0

Note: I assume the name of your macOS boot volume is HARDDISK. If not, make the appropriate substitution.

An example of your input to gdisk is given below.

GPT fdisk (gdisk) version 1.0.3

Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): r

Recovery/transformation command (? for help): h

WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one,
just hit the Enter key at the below prompt and your MBR partition table will
be untouched.

Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 2 3 4
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): y

Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default AF): ac
Set the bootable flag? (Y/N): n

Creating entry for GPT partition #3 (MBR partition #3)
Enter an MBR hex code (default AB): ab
Set the bootable flag? (Y/N): n

Creating entry for GPT partition #4 (MBR partition #4)
Enter an MBR hex code (default 07): 07
Set the bootable flag? (Y/N): y

Recovery/transformation command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/disk0.
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.

As the above message suggests, it would be a good idea to restart the Mac.

Final Thoughts

If you Mac still fail to boot to Windows, then you will need to rebuild your Windows boot code. For this you will need a flash drive you used to install Windows 7. Let me know if you need instructions.

If you read all the way down to this point, I might as well mention the other problem. Your Recovery HD partition is not suppose to be 87.8 GB in size. This has nothing to do with Windows, but I thought I should point it out.