0

I would like to I've recently installed Debian Linux on my Macbook, which required repartitioning the hard drive.

I now can't boot into Recovery Mode. Holding down Command+R on boot brings up Internet Recovery Mode. Holding Option on boot brings up the Startup Manager, which lists the Recovery HD, but if I select it, regular OS X boots.

I'm using a Retina MacBook Pro Early 2015 13" on OS X 10.11.4

$ sudo gpt -r show /dev/disk0
gpt show: /dev/disk0: Suspicious MBR at sector 0
    start       size  index  contents
        0          1         MBR
        1          1         Pri GPT header
        2         32         Pri GPT table
       34          6         
       40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
   409640  843043264      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
843452904    1269536      3  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
844722440  123046872      4  GPT part - 0FC63DAF-8483-4772-8E79-3D69D8477DE4
967769312     262144         
968031456    8811424      5  GPT part - 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
976842880     262147         
977105027         32         Sec GPT table
977105059          1         Sec GPT header

$ sudo fdisk /dev/disk0
Disk: /dev/disk0    geometry: 60821/255/63 [977105060 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE    0   0   1 - 1023 254  63 [         1 -     409639] <Unknown ID>
*2: AF 1023 254  63 - 1023 254  63 [    409640 -  843043264] HFS+        
 3: AF 1023 254  63 - 1023 254  63 [ 843452904 -    1269536] HFS+        
 4: 83 1023 254  63 - 1023 254  63 [ 844722440 -  123046872] Linux files*

 $ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            431.6 GB   disk0s2
   3:                  Apple_HFS Recovery HD             650.0 MB   disk0s3
   4:           Linux Filesystem                         63.0 GB    disk0s4
   5:                 Linux Swap                         4.5 GB     disk0s5

$ diskutil cs list
No CoreStorage logical volume groups found
  • Could you enter the following commands in a Terminal application window and post the results to your question. The commands will not change your computer and may require your login password. The commands are sudo gpt -r show /dev/disk0, fdisk /dev/disk0, diskutil list, and diskutuil cs list. You can just cut and paste the results to your question. Someone will cleanup the output. Also, add the model/year of your Mac and the version of OS X you are using. – David Anderson Apr 20 '16 at 9:33
  • @DavidAnderson sure! Added to my question. – Eric Andrew Lewis Apr 21 '16 at 1:00
1

From the results you posted, I can see the GUID for the Recovery partition is wrong. This is partition number 3 in the tables. The correct value in the GPT would be 426F6F74-0000-11AA-AA11-00306543ECAC. The fdisk command also shows the value to be wrong in the MBR table. Here, the correct value should be AB. If you can not boot to your Recovery partition after repairing these tables, then I would assume the contents of the partition is corrupted.

As far as I know, there is no utility in OS X for this type of repair. (Technically, you could use the dd command, but no sane person would attempt using dd to fix this problem.) I would recommend downloading and installing the gdisk command from here. To install, you may have to modify the setting on the "Security & Privacy" pane of the "System Preferences".

To use the gdisk command, you will need to disable System Integrity Protection (SIP). Normally, this can be done while in Recovery mode. Since you can not boot to Recovery mode, you can use a product called "rEFInd". Many Linux users already have this product installed on their Mac computer. If you do not, you can create a USB flash drive version which can be used to disable/enable SIP. The instructions are given here.

Note: Since you have Debian Linux already installed, you may be able to execute gdisk from this operating system. Since I do not have this operating system installed, I am not going to pursue this further. You can obtain more information from this site. Also, gdisk may be available by booting from an external Emergency Disk. If available under Linux or from an Emergency Disk, you will not have to disable SIP.

Once gdisk is installed and SIP is disabled, you will need to make three changes. These changes involve modifying both the GUID Partition Table (GPT) and the Master Boot Record (MBR) partition table. The changes are listed below.

  1. Change the type GUID for partition 3 in the GPT from 48465300-0000-11AA-AA11-00306543ECAC to 426F6F74-0000-11AA-AA11-00306543ECAC. Note: gdisk uses a value of AB00 to represent the value 426F6F74-0000-11AA-AA11-00306543ECAC.
  2. Make sure the attribute for partition 3 is 0002000000000000. In the example below, I assume the current value for the attribute is 0000000000000000. If not, make the appropriate corrections.
  3. Change the id for partition 3 in the MBR table from AF to AB.

In the example below, I create and mounted a sparse image as /dev/disk1. I then used this image as input to the gdisk command. This was done to simulate the conditions on your computer. You will be making changes to your /dev/disk0.

Steelhead:~ davidanderson$ sudo gdisk /dev/disk1
GPT fdisk (gdisk) version 1.0.1

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): t
Partition number (1-5): 3
Current type is 'Apple HFS/HFS+'
Hex code or GUID (L to show codes, Enter = AF00): ab00
Changed type of partition to 'Recovery HD'

Command (? for help): x

Expert command (? for help): a
Partition number (1-5): 3
Known attributes are:
0: system partition
1: hide from EFI
2: legacy BIOS bootable
60: read-only
62: hidden
63: do not automount

Attribute value is 0000000000000000. Set fields are:
  No fields set

Toggle which attribute field (0-63, 64 or <Enter> to exit): 49
Have enabled the 'Undefined bit #49' attribute.
Attribute value is 0002000000000000. Set fields are:
49 (Undefined bit #49)

Toggle which attribute field (0-63, 64 or <Enter> to exit): 

Expert 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): y

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 83): 83
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/disk1.
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.
Steelhead:~ davidanderson$ 

At this point, I would restart your Mac.

  • What's the purpose of the 'Undefined bit #49' attribute? – klanomath Apr 21 '16 at 16:39
  • @klanomath: I haven't a clue what the bit is for. OS X puts it in the GPT when creating an OS X Recovery partition. I first noticed this when I wrote my readgpt utility. As far as I know, neither diskutil, gpt nor any other OS X Terminal application command has a way to modify the GPT attribute. – David Anderson Apr 21 '16 at 17:44
  • Thank you so much, this did the trick. One note: I made changes to /dev/sda rather than of /dev/disk0 from within Debian. – Eric Andrew Lewis Apr 26 '16 at 0:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .