9

I have encountered a nearly identical issue to the one in this question (and this too: Data Not Backed Up, Partition Type: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF), but my hard drive's main partition is formatted in APFS. When I tried correcting the GUID error as shown in the answer, after reaching the step in which the following command: gpt add -i 2 -b 409640 -s 372637568 -t APFS /disk0 had to be entered, it returned an error: usage: gpt add [-b lba] [-i index] [-s lba] [-t uuid] device ....

screen shot of the previous configuration

I cannot boot into macOS, my computer is in internet recovery environment. What's the uuid of the new APFS format? I cannot seem to find it anywhere in the web, and my computer isn't detecting the type of the main macOS partition. My computer's model: MacBook Pro late 2013. My data is not backed up and I would really love to recover it. Update: gpt -r show disk0:

screen shot of the previous configuration

Update: I created a MacOS High Sierra Installation disk, and rebooted to it. The new disk utility does not recognize the disk0s2 partition at all, and diskutil list included the size of the main osx partition in GUID_partition_scheme part of the disk. Would it be possible (and how) to recover the data of the deleted partition (s2) if I reinstalled macOS on an existing unused partition (the Linux partition disk0s4)? disk utility diskutil list gpt -r show disk0

4
  • try with ... -t 7C3457EF-0000-11AA-AA11-00306543ECAC ... instead of ... -t apfs ...! Maybe your recovery boot system is too old and gpt doesn't recognize the apfs argument. AFAIK only 10.12 and 10.13 recovery system's gpt binary can deal with ... - t apfs ....
    – klanomath
    Commented Dec 3, 2017 at 18:04
  • @klanomath it returned an error: gpt add: /dev/disk0: Suspicious MBR at sector 0 and gpt add: /dev/disk0: error: no space available on device Commented Dec 3, 2017 at 18:20
  • Please update the gpt -r show disk0 output to check what replaced partition 2!
    – klanomath
    Commented Dec 3, 2017 at 18:25
  • 1
    @marklark Taking screenshots works neither in the legacy recovery mode, nor the Internet Recovery which I was stuck in Commented Mar 5, 2019 at 16:14

1 Answer 1

14

The proper GUID of APFS partitions is 7C3457EF-0000-11AA-AA11-00306543ECAC.

The default pMBR was replaced with an old-style MBR, probably by the Linux installation!

Your boot system (in Internet Recovery Mode) seems pretty old. Any disk or partition verification executed with diskutil may yield some bogus result. In no case try to repair anything with diskutil!


To get your APFS partition back remove partition disk0s2 and restore it with the proper type:

  • Open in the menubar > Utilities > Terminal
  • get some details:

    diskutil list #below I assume the disk identifier of the internal disk is disk0
    gpt -r show disk0
    
  • Unmount disk0:

    diskutil umountDisk disk0
    
  • remove and restore the 2nd partition:

    gpt remove -i 2 disk0
    diskutil umountDisk disk0
    gpt add -i 2 -b 409640 -s 372637568 -t 7C3457EF-0000-11AA-AA11-00306543ECAC disk0
    
  • verify disk and partition:

    diskutil list
    diskutil verifyDisk disk0       
    diskutil verifyVolume disk0s2
    

Your Mac should be able to boot despite the MBR.

If you want (or have) to restore the pMBR because the MBR is stubborn/blocks the modification of the partition table do the following:

  • get all disk details:

    diskutil list #below I assume the disk identifier of the internal disk is disk0
    gpt -r show disk0
    
  • replace the GUID partition table:

    diskutil umountDisk disk0
    gpt destroy disk0
    gpt create -f disk0
    
  • re-add all previous partitions visible in the last gpt -r show disk0 output:

    gpt add -i 1 -b 40 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B disk0
    gpt add -i 2 -b 409640 -s 372637568 -t 7C3457EF-0000-11AA-AA11-00306543ECAC disk0
    gpt add -i 3 -b 373047208 -s 262144 -t 426F6F74-0000-11AA-AA11-00306543ECAC disk0
    gpt add -i 4 ...
    gpt add -i 5 ...
    

    If you get a resource busy error after one of the steps, just unmount disk0 again with

    diskutil umountDisk /dev/disk0
    
  • Finally verify disk and partitions:

    diskutil list
    diskutil verifyDisk disk0       
    diskutil verifyVolume disk0s1
    diskutil verifyVolume disk0s2
    diskutil verifyVolume disk0s3
    #disk0s4 & disk0s5 can't be verified with the default macOS tools because the latter is a Linux swap and the former a Linux partition, probably with ext4
    

     

7
  • I cannot remove the disk0s2, as the command gpt remove -i 2 disk0 throws an error: gpt remove: disk0: Suspicious MBR at sector 0. Similarly, the command gpt add -i 2 -b 409640 -s 372637568 -t 7C34[and so forth] returns gpt add: disk0: Suspicious MBR at sector 0 and gpt add: disk0: error: no space available on device. I have added new screen shots to my question for reference. Commented Dec 4, 2017 at 17:05
  • Thank you for your help! The second part of your answer fixed everything and my Mac booted as if nothing had happened! Commented Dec 4, 2017 at 17:33
  • 2
    @GintsK and klanomath : you two saved me 3 months of work. My deepest gratitude for documenting clearly this tricky issue.
    – Yoric
    Commented Oct 20, 2018 at 15:23
  • gpt add: disk0: error: no space available on device is also caused by providing a wrong block number with gpt add -b. For more informations how gpt works please refere to this man page Commented May 23, 2020 at 12:23
  • because my recovery partition was on the same disk as my broken partition, I was unable to unmount disk0, so I got a bootable usb stick with gparted on it, but really any linux distro would work - then used gdisk to change the partition type flag. Pretty sure the options are t to change type, then choose partition number, then search for type apfs and then w to write changes. It will warn about overwriting data but its just the table not the disk so it should be okay. I then rebooted holding option and my drive came up.
    – FredoAF
    Commented Oct 8, 2020 at 9:30

You must log in to answer this question.

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