Windows – “Missing Operating System” on Windows 10 Bootcamp after partition

bootcampwindows

After trying to install a third operating system Windows 10 won't boot, displaying the message "Missing Operating System". My problem seems to be very similar to this one: Triple Boot: "Missing operating system" on Windows 7 partition after Ubuntu installation

However, I followed the steps provided in the solution and it still shows the same error. I have tried many other solutions and none have worked; I can't figure out what I'm missing.

diskutil list disk0:

enter image description here

sudo gpt -r show /dev/disk0:

enter image description here

sudo fdisk /dev/disk0:

enter image description here

Thanks in advance!

Best Answer

You have a couple of problems.

  • Your EFI System Partition (ESP) is missing in your GPT partition table (so it has 2 partitions not 3). This will prevent Windows booting if installed in EFI mode.
  • Your hybrid MBR partition table is corrupt. Your APFS partition is marked active and has partition id type 07 (Microsoft) when it should have AF (Apple). Your BOOTCAMP partition is also missing. This will prevent Windows booting if installed in BIOS mode.

MacOS will boot directly from firmware, doesn't require ESP to boot (most of the time) and ignores hybrid MBR.

First recreate ESP

It is likely that the contents are still there - you just need to add it's definition to your GPT partition table. You have unallocated space from positions 34 to 409606. You need to add the partition back to the table in this space which you can do using gdisk which you can download from here https://sourceforge.net/projects/gptfdisk/

Install it, then open using sudo gdisk /dev/disk0 and you should see something like this :

$ sudo gdisk /dev/disk0
Password:
GPT fdisk (gdisk) version 1.0.4

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

Found valid GPT with hybrid MBR; using GPT.

Command (? for help):

Take option p to show GPT partition table and you should see your first partition starting at position 409640 (same as mine below). Note I deleted my EFI partition table entry here so as to look the same as yours but my second partition started at the same number as you as it is the standard position after a 200MiB ESP.

Recovery/transformation command (? for help): p
Disk /dev/disk0: 250069680 sectors, 119.2 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 569B72DC-B014-4DD3-B28A-A95CA047CBEE
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 250069646
Partitions will be aligned on 8-sector boundaries
Total free space is 525694 sectors (256.7 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   2          409640       172376718   82.0 GiB    0700  MacWindows
   3       172378112       180766719   4.0 GiB     2700  Recovery
   4       180766720       201738239   10.0 GiB    8300  Arch
   5       201738240       222447615   9.9 GiB     AF00  Lion
   6       222709760       249807495   12.9 GiB    AF00  El Capitan

Now you want to backup your partition table using option b. This will save it to your home folder and can be used to restore if you make a mistake.

Command (? for help): b       
Enter backup filename to save: GPTBackup.bin
The operation has completed successfully.

Now add the missing partition table entry with option n. You can take defaults but make sure you set partition type to EF00 which is EFI. The start position is important - try 40 as it is the default and also what your fdisk screen print shows. The end position doesn't matter so just take one less than the next partition.

Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-250069646, default = 40) or {+-}size{KMGTP}: 40
Last sector (40-409639, default = 409639) or {+-}size{KMGTP}: 409639
Current type is 'Apple HFS/HFS+'
Hex code or GUID (L to show codes, Enter = AF00): EF00
Changed type of partition to 'EFI System'

You can then take option p to show GPT partiton table. Note nothing is saved yet.

Create Hybrid MBR

Take options followed by r, h to create new hybrid MBR partition table. All you want to put there is the Windows partition which will be your 3rd GPT partition now you've added the ESP. Take the option to add 0xEE protective MBR, set the type code for BOOTCAMP partition to 0700 and make it bootable.

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: 3
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): y

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

You can then use option o to check it.

Recovery/transformation command (? for help): o

Disk size is 250069680 sectors (119.2 GiB)
MBR disk identifier: 0xEBD711AE
MBR partitions:

Number  Boot  Start Sector   End Sector   Status      Code
   1                     1       409639   primary     0xEE
   2      *         409640    172376718   primary     0x07
   3             172378112    180766719   primary     0x27
   4             180766720    201738239   primary     0x83

It doesn't much matter what is in your hybrid MBR partition table as long as Windows (and Linux if you are booting it in BIOS mode) start and end at the same sectors as in the GPT table. As you can see I don't have any macOS listed at all as it EFI boots even on my 2007 MBP so what is here is irrelevant for it. Note that if you were booting Windows in EFI mode it also would not care what is in hybrid member or even be able to see it.

If you are happy you can take option w and write the new partition table to disk.

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.

It should now boot whether you installed Windows in BIOS or EFI mode. If it doesn't then you will need to fix bootloader with Windows standard bcdboot command but repairing partition tables is required first.