MacOS: unable to resize partitions after bootcamp failed

bootcampdisk-utilitymacospartition

I tried to install Win10 with Bootcamp on my MacBook Air running MacOS Sierra 10.12.1. Doing so I changed my main partition in order to create the one for Bootcamp. But when running the Windows setup I had to choose the partition onto which to install Windows and always got an error there. So I tried reformatting the Bootcamp partition within the Windows setup, but also failed.

So I decided to stop and remove the Bootcamp partition. But somehow I can not delete nor merge it with the MacOS partition. The disk utility app says I can not remove the partition because the other one (MacOS) can not be resized. FileVault is deactivated.

So what can I do? By the way, the terminal command line diskutil cs or corestorage list does not work:

diskutil cs list
No CoreStorage logical volume groups found

Here's the output from the terminal and from the disk utility app.
disk utility
terminal diskutil

The Bootcamp assistant won't allow me to restart the whole process since it can not resize the main partition and it does not let me choose the second partition as a target. Any idea how to cleanup all partitions?

Best Answer

I somehow managed to do it. First, I reformatted all small hidden partitions from disk0s4 to disk0s8 using this command:

diskutil erasevolume JHFS+ data5 disk0s4

Then I merged all those partitions using this command:

diskutil mergePartitions JHFS+ BOOTCAMP disk0s4 disk0s8

Finally I used the visual disk utility app to remove the newly created BOOTCAMP partition, which then gave all the empty space to my MacOS partition.