MacOS – Partition type for boot drive FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF and more

bootcampmacospartition

I was trying to install Ubuntu onto my MacBook Pro 2011 (Catalina running via Catalina Patcher) which already had Windows 10 with bootcamp. When I tried to run Windows again, I couldn't so I decided to delete Windows 10 and Ubuntu and just keep MacOS. I deleted the partitions but couldn't get the deleted space to combine with the MacOS partition. When I checked the type, it said unknown type. So I rebooted my computer but when it turned on it started flashing the question mark file. I found a previous question that matched my problem so I followed it.

Data Not Backed Up, Partition Type: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF

I got to the step where you do gpt remove then I realized I needed my original numbers to be able to do gpt add. Is there any way I can get my boot, data and settings back?

Partition removed

This is my first time posting, I usually read other questions and the answers a few times over but this time I really messed up. Any and all help is very much appreciated. Thank you in advance.

TLDR: Forgot to note down the size and starting before gpt remove.

output from the commands export LC_CTYPE="ASCII";dd if=/dev/disk1 count=1 skip=409640 | vis -c

enter image description here

After running the gpt command that @David Anderson said below. I was able to boot using an external drive and see my MacOS partition. I restarted and was able to boot into my original drive. The only problem is that there seems to be 187.85GB of memory available rather than the full 240GB.

Edit: I was able to remove the "free space" partition from Disk Utility and now have access to all 240GB.

Thank you so much @David Anderson, you saved 4 years worth of my data and settings.

Best Answer

Note: This answer assumes the missing partition on disk1 was not part of a fusion container.

The answer you posted shows the string NXSB\0\^P\0\0+\M-L\M-;\^B\0\0\0\0. This can be converted to hexadecimal and ASCII values by entering the commands given below.

export LC_CTYPE="ASCII"
echo -nE "NXSB\0\^P\0\0+\M-L\M-;\^B\0\0\0\0" | unvis | hexdump -Cv

The output from this command is given below.

00000000  4e 58 53 42 00 10 00 00  2b cc bb 02 00 00 00 00  |NXSB....+.......|
00000010

The string 2b cc bb 02 00 00 00 00 when byte reversed is the hexadecimal value of 2bbcc2b, which is 45,861,931 in decimal. This means the APFS file system contains 45,861,931 blocks, where a block is 4096 bytes in size. In your case, this can be converted to 512 byte sectors by multiplying by 8. The result is 366,895,448 sectors. In this case, the commands to add the APFS container partition are given below.

diskutil unmountdisk disk1
gpt add -i 2 -b 409640 -s 366895448 -t 7C3457EF-0000-11AA-AA11-00306543ECAC /dev/disk1

Note: If missing partition is part of a fusion container, then the value of 366895448 needs to be reduced by the byte size of the other partition after dividing by 512.