MacOS – How to properly remove Linux and resize the partition if it’s showing FFFFFFFFFFFF-FFFFF-FFFFF without turning off the Macbook

command linedisk-utilitymacospartitionunix

Having deleted both linux partitions from my device using

sudo diskutil eraseVolume free none disk0s4

and

sudo diskutil eraseVolume free none disk0s3
In an attempt to then have both partitions rejoin the larger one i used

sudo diskutil apfs resizeContainer disk0s2 0

but it was unsuccessful to my chagrin.

enter image description here

I checked my with diskutil list

and now I have a shady FFFF-FFFF-FFFF partition instead of the normal disk0s2.

enter image description here

How can I revert the partition to its normal state and resize the partition without turning off my macbook and messing up the entire thing.

This is on macOS catalina 10.15.2

I have also an image of sudo fdisk /dev/disk0

enter image description here

Any help would be greatly appreciated besides saying just use a time machine.

gpt -r show /dev/disk0

enter image description here

EDIT

After implementing David Anderson's solution the end result was this

enter image description here

Which seems to have restored the partition to it's normal state.

Both of David Anderson's solutions work

MacBook-Pro ~ % sudo gpt -f remove -i 2 disk0 
Password:
disk0s2 removed
MacBook-Pro ~ % sudo gpt -f add -i 2 -b 409640 -s 1796865488 -t apfs disk0
disk0s2 added

Best Answer

Download and install gdisk.

After downloading, you can remove the quarantine by entering the following command.

xattr -d com.apple.quarantine ~/Downloads/gdisk-1.0.4.pkg

Enter the commands given below.

sudo gdisk /dev/disk0
t
2
af0a
w
y

You can also use the gpt command, but gdisk has the advantage of being atomic. In other words, no changes are made to the GPT until you enter the y command.

If you want to try using the gpt command without first booting to macOS Recovery, then here are the commands. I warn you this might cause the computer to hang.

sudo -f gpt remove -i 2 disk0
sudo -f gpt add -i 2 -b 409640 -s 1796865488 -t apfs disk0
Related Question