1

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
  • How did the OP manage to enter the command sudo fdisk /dev/disk0 without getting the message fdisk: /dev/disk0: Operation not permitted? Either SIP is off or the computer is already booted to macOS Recovery. If so, then why not just use the gpt command to fix the problem? – David Anderson Jan 29 at 21:13
  • No particular reason other that the strange feeling that I did something wrong because the partition disk0s2 isn't labelled as it normally should be @klanomath . Do you believe that I can safely reboot my system even though the linux partitions are yet to rejoin the much larger disk0s2 – Artorius Castus Jan 29 at 21:18
  • Yes, SIP is disabled. @DavidAnderson , but what gpt command are you referring to? I tried to have to deleted space rejoin the original disk0s2 but to no avail and that has me on edge a bit. – Artorius Castus Jan 29 at 21:20
  • 1
    Please do not post graphic images of Terminal output! Simply copy and paste the output and use code formatting so it displays properly. – user3439894 Jan 29 at 21:44
  • 1
    @ArtoriusCastus You just have to c&p the Terminal window's content and hit {} in the edit window. The problem with screenshots: you can't copy text from it and have to type it instead. If I mistype the size of disk0s2 (1796865488), an answer containing the wrong size wouldn't work. c&p the size (or other data) from your question is faster, more convenient and less error-prone for a person submitting an answer. – klanomath Jan 29 at 21:54
2

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
| improve this answer | |
  • @ArtoriusCastus: Well so much go getting it right the first time. I made a mistake. You entered af00 and you should have entered af0a. Sorry, you will have to do it again. – David Anderson Jan 29 at 22:11
  • no big deal @DavidAnderson it was my fault for not c&p(ing) to begin with. – Artorius Castus Jan 29 at 22:12
  • @DavidAnderson yes, the af0a made the difference. Using sudo diskutil apfs resizeContainer disk0s2 0 does allow the deleted linux partition to rejoin the larger disk0s2. All without the need to restart my computer. But I will still test the recovery mode method regardless of this successful result – Artorius Castus Jan 29 at 22:15
  • I appreciate you both walking on tightrope with me, @klanomath and David Anderson – Artorius Castus Jan 29 at 22:18
  • The gpt command was not needed in my case, after using gdisk and changing af00 to af0a and verifying the whole thing. The command sudo diskutil apfs resizeContainer disk0s2 0 immediately works and my drive was properly resized. Restarting was not an issue – Artorius Castus Jan 29 at 22:24

You must log in to answer this question.

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