Windows – How to convert a drive from the GPT format to the hybrid GPT/MBR format when using High Sierra (macOS 10.13.2)

bootbootcamppartitionwindows

Previous versons of OS X and macOS automatically converted pure GPT drives to hybrid GPT/MBR format when the 2nd, 3rd, and/or 4th GPT partitions were formatted "MS DOS (FAT)" by the Disk Utility application or the diskutil command. I am not sure when this changed, but this no longer happens under High Sierra (macOS 10.13.2).

My Mac needs the hybrid format in order to BIOS boot the installed Windows operating system.

What is a procedure to manually convert the drive back to the hybrid format?

Below is the output from the command diskutil list disk0.

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         249.5 GB   disk0s2
   3:       Microsoft Basic Data BOOTCAMP                200.0 GB   disk0s3
   4:       Microsoft Basic Data COMMON                  50.0 GB    disk0s4
   5:                  Apple_HFS Refind                  200.0 MB   disk0s5

The BOOTCAMP volume is NTFS formatted and the COMMON volume is FAT32 formatted.

Note: The next two commands were executed after starting up from macOS Recovery.

Below is the output from the command gpt -r show /dev/disk0.

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  487304680      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  487714320        496         
  487714816  390623232      3  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  878338048       2048         
  878340096   97654784      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  975994880        696         
  975995576     390616      5  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  976386192     176315         
  976562507         32         Sec GPT table
  976562539          1         Sec GPT header

Below is the output from the command fdisk /dev/disk0.

Disk: /dev/disk0    geometry: 60788/255/63 [976562540 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -  976562539] <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    

Best Answer

Here, I assume you are using High Sierra (macOS 10.13.2).

To update the MBR partition table, a mapping of the partition types needs to be known. Below is a table of some commonly found types.

Note: The mapping is not one-to-one.

            Partition Type              MBR ID              UEFI GUID
--------------------------------------  ------  ------------------------------------
Apple Mac OS Extended (HFS+ or JHFS+)     AF    48465300-0000-11AA-AA11-00306543ECAC
Apple Boot (Recovery HD)                  AB    426F6F74-0000-11AA-AA11-00306543ECAC
Apple Core Storage                        AC    53746F72-6167-11AA-AA11-00306543ECAC
Apple File System (APFS)                  AF    7C3457EF-0000-11AA-AA11-00306543ECAC
Extensible Firmware Interface (EFI)       EE    C12A7328-F81F-11D2-BA4B-00A0C93EC93B
Linux Filesystem Data                     83    0FC63DAF-8483-4772-8E79-3D69D8477DE4
Linux Swap                                82    0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
Linux Logical Volume Manager (LVM)        8E    E6D6D379-F507-44C2-A23C-238F2A3DF928
Microsoft File Attribute Table (FAT32)    0C    EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
Microsoft Windows NT (NTFS) or ExFAT      07    EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
Microsoft Windows Recovery Environment    27    DE94BBA4-06D1-4D40-A16A-BFD50179D6AC

Here are the methods involving in editing the MBR table to create a hybrid partitioning scheme.

Method 1: Use the Third Party Tool gdisk

  1. While booted to macOS, download and install gdisk.

    Note: If you get the popup shown below, then will need to run the Terminal application command shown below before trying to install gdisk.

    xattr -d com.apple.quarantine ~/Downloads/gdisk-1.0.4.pkg
    

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

  2. Disable SIP and then boot back to macOS. This will allow you to use the commands gpt, gdisk and fdisk. You also can execute gpt, gdisk and fdisk from macOS Recovery, but this may require you to precede the gdisk command with a path.

  3. The command given below can be used to partially display the information contained in GPT stored on disk0. You will need this information verify the changes made to the MBR table. (See the above question for the output from this command.)

    gpt -r show /dev/disk0 
    
  4. Enter the command given below.

    sudo gdisk /dev/disk0
    
  5. Enter the input given below. This input is correct for the drive used as an example in this answer. Your actual input may vary from what is shown.

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

    r
    h
    2 3 4
    y
    af
    n
    07
    y
    07
    n
    w
    y
    

    Note: If you encounter the question shown below, enter the answer n.

    Unused partition space(s) found. Use one to protect more partitions? (Y/N):
    

    Below is an example of the output after entering the command and the above input.

    GPT fdisk (gdisk) version 1.0.4
    
    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): af
    Set the bootable flag? (Y/N): n
    
    Creating entry for GPT partition #3 (MBR partition #3)
    Enter an MBR hex code (default 07): 07
    Set the bootable flag? (Y/N): y
    
    Creating entry for GPT partition #4 (MBR partition #4)
    Enter an MBR hex code (default 07): 07
    Set the bootable flag? (Y/N): n
    
    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/disk4.
    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.

  6. Enter the command given below to verify the changes.

    sudo fdisk /dev/disk0
    

    Below is an example of the output after entering the command. Except for the start value of partition 1, the remaining start and size values should match the output from the gpt -r show /dev/disk0 command.

    Disk: /dev/disk4    geometry: 60788/255/63 [976562540 sectors]
    Signature: 0xAA55
             Starting       Ending
     #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
    ------------------------------------------------------------------------
     1: EE    0   0   2 -   25 127  14 [         1 -     409639] <Unknown ID>
     2: AF   25 127  15 - 1023 254  63 [    409640 -  487304680] HFS+        
    *3: 07 1023 254  63 - 1023 254  63 [ 487714816 -  390623232] HPFS/QNX/AUX
     4: 07 1023 254  63 - 1023 254  63 [ 878340096 -   97654784] HPFS/QNX/AUX
    

    Note: The descriptions <Unknown ID>, Xenix BBT and HPFS/QNX/AUX are either wrong and/or outdated.

  7. If desired, enable SIP.

Method 2: Use No Third Party Tools

Unless you disable System Integrity Protection (SIP), the solution 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.

  1. The command given below can be used to partially display the information contained in GPT stored on disk0. You will need this information when editing the MBR table. (See the above question for the output from this command.)

    gpt -r show /dev/disk0 
    
  2. 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.

  3. 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. Below is the resulting output from using the edit command to reduce the size of the first MBR partition.

    fdisk: 1> edit 1
             Starting       Ending
     #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
    ------------------------------------------------------------------------
     1: EE 1023 254  63 - 1023 254  63 [         1 -  976562539] <Unknown ID>
    Partition id ('0' to disable)  [0 - FF]: [EE] (? for help) EE
    Do you wish to edit in CHS mode? [n] N
    Partition offset [0 - 976562540]: [63] 1
    Partition size [1 - 976562539]: [976562539] 409639
    fdisk:*1>
    
  4. Next, enter the correct values for partition 2. The command is enter and the id is AF. The start and size values are the same as shown in the GPT. Doing so, results in what is shown below.

    fdisk:*1> edit 2
             Starting       Ending
     #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
    ------------------------------------------------------------------------
     2: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
    Partition id ('0' to disable)  [0 - FF]: [0] (? for help) AF
    Do you wish to edit in CHS mode? [n] N
    Partition offset [0 - 976562540]: [409640] 409640
    Partition size [1 - 976152900]: [976152900] 487304680
    fdisk:*1>
    
  5. Repeat the previous step to update partitions 3 and 4. This is shown below. The id for partition 3 is 07 and for partition 4 is 0C.

    fdisk:*1> edit 3
             Starting       Ending
     #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
    ------------------------------------------------------------------------
     3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
    Partition id ('0' to disable)  [0 - FF]: [0] (? for help) 07
    Do you wish to edit in CHS mode? [n] N
    Partition offset [0 - 976562540]: [487714320] 487714816
    Partition size [1 - 488847724]: [488847724] 390623232
    fdisk:*1> edit 4
             Starting       Ending
     #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
    ------------------------------------------------------------------------
     4: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
    Partition id ('0' to disable)  [0 - FF]: [0] (? for help) 0C
    Do you wish to edit in CHS mode? [n] N
    Partition offset [0 - 976562540]: [878338048] 878340096
    Partition size [1 - 98222444]: [98222444] 97654784
    fdisk:*1> 
    
  6. The next command flags the third partition as bootable. This partition was chosen because this is where the Windows resides.

    fdisk:*1> flag 3
    Partition 3 marked active.
    fdisk:*1> 
    
  7. The next command to enter is print. This command displays what the updated MBR table would look like. The result is shown below. You can use the output to verify your changes. Except for the start value of partition 1, the remaining start and size values should match the output from the gpt -r show /dev/disk0 command.

    fdisk:*1> print
    Disk: /dev/disk0    geometry: 60788/255/63 [976562540 sectors]
    Offset: 0   Signature: 0xAA55
             Starting       Ending
     #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
    ------------------------------------------------------------------------
     1: EE    0   0   2 - 1023 254  63 [         1 -     409639] <Unknown ID>
     2: AF 1023 254  63 - 1023 254  63 [    409640 -  487304680] Xenix BBT   
    *3: 07 1023 254  63 - 1023 254  63 [ 487714816 -  390623232] HPFS/QNX/AUX
     4: 0C 1023 254  63 - 1023 254  63 [ 878340096 -   97654784] Win95 FAT32L
    fdisk:*1> 
    

    Note: The descriptions <Unknown ID>, Xenix BBT and HPFS/QNX/AUX are either wrong and/or outdated.

  8. 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.

  9. If desired, enable SIP.