13

Yesterday, I have tried to delete an Ubuntu partition. Since, my Mac (13", MBPro mid-2014) doesn't boot. Now, I boot on Mac OS copy with an USB. i follow different subject of this forum (like this : Partition type suddenly FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF, drive unmountable), and my volume partition change from FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF to 48465300-0000-11AA-AA11-00306543ECAC. But I still can't boot to it...

my /dev/disk0

Thank you very much !

6
  • 1
    The proper type of slice 2 of disk0 is probably 53746F72-6167-11AA-AA11-00306543ECAC (CoreStorage) in Sierra or 7C3457EF-0000-11AA-AA11-00306543ECAC (APFS) in High Sierra
    – klanomath
    Nov 14 '17 at 13:44
  • I tried 7C3457EF-0000-11AA-AA11-00306543ECAC, and I can boot ! Thank you so much @klanomath ! Nov 14 '17 at 14:00
  • @grgarside There are better q&a to mark this question as duplicate: Recover data from partition showing as FFFF. The actually linked q&a is related to a ffff.. type partition and an unlinked Fusion Drive. My answer here is based on the proposed duplicate q&a and extended to include APFS partitions. Therefore it may even stand on its own (aka no duplicate at all).
    – klanomath
    Nov 16 '17 at 13:21
  • @klanomath What about MacOS Mojave? (Is 7C3457EF-0000-11AA-AA11-00306543ECAC still applicable for Mojave?) I'm currently experiencing almost the same issue, except it's a MacBook Pro Early 2015, and I'm not experiencing the issue where gpt -r show disk0 produces that output in the screenshot.
    – Edric
    Nov 20 '18 at 3:38
  • Nevermind, 7C3457EF-0000-11AA-AA11-00306543ECAC should work for High Sierra and up. (Already tested it: file verification works!)
    – Edric
    Nov 20 '18 at 4:05
17

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

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. To reconfigure your partitions boot to a third party drive (e.g. Internet Recovery or a OS X installer thumb drive).

Under certain circumstances SIP has to be disabled to modify the GUID partition table.


  • Boot to Internet Recovery Mode (or a third party drive).

  • Open Terminal in the menubar Utilities > Terminal

  • Get an overview with diskutil list

  • Get an overview of your internal disk with the disk identifier found in the previous command. Below I assume the disk identifier of your internal disk is disk0 (SSD) (replace it with the one you have found in your environment).

      gpt -r show disk0
    
  • Unmount disk0 with diskutil umountDisk disk0

  • Then remove and re-add the second partition with the same size but proper type. The most probable type for disk0s2 on an SSD with Sierra currently installed is 53746F72-6167-11AA-AA11-00306543ECAC or with High Sierra installed 7C3457EF-0000-11AA-AA11-00306543ECAC (because a previous CoreStorage partition was almost certainly converted to APFS while upgrading Sierra to High Sierra).

Note: If any of the gpt add commands below generate the error message gpt add: disk0: error: no space available on device, then see this answer for a possible fix.

Sierra (CoreStorage):

    gpt remove -i 2 disk0
    gpt add -i 2 -b 409640 -s 431203056 -t 53746F72-6167-11AA-AA11-00306543ECAC disk0
    

or

High Sierra (APFS):

    gpt remove -i 2 disk0
    gpt add -i 2 -b 409640 -s 431203056 -t 7C3457EF-0000-11AA-AA11-00306543ECAC  disk0

or

standard partition (HFSJ Extended):

    gpt remove -i 2 disk0
    gpt add -i 2 -b 409640 -s 431203056 -t 48465300-0000-11AA-AA11-00306543ECAC  disk0
  • Verify disk and volume:

      diskutil verifyDisk disk0
      diskutil verifyVolume disk0s2
    

Booted to your USB drive and logged in as an admin you have to prepend sudo to execute the gpt commands successfully.


If you forgot your system version or did some custom partitioning you can still inspect the first blocks of disk0s2 and determine the proper GUID type:

If you've booted to a full-fledged system you can use hexdump:

  • Unmount disk0 with diskutil umountDisk disk0

  • hexdump the first 3 blocks of the FFFF... partition:

      sudo dd if=/dev/disk0s2 count=3 | hexdump
    

The following result identfies it as a normal OS X partition:

    0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000400 48 2b 00 04 80 00 21 00 48 46 53 4a 00 00 01 ff
    0000410 d3 8c 77 d3 d4 33 3c b0 00 00 00 00 d3 8c 5b b3
    0000420 00 00 02 a8 00 00 00 25 00 00 10 00 00 fe b7 f6
    0000430 00 fe 1e fa 00 ed 80 00 00 01 00 00 00 01 00 00
    0000440 00 00 10 f2 00 00 5a 9d 00 00 00 00 00 00 00 01
    0000450 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000460 00 00 00 00 00 00 00 00 7d 9d b0 3a 02 31 62 f0
    0000470 00 00 00 00 00 1f e0 00 00 1f e0 00 00 00 01 fe
    0000480 00 00 00 01 00 00 01 fe 00 00 00 00 00 00 00 00
    0000490 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    00004c0 00 00 00 00 00 60 00 00 00 60 00 00 00 00 06 00
    00004d0 00 00 0a 00 00 00 06 00 00 00 00 00 00 00 00 00
    00004e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000510 00 00 00 00 03 10 00 00 03 10 00 00 00 00 31 00
    0000520 00 03 ac 00 00 00 31 00 00 00 00 00 00 00 00 00
    0000530 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000560 00 00 00 00 05 40 00 00 05 40 00 00 00 00 54 00
    0000570 00 00 10 00 00 00 54 00 00 00 00 00 00 00 00 00
    0000580 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000600

The first number is the byte count in hex: 0000000: 0; 0000600: 1536. The * denotes identical lines. This means: the first two blocks (0x000-0x3ff) are all zeros.

A CoreStorage partition shows some non-zeros in the first block (0x000-0x1ff):

    0000000 0c 73 a1 a9 ff ff ff ff 01 00 10 00 07 14 d7 01
    0000010 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000030 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000040 00 20 c1 cc 0f 00 00 00 00 00 00 00 00 00 00 00
    0000050 00 00 00 00 00 00 00 00 43 53 01 00 00 00 04 00
    0000060 00 10 00 00 00 00 40 00 11 bc fc 00 00 00 00 00
    0000070 11 c0 fc 00 00 00 00 00 11 c4 fc 00 00 00 00 00
    0000080 11 c8 fc 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00000a0 00 00 00 00 00 00 00 00 10 00 00 00 02 00 00 00
    00000b0 62 02 98 59 ee a9 ab 51 9b 49 23 90 2e f8 8b 43
    00000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000130 e4 6e f8 f2 63 99 45 c1 b2 13 86 28 a5 18 46 6d
    0000140 c4 51 c0 f6 32 f9 43 ab 8e 59 42 d2 1a ef f6 50
    0000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000400 48 2b 00 04 80 00 21 00 48 46 53 4a 00 00 01 ff
    0000410 d1 98 a4 93 d4 33 8b d5 00 00 00 00 d1 98 88 73
    0000420 00 06 07 53 00 01 82 39 00 00 10 00 00 fb 6a 00
    0000430 00 c5 1c 55 00 25 73 c7 00 01 00 00 00 01 00 00
    0000440 00 0d e2 65 00 3e a2 fb 00 00 00 00 02 20 00 fb
    0000450 00 00 00 31 00 06 b9 ef 00 00 00 00 00 00 00 00
    0000460 00 00 00 00 00 00 00 31 fb 48 1e a0 6c 47 a2 9f
    0000470 00 00 00 00 00 1f e0 00 00 1f e0 00 00 00 01 fe
    0000480 00 00 00 01 00 00 01 fe 00 00 00 00 00 00 00 00
    0000490 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    00004c0 00 00 00 00 00 60 00 00 00 60 00 00 00 00 06 00
    00004d0 00 00 0a 00 00 00 06 00 00 00 00 00 00 00 00 00
    00004e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000510 00 00 00 00 0e 40 00 00 01 30 00 00 00 00 e4 00
    0000520 00 00 10 00 00 00 e4 00 00 00 00 00 00 00 00 00
    0000530 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000560 00 00 00 00 11 d0 00 00 01 30 00 00 00 01 1d 00
    0000570 00 02 80 00 00 00 72 00 00 13 30 97 00 00 13 00
    0000580 00 15 c5 aa 00 00 13 00 00 18 2d 23 00 00 13 00
    0000590 00 19 d8 fb 00 00 13 00 00 1b 76 cb 00 00 13 00
    00005a0 00 1c 34 70 00 00 13 00 00 1d 0e 4d 00 00 13 00
    00005b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    0000600

The line starting with byte 0x130 shows the UUID of the Physical Volume, the line starting with byte 0x140 shows the UUID of the Logical Volume Group.

The string 48 46 53 4a (= "HFSJ") in the first 16 bytes of the third blocks identifies a Journaled HFS+ volume on both partition types.

An APFS container looks like this:

    0000000 e7 ec ab 5b a2 94 96 44 01 00 00 00 00 00 00 00
    0000010 18 0c 00 00 00 00 00 00 01 00 00 80 00 00 00 00
    0000020 4e 58 53 42 00 10 00 00 f6 37 ff 00 00 00 00 00
    0000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000040 02 00 00 00 00 00 00 00 11 f1 5e 40 31 10 4c 20
    0000050 bb 47 53 66 7e 8b 42 d5 b9 c4 00 00 00 00 00 00
    0000060 19 0c 00 00 00 00 00 00 18 01 00 00 18 6c 00 00
    0000070 01 00 00 00 00 00 00 00 19 01 00 00 00 00 00 00
    0000080 21 00 00 00 80 5a 00 00 1f 00 00 00 02 00 00 00
    0000090 7a 5a 00 00 06 00 00 00 00 04 00 00 00 00 00 00
    00000a0 37 fd 03 00 00 00 00 00 01 04 00 00 00 00 00 00
    00000b0 00 00 00 00 64 00 00 00 02 04 00 00 00 00 00 00
    00000c0 06 04 00 00 00 00 00 00 08 04 00 00 00 00 00 00
    00000d0 66 a4 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    00003d0 00 00 00 00 00 00 00 00 16 21 06 00 00 00 00 00
    00003e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *
    00004f0 00 00 00 00 00 00 00 00 91 3d 0f 00 00 00 00 00
    0000500 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000510 78 f4 09 00 00 00 00 00 01 00 00 00 00 00 00 00
    0000520 01 00 04 00 08 00 00 00 00 00 00 00 00 00 00 00
    0000530 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

The string 4e 58 53 42 (= "NXSB") starting with byte 0x020 in the first block is the magic string of an APFS container superblock and identifies it as APFS container. The UUID of the container starts at 0x48 (here: 11 f1 5e 40 ...)

If you are limited to (Internet) Recovery Mode or an installer boot drive (all with a base system only which doesn't contain hexdump) you can still use vis:

  • Unmount disk0 with diskutil umountDisk disk0

  • vis the first 3 blocks of the FFFF... partition:

      dd if=/dev/disk0s2 count=3 | vis -c
    

If you had a standard partition previously the first 1024 Bytes only contain non-printable (zeros): \0\0\0\0\0\0... After ~Byte 1030 you will see the following sequence: \0HFSJ\0

If you had a CoreStorage partition some non-zeros in the first 512 Bytes and the string CS (...\0CS\^A...) are shown:

    \^U\^D\^A\M-s\M^?\M^?\M^?\M^?\^A\0\^P\0\0\0\M-W\^A\a\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\0\M^Pu\M-\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0CS\^A\0\0\0\^D\0\0\^P\0\0\0\0@\0X\M-7}\^C\0\0\0\0X\M-;}\^C\0\0\0\0X\M-?}\^C\0\0\0\0X\M-C}\^C\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\0\0\0\0\^P\0\0\0\^B\0\0\0006j v\^R\M-+\^U\M^[\f\M^CdG\M-y\^]...

