1

Preface: I know there are lots of other questions about this on here, but they do not exactly match my situation and/or I do not have the technical knowledge to apply the answers to my situation. Thank you in advance for any help!

I have a Macbook Pro (Late 2011), running High Sierra. I partitioned the harddrive to install Linux. I later uninstalled Linux, and I seemingly did it in a bad way! My main volume now is unbootable, and it does not show up in the startup manager. I'm also not able to boot from Recovery, so to get to the terminal I've booted from a UBS flash drive with a MacOS installer on it.

I followed the steps from answers to similar questions on here, and I got to the step where I remove the volume with the gpt command, but then couldn't get any further. So the main partition doesn't show up on the diskutil list anymore (shown below).

Here is some relevant information from the terminal. For convenience of viewing, I've also included photos of these outputs (below).

[-bash-3.2# diskutil list disk0
/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                         650.0 MB   disk0s3
   3:       Microsoft Basic Data                         74.3 GB    disk0s4

[-bash-3.2# gpt -r show disk0
gpt show: 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-BA4B-00A0C93EC93B
      409640  1318255112      2  MBR part 218 *[no contents because I removed this one]*
  1318664752     1269536      3  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1319934288        1712
  1319936000   145210938      4  GPT part - EBD0A0A2-B9E5-4433-B7C0-6886B72699C7
  1465146938        2197
  1465149135          32         Sec GPT table
  1465149167           1         Sec GPT header

output from diskutil list output from got -r show disk0

The answer at this question has been the most helpful to me so far. However, I do not have an additional mac to do the hex dump that the answer calls for. If needed, I can borrow one from a friend, but I don't own one.

Any help would be greatly appreciated!


Output of the commands export LC_CTYPE="ASCII" and dd if=/dev/disk0s2 bs=1 count=64 | vis -c;echo:

64+0 records in
64+0 records out
64 bytes transferred in 0.377151secs (170 bytes/sec)
\M-6\0\^S\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\^B\0\0\0\0\0\0\0\0\0\0\0\0\0\0
  • If you say you don’t have the skills to understand or apply the existing answers then you should take it to a professional before you make it worse. – Solar Mike Oct 18 at 5:14
  • I appreciate your opinion and your willingness to share advice (and I will take it to a data-recovery specialist if that ends up being necessary). However, it seems to me that some previous askers of this type of question were in a very similar position. I'm hopeful that a kind soul on this forum will be willing to help me out. :) – pwe5000 Oct 18 at 14:55
  • I suppose you have Windows installed? – David Anderson Oct 18 at 16:47
  • I don't actually have Windows installed. I had a Bootcamp Windows installation quite a few years ago, but not anymore. – pwe5000 Oct 18 at 17:14
1

You have hybrid partitioning. The question you have linked to does not. An indicator of hybrid partitioning is the output of the following warning message from the gpt command.

Suspicious MBR at sector 0

When a GUID partitioning is being used, there are two tables. The first is the MBR (Master Boot Record) partition table located at sector 0. This is followed by the GPT (GUID Partition Table) which occupies several sectors. When hybrid partition is being used, one or more entries in the GPT are duplicated in the MBR partition table. The gpt remove command can only remove a duplicate entry from the GPT. This means the other duplicate in the MBR partition table remains. The gpt add command will not add an entry to the GPT, if this entry overlaps an entry in the GPT or the MBR partition table. In your case, the duplicate entry in the MBR partition table was indicated by the following line output from the gpt -r show disk0 command.

     409640 1318255112      2  MBR part 218

Hybrid partitioning is required, if you need to BIOS boot an operating system on an older Macs that has a BIOS. For example, older Macs may need to BIOS boot certain versions of Windows. Below are answers which depend on whether Windows is installed.

Note: Since you will be booting to macOS Recovery from a flash drive, you probably can omit sudo from the commands given below. With older versions of macOS and OS X, the -f option for the gpt command may not be available. If the -f option is omitted, then you may need to enter the command diskutil unmountdisk disk0 before entering the gpt command.

Answer When Windows Is Not Installed

Since you only have macOS installed, you do not need hybrid partitioning. Below are the steps you can take to remove hybrid partitioning from disk0.

Enter the following command to edit the MBR partition table.

sudo fdisk -e /dev/disk0

When using the above command, the following warning messages can be ignored.

fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
Device could not be accessed exclusively.
A reboot will be needed for changes to take effect.

This is an interactive command. Below are the values to enter into this command. A blank line indicates you are to accept the default values by pressing the return key. If you make a mistake, you can press the control+C key combination to exit fdisk without saving any changes.

auto hfs
edit 1
0
edit 1
ee

1

quit
yes

When finish, the sudo fdisk /dev/disk0 should produce the following output

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

After removing the hybrid partitioning, you should be able to enter one of the next three commands to add back in the macOS partition.

Below is the first possible command for adding the macOS partition back into the GPT. If you are using Core Storage, encryption or APFS, then skip this command.

sudo gpt -f add -i 2 -b 409640 -s 1318255112 -t hfs disk0

If you are not using APFS and you are using encryption and/or Core Storage, then you should use command given below.

sudo gpt -f add -i 2 -b 409640 -s 1318255112 -t 53746F72-6167-11AA-AA11-00306543ECAC disk0

If you are using APFS, then you should substitute the command given below.

sudo gpt -f add -i 2 -b 409640 -s 1318255112 -t apfs disk0

Answer When Windows Is Installed

2011 model Macs require Windows to be installed to BIOS boot. This means you need to keep hybrid partitioning. In this case, the instructions below will remove the duplicate entry from the MBR partition table, then add this entry back into both the GPT and MBR partition table.

The command given below removes the duplicate entry from the MBR partition table.

sudo fdisk -e /dev/disk0

This is an interactive command. Below are the values to enter into this command. If you make a mistake, you can press the control+C key combination to exit fdisk without saving any changes.

edit 2
0
quit
yes

You should be able to enter one of the next three commands to add back in the macOS partition.

Below is the first possible command for adding the macOS partition back into the GPT. If you are using Core Storage, encryption or APFS, then skip this command.

sudo gpt -f add -i 2 -b 409640 -s 1318255112 -t hfs disk0

If you are not using APFS and you are using encryption and/or Core Storage, then you should use command given below.

sudo gpt -f add -i 2 -b 409640 -s 1318255112 -t 53746F72-6167-11AA-AA11-00306543ECAC disk0

If you are using APFS, then you should substitute the command given below.

sudo gpt -f add -i 2 -b 409640 -s 1318255112 -t apfs disk0

Below adds the duplicate back into the MBR partition table.

sudo fdisk -e /dev/disk0

The interactive entries for the above command are given below.

edit 2
af
n
409640
1318255112
quit
yes

Fixing the macOS Boot Partition

The partition with an index of 3 has a GPT partition type of 48465300-0000-11AA-AA11-00306543ECAC. This should be 426F6F74-0000-11AA-AA11-00306543ECAC. You need to change this the same way you did for the partition with an index of 2.

The remove command is given below.

sudo gpt -f remove -i 3 disk0

The add command is given below.

sudo gpt -f add -i 3 -b 1318664752 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC disk0

 

| improve this answer | |
  • Thank you! I very much appreciate you taking the time to help me. I followed those steps, and they worked exactly as described. At this point, I have the following: > diskutil verifyDisk disk0 > Volume on disk0s2 has 0 bytes of trailing loader space and it needs 134217728 bytes > Problems were found with the partition map which might prevent booting > Error: -69765: Partition map needs repair because a data partition needs loader space – pwe5000 Oct 18 at 17:07
  • Well, that was not part of your question. However, I should have seen that error. I will have to update my answer in a few hours. I assume you can boot to macOS? – David Anderson Oct 18 at 17:48
  • Sorry about that! And, again, thanks for your help! I'm not currently able to boot to MacOS. When I start up with Startup Manager, the only option is "EFI Boot." I do not have Windows installed. – pwe5000 Oct 18 at 17:55
  • I updated my answer to explain how to fix the boot partition problem. My original answer assumed you are not using encryption or APFS. I change the answer to cover these possibilities. – David Anderson Oct 18 at 21:58
  • Thank you! That did indeed clear up the "loader space" error. I am pretty sure I'm using APFS, so I tried that one, and I received a different error when I ran "diskutil verifyDisk disk0". The drive still does not show up as a boot option. I tried the other two commands you gave above, to be thorough, and they generated the same error. The error is: "Error: -69846: Unrecognized file system". Any idea what might be going wrong? – pwe5000 Oct 18 at 23:09

You must log in to answer this question.

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