Macbook Pro (2015) Only Booting From GNU GRUB [duplicate]

I was trying to uninstall linux mint and was trying to restore the partitions back to one. Somehow I ended with the one of the partition labeled FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF.

This are the information from diskutil:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF Macintosh HD            500.4 GB   disk0s2
   3: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF               650.0 MB   disk0s3
   4:                  Apple_HFS extra                   498.9 GB   disk0s4

/dev/disk1 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         24.0 GB    disk1
   1:                        EFI EFI                     314.6 MB   disk1s1
   2:          Apple_CoreStorage Macintosh HD            23.6 GB    disk1s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk1s3

/dev/disk2 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            MacintoshHD            +523.0 GB   disk2
                                 Logical Volume on disk1s2, disk0s2
                                 B6A398E1-B484-4A1A-A590-2FB663DC609A
                                 Unencrypted Fusion Drive


sudo 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   977248144      2  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
   977657784     1269536      3  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
   978927320   974335664      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1953262984      262151         
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header

I ended up restarting and was unable to log in to MacOS. I attempted recovery but ended up installing MacOS on a separate partition. Now the diskutil reads:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF Macintosh HD            500.4 GB   disk0s2
   3: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF               650.0 MB   disk0s3
   4:                  Apple_HFS extra                   498.3 GB   disk0s4
   4:           Apple_Boot Recovery HD                   498.3 GB   disk0s5

/dev/disk1 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         24.0 GB    disk1
   1:                        EFI EFI                     314.6 MB   disk1s1
   2:          Apple_CoreStorage Macintosh HD            23.6 GB    disk1s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk1s3

sudo 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   977248144      2  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
   977657784     1269536      3  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
   978927320   973328272      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC                                                                      
   19552255592   1269536      5  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  1953525128     7         
  1953525135     32              Sec GPT table
  1953525167      1              Sec GPT header

Now it seems that the fusion drive is unlinked. I think I am messing up hard disk big time. I do not know what is going on and I have important data (which I stupidly failed to backup).

Is there any ways to recover the partition, relink the fusion drive and not lose the data within? I really appreciate if anyone can guide me along the way. The other posts pertaining to fusion drives alone and FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF issues that I had read confuses me. Moreover I am worried that I will mess things more.

Please help.

Update: I have followed the detailed instructions by klanomath. Hurray. I have manage to boot in. Now the diskutil reads:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            500.4 GB   disk0s2
   3:                 Apple_Boot                         650.0 MB   disk0s3

/dev/disk1 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         24.0 GB    disk1
   1:                        EFI EFI                     314.6 MB   disk1s1
   2:          Apple_CoreStorage Macintosh HD            23.6 GB    disk1s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk1s3

/dev/disk2 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            MacintoshHD            +523.0 GB   disk2
                                 Logical Volume on disk1s2, disk0s2
                                 B6A398E1-B484-4A1A-A590-2FB663DC609A
                                 Unencrypted Fusion Drive

sudo 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   977248144      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
   977657784     1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
   978927320   974597815               
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header

Also when I boot in, it goes to GNU GRUB version 2.02. I can log in MacOS by holding option/alt when I boot up. The follow up questions are:

  1. Is there a way to clean up the linux installation and not have GRUB appear?

  2. disk0s3 is not necessary for my OS to boot right? It seems like the remains of my linux installation but I am not sure. Is it possible to remove/format it and add it back to the main partition?

  3. Partition 4 (498.9GB) is now missing.

I assume I have to use:

gpt add -i 4 -b 978927320 -s 974597815 -t ????????-0000-11AA-AA11-00306543ECAC disk0

What number do I use?


Solution 1:

The second (and the third) partition of your internal HDD got the wrong partition types, your data probably won't be lost. If one part of a Fusion Drive (i.e. disk0s2) suddenly get a wrong partition type, the "Fusion Drive" is split and dysfunctional.

A bootable OS X partition (except the Recovery HD) either has the GUID 48465300-0000-11AA-AA11-00306543ECAC for a standard OS X partition or the GUID 53746F72-6167-11AA-AA11-00306543ECAC for a CoreStorage partition. The FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF is an unknown partition type (but not no partition like the 000000-0000-0000.... one).

Since your iMac contains a Fusion disk and the remnants of CoreStorage items are visible in the diskutil output (disk1s2 and disk2) it's the latter.