If you had a APFS partition the string NXSB (...\0NXSB\0\^P...) is shown in the first few bytes:

    ??[?\M^T\M^VD\^A\0\0\0\0\0\0\0\^X\f\0\0\0\0\0\0\^A\0\0\M^@\0\0\0\0NXSB\0\^P\0\0?7?\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\^Q?^@1\^PL ?GSf~\M^KBչ?\0\0\0\0\0\0\^Y\f\0\0\0\0\0\0\^X\^A\0\0\^Xl\0\0\^A\0\0\0\0\0\0\0\^Y\^A\0\0\0\0\0\0!\0\0\0\M^@Z\0\0\^_\0\0\0\^B\0\0\0zZ\0\0\^F\0\0\0\0\^D\0\0\0\0\0\0007?\^C\0\0\0\0\0\^A\^D\0\0\0\0\0\0\0\0\0\0d\0\0\0\^B\^D\0\0\0\0\0\0\^F\^D\0\0\0\0\0\0\b\^D\0\0\0\0\0\0f?\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\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\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\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\0\0\0\0\0\0\0\0\0\0\0\

 

6
  • I just wanted to refer you to this bounty question in case you hadn't seen it. It refers to your answer here, so thought you may be able to help.
    – Monomeeth
    Apr 18 '18 at 0:10
  • This post helped me fix my problem after partitioning my disk for linux. Thank you so much. I just have a question. I got a lot of warnings during diskutil verifyVolume (xattr ?) but at the end it said it was OK, and it was. Are these warnings normal?
    – user255044
    Apr 20 '18 at 18:04
  • As I review your answers, I wonder why the vis -c output posted by some users is invertible while other output contains many ? characters, which makes the output non-invertible. On my Mac, I have to first enter export LC_CTYPE="ASCII" before using vis -cw or vis -cfw to create invertible output. May 23 '19 at 11:10
  • @DavidAnderson "...output posted by some users is invertible..." Can you link the respective question, answer or comment OR is this a real world problem?
    – klanomath
    May 23 '19 at 11:24
  • This is in regard to this question and this question. In the first question I was able to invert the vis -c output to get the partition size. In the second question, I could not because the output contained question mark (?) characters. This led me to investigate how to get the output to be invertible. May 23 '19 at 11:48
0

Fixing the GPT when Hybrid Partitioning Exists

In the context of klanomath's answer, this answer addresses what to do, when the following message occurs after using the gpt command to add a new partition that also exists in the MBR partition table.

gpt add: disk0: error: no space available on device

The MBR partition table entry can usually be identified from the output of the gpt -r show disk0 command. Below is typical output that would appear when the above message occurs.

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-11D2-BA4B-00A0C93EC93B
     409640  431203056      2  MBR part 255
  431612696   58622023         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

Here, the line containing the MBR indicates the second entry in the MBR partition table defines a partition which occupies the same space that each of the gpt add commands in klanomath's answer is trying to add back into the GPT. The command below can be use to print the MBR partition table.

fdisk /dev/disk0

Typical output is shown below.

Disk: /dev/disk0    geometry: 30515/255/63 [490234752 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE    0   0   2 -   25 127  14 [         1 -     409639] <Unknown ID>
 2: FF   25 127  15 - 1023 254  63 [    409640 -  431203056] Xenix BBT   
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused          

To put the partition entry back into the GPT, implement the following steps.

  1. Save a text copy of the MBR partition table. The command is given below.

    fdisk -d /dev/disk0 > /var/tmp/mbr.txt
    
  2. Remove the partition entry from the MBR partition table. Example commands are given below.

    diskutil unmountdisk disk0
    fdisk -e /dev/disk0
    setpid 2
    0
    quit
    

    A summary of the fdisk interactive commands is given below.

    help        Command help list
    manual      Show entire man page for fdisk
    reinit      Re-initialize loaded MBR (to defaults)
    auto        Auto-partition the disk with a partition style
    setpid      Set the identifier of a given table entry
    disk        Edit current drive stats
    edit        Edit given table entry
    erase       Erase current MBR
    flag        Flag given table entry as bootable
    update      Update machine code in loaded MBR
    select      Select extended partition table entry MBR
    print       Print loaded MBR partition table
    write       Write loaded MBR to disk
    exit        Exit edit of current MBR, without saving changes
    quit        Quit edit of current MBR, saving current changes
    abort       Abort program without saving current changes
    

    Below is sample output.

    diskutil unmountdisk disk0
    Unmount of all volumes on disk0 was successful
    $ fdisk -e /dev/disk0
    fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
    Enter 'help' for information
    fdisk: 1> setpid 2
             Starting       Ending
     #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
    ------------------------------------------------------------------------
     2: FF   25 127  15 - 1023 254  63 [    409640 -  431203056] Xenix BBT   
    Partition id ('0' to disable)  [0 - FF]: [FF] (? for help) 0
    fdisk:*1> quit
    Writing current MBR to disk.
    

     

    Note: The following warning message can be ignored.

    fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory

    The file boot0 is suppose to contain MBR BIOS boot code. Since macOS uses EFI booting instead of legacy BIOS booting, an installation of macOS does not include this file.

  3. Add the partition entry back into the GPT. Basically, execute the same commands to add the partition as determined by klanomath's answer. The commands the OP used are given below.

    diskutil unmountdisk disk0
    gpt add -i 2 -b 409640 -s 431203056 -t 7C3457EF-0000-11AA-AA11-00306543ECAC disk0
    

     

  4. Restore the MBR partition table from the saved text copy. The commands are given below.

    diskutil unmountdisk disk0
    fdisk -r -y /dev/disk0 < /var/tmp/mbr.txt
    

    Below is sample output.

    $ diskutil unmountdisk disk0
    Unmount of all volumes on disk0 was successful
    $ fdisk -r -y /dev/disk0 < /var/tmp/mbr.txt
    fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
    

     

  5. Remove the saved text copy of the MBR partition table. The command is given below.

    rm /var/tmp/mbr.txt
    

 

You must log in to answer this question.

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