gpt add: disk0: error: no space available on device [duplicate]
Solution 1:
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 messagegpt 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-?}\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