The GUID can be modified with gpt. You can only add, delete and modify GUID partition tables with gpt when all related disks are unmounted. If you have a CoreStorage Logical Volume Group (e.g a Fusion drive or a FileVault volume) the logical volumes get their own (virtual) disk identifiers which have to be unmounted first. An example is your first diskutil listoutput: your logical volume got the disk identifier disk2. To unmount disk1 you have to unmount disk2 first because parts of it reside on disk1 (disk1s2). The other part resides on the defunct disk0 (disk0s2):

/dev/disk2 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            MacintoshHD            +523.0 GB   disk2
                                 Logical Volume on disk1s2, disk0s2
                                 B6A398E1-B484-4A1A-A590-2FB663DC609A
                                 Unencrypted Fusion Drive

To reconfigure your partitions boot to a third party drive (e.g. Internet Recovery or a OS X installer thumb drive).


  • Boot to Internet Recovery Mode
  • Open Terminal in the menubar Utilities > Terminal
  • Get an overview with diskutil list
  • Get an overview of your internal disks with the disk identifier found in the previous command. Below I assume the disk identifier of your internal disks are disk0 (HDD) and disk1 (the small SSD) (replace it with the one you have found in your environment)

    gpt -r show disk0
    gpt -r show disk1
    
  • Unmount disk0 and disk1 with diskutil umountDisk disk0 and diskutil umountDisk disk1
  • Then remove the newly installed OS X and its Recovery HD. I assume you don't have any important data on it.

    gpt remove -i 5 disk0
    diskutil umountDisk disk0
    gpt remove -i 4 disk0
    
  • Then remove and re-add the previous working partitions with the same sizes but proper types:

    diskutil umountDisk disk0
    gpt remove -i 3 disk0
    gpt remove -i 2 disk0
    gpt add -i 3 -b 977657784 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC disk0
    gpt add -i 2 -b 409640 -s 977248144 -t 53746F72-6167-11AA-AA11-00306543ECAC disk0
    
  • In most cases the Logical Volume (MacintoshHD with the UUID B6A398E1-B484-4A1A-A590-2FB663DC609A) will reappear automatically.

    diskutil verifyDisk disk0
    

    You can explicitly mount the Logical Volume by using its lvUUID:

    diskutil mount B6A398E1-B484-4A1A-A590-2FB663DC609A
    
  • Check the Fusion drive with (you have to use either of the disk identifiers of the partitions disk0s2/disk1s2):

    fsck_cs disk1s2
    
  • Enter diskutil cs list to check if the Logical Volume got its own disk identifier and is online (the size and the disk identifier may differ in your environment and the output below is just guessing). It should show something like this:

        ...
        |
        +-> Logical Volume B6A398E1-B484-4A1A-A590-2FB663DC609A
            ---------------------------------------------------
            Disk:                  disk17
            Status:                Online
            Size (Total):          523101572992 B (523 GB)
            Conversion Progress:   -none-
            Revertible:            No
            LV Name:               Macintosh HD
            Volume Name:           MacintoshHD
            Content Hint:          Apple_HFS
    
  • Check the volume with:

    diskutil verifyVolume disk17
    

If you get an error message device diskX is busy while modifying disks with gpt ... simply unmount it with diskutil umountDisk diskX (replace diskX by the proper "busy" disk identifier (e.g. disk3)).


If you want to expand your recovered logical volume (MacintoshHD with ~523 GB) to the full size of your Fusion Drive you can simply resize the whole CoreStorage stack booted to your main system with:

diskutil cs resizeStack lvUUID size

with lvUUID: the UUID of the logical volume which you get by entering diskutil cs list and size: a size in t, g, m, k or b.

In your case that's (depending on your installed system):

diskutil cs resizeStack B6A398E1-B484-4A1A-A590-2FB663DC609A 0g
diskutil cs resizeStack B6A398E1-B484-4A1A-A590-2FB663DC609A 998g

0g is a magic size here which works in 10.7 - 10.10 (sometimes also in 10.11/12). If you get an error "disk too small" use a slightly lower size like 997g or 996g. After removing a BootCamp or a Linux partition the hard way this may fail because internals of the CoreStorage Logical Volume Group got corrupted. Then you have to backup your main volume with e.g. Time Machine, clean-recreate your Fusion Drive from scratch and restore your system with your Time Machine backup.


To remove GRUB you have to remember where you installed it. Usually it's installed to one of the two EFI partitions. You have to mount either of them and check if they contain "uncommon" folders.