Question

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)

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top