I have an iMac 5K 2017 running MacOS Big Sur and Windows 10 and the problem is a little bit tricky:

After I resized my Bootcamp with AOMEI Partition Assistance and restarted it, it couldn't run MacOS(it showed prohibitory sign) and needed to be recovered. In Disk Utility on Recovery Mode, the Fusion Drive had been separated into HDD and SSD. Except Bootcamp partition, the other partitions are gone and cannot be erased or splited.

Therefore I restarted to Windows and tried to fix it with gdisk, but I accidentally changed the partition ID on wrong disk(I changed Bootcamp partition ID into APFS as shown in fig.1)

fig.1 Weird partitions

fig.1 Weird partitions

Now I am not albe to boot both systems, only Recovery Mode. I am trying to change APFS back to Microsoft Basic Data of the Bootcamp partition on Terminal in it, but it always shows "command not found."REF1 REF2

Is there any way to fix it? Because I didn't backup my Windows(Mac is OK to be erased)

  • To chime in about the "weird partitions" in recovery mode, I believe those are your ramdisks that are loaded at boot. I dont know mych else about them though.
    – DanRan
    Commented Dec 17, 2020 at 4:18
  • I have no idea either, but when the second time I reboot and run the command again, they were strangely gone.
    – FROD Yeh
    Commented Dec 22, 2020 at 1:49

1 Answer 1


The commands given in this answer should be entered while booted to macOS Recovery. Older versions of macOS (OS X) may require booting macOS Recovery from the Internet or a macOS installation USB flash drive. Also, some commands may need to be preceded by a sudo. The instructions given below will probably fail when hybrid partitioning is being used.

The command provided by macOS to change a partition type GUID is gpt. However, this command works differently from gdisk in that gdisk is interactive and gpt is not. Also, the gpt command requires removal of the partition from the GPT in order to change the partition type GUID. Once removed, the partition can be added back to the GPT with the correct partition type GUID. This removal and addition does not alter the contents of the partition.

The command below can be used to partially view the current contents of the GPT for the drive with the identifier disk0.

gpt -r show /dev/disk0

The commands below can be used to remove from the GPT the partition with the identifier disk0s2.

diskutil unmountdisk disk0
gpt remove -i 2 /dev/disk0

The commands below can be used to add to the GPT the previously removed partition. This partition will be given the Windows GUID type. Replace <start> and <size> with the integer values shown in the output of the command gpt -r show /dev/disk0 for the row with an index of 2.

diskutil unmountdisk disk0
gpt add -i 2 -b <start> -s <size> -t windows /dev/disk0

Note: The integers used in identifiers do not have to match the index values used by the GPT and gpt command. In this case, the 2 used in disk0s2 probably refers to the partition with index value of 2 in the GPT.

  • It worked! Thank you for your answer, it's very helpful. Why couldn't I find out gpt command tho... it must be because I googled in the wrong direction.
    – FROD Yeh
    Commented Dec 22, 2020 at 1:47
  • @David_Anderson, there is minimal documentation in the man pages about the got comman In addition, there are very few forum discussions anywhere in internet history about the got command, most likely because people default to using gdisk instead
    – DanRan
    Commented Dec 22, 2020 at 11:47

You must log in to answer this question.

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