MacOS – Different partition configuration between gpt and fdisk

bootcampdiskutilmacospartition

After resizing my HFS partition (to solve a case sensitive/insensitive problem) I found out my BOOTCAMP partition was no longer accessible. As I navigate the web, I found out this is a common issue and there are several pages describing possible solutions.

Most of them begin by asking the user to analyse the output from the following commands:

sudo gpt -r -vv show disk0

gpt show: disk0: mediasize=750156374016; sectorsize=512; blocks=1465149168
gpt show: disk0: PMBR at sector 0
gpt show: disk0: Pri GPT at sector 1
gpt show: disk0: Sec GPT at sector 1465149167
       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  1063995800      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1064405440     1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  1065674976     1269536      4  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  1066944512   398202880      5  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  1465147392        1743
  1465149135          32         Sec GPT table
  1465149167           1         Sec GPT header

sudo fdisk /dev/disk0

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

diskutil list

dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *750.2 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            544.8 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:                 Apple_Boot                         650.0 MB   disk0s4
   5:       Microsoft Basic Data BOOTCAMP                203.9 GB   disk0s5

My question is, how can fdisk and gpt show different partition configurations?

Also do you think my BOOTCAMP partition is recoverable?

My laptop is an early 2011 Macbook Pro (quad i7) running El Capitan and Windows 10 64bit in bootcamp (upgraded from windows 7).

The procedure that led to this state was:

  1. Resize Macintosh HFS+ partition to half its size
  2. Created a new HFS+ non case sensitive partition between the original and bootcamp.
  3. Mirrored the original partition to the new one.
  4. Formatted the original partition case insensitive.
  5. Mirrored the new partition to the original one.
  6. Deleted the new partition.
  7. Resized the original HFS partition to occupy the whole space.

Thanks in advance for your help.

Best Answer

Update 1

This step will involve configuring Master Boot Record (MBR) of your physical internal drive. The MBR is stored on the first 512 bytes of this drive. This space is shared by boot code and the MBR partition table.

This step can not be preformed under OS X 10.11 (El Capitan) with System Integrity Protection (SIP) turn on. (This is the default setting.) If you are using OS X 10.11, you must disable SIP, complete this step, then restore SIP. See the link: How do I disable System Integrity Protection (SIP) AKA “rootless” on OS X 10.11, El Capitan?.

In a Terminal application window, enter the following commands. The first fdisk command flags the Windows partition as the active partition. The second fdisk command changes the Windows partition id to 7.

INPUT=$(printf  "f  4\nq\ny")
sudo  fdisk  -e  /dev/disk0  <<<"$INPUT"  &>/dev/null
INPUT=$(printf  "s  4\n7\nq\ny")
sudo  fdisk  -e  /dev/disk0  <<<"$INPUT"  &>/dev/null

You may need to restart your computer after completing this step.

Original Answer

The command fdisk displays the contents of the Master Boot Record (MBR) partition table. This table can only contain 4 entries and is stored at address 0 of your disk. The command gpt displays the contents of the GUID partition table (GPT). This table can contain 120 entries and starts at address 1 of your disk. (A backup GPT is also stored at the end of the disk.) Legacy systems use a MBR scheme while more modern computers use a GPT scheme. Normally, OS X uses a GPT scheme. When the GPT is employed, the MBR table still exists, but is now called a Protective Master Boot Record (PMBR) table. This PMBR table contains a single entry with ID of EE. This fools any legacy applications, that only use a MBR scheme, into seeing the disk as occupied by a single partition.

Older Mac computers install Windows using the MBR scheme. It is my understanding this is also a requirement for Windows 7 installations. To accommodate both schemes simultaneously, Apple shrinks the EE partition in the MBR table to end at the same location as the first partition in the GPT. Usually, the next three partitions in the GPT match the last three partitions in the MBR table.

Anyway, as far as I can tell, if you enter the command given below in a Terminal application windows, your partitions should be fixed.

sudo diskutil eraseVolume "Free Space" name /dev/disk0s4

While the above command should fix the partitioning, the 4th partition in the MBR partition table will not be marked as "active". So if you still can not boot to Windows, let me know and I will include steps to mark this partition as "active".