MacOS Cannot format to APFS [duplicate]

I am experiencing an identical problem to the one in: Unable to format internal drive as APFS on 2018 MacBook Pro

However this thread in unanswered and unresolved

My internal drive can format to everything except APFS, I have tried troubleshooting via linux, and simple disk utility. Fsck and first aid both report no problems and this is driving me insane!! help desperately needed!


Solution 1:

I do not know if you read my answer to the question you refer to? The command diskutil apfs createcontainer disk0 should have failed. You are suppose to create the container inside a partition (or two partitions where each partition is on a different drive). You specified disk0 which usually is the primary internal drive on a Mac. Maybe you were able to create the container, but being unable to create a volume would not be an unexpected result.

Below are the commands from my other answer.

diskutil eraseDisk JHFS+ dummy GPT disk0
diskutil apfs createContainer disk0s2
Container=$(diskutil info disk0s2 | grep Container)
diskutil apfs addVolume "${Container##* }" APFS myVolume

The first command creates the partitions. The second command create a APFS container in the second partition. The third and fourth commands creates an APFS volume in the APFS container.