How do I delete a BootCamp partition using Terminal's diskutil?

Here's what worked for me:

  1. use diskutil list to find the small Microsoft Reserved partition you're trying to delete but disk utility (or the command-line equivalent diskutil) won't allow. Let's say it's on disk 99 partition 400 (mine was on disk 0 partition 4)
  2. sudo diskutil eraseVolume JHFS+ deleteme /dev/disk99s400

The above reformats the partition to journaled HFS+ and once you've done that you can just simply delete it (and then resize etc. as you wish).

Note: I've used /dev/disk99s400 because that should not ever work, you have to replace those with the right disk and partition.

WARNING: Destructive, high risk. ALWAYS do a full back up first before screwing with partitions. ALWAYS.


Have you tried booting from OSX installation media? Those have both a Terminal (with diskutil) and the GUI Disk Utility, which might start working as you're no longer trying to partition the drive you're booting from.

Caution, from now on: here be dragons! Make sure you understand what's going on before you start on this, you can't back out halfway! Check your backups are readable!

If both versions of diskutil fail here too, stay in the installation media's terminal and get the raw partition table using:

gpt -r show disk0

What has likely happened is that the two partition tables, the GPT and the MBR, have gone out of sync. This happens if you try to partition your Mac disk from Windows. The above shows the GPT version (which OSX uses). This shows the MBR version (which Windows uses):

fdisk /dev/disk0

Make sure this is the disk you want to change (might be disk1, disk2, etc). Note the number (index) of the partition you want to delete in both the GPT and the MBR. They might not be the same!

If confused, post the output from the above 2 here, and don't proceed.

Unmount all mounted partitions on the disk you want to partition, e.g.

diskutil unmount "/Volumes/Macintosh HD"
diskutil unmount "/Volumes/BOOTCAMP"

Then comes the dangerous bit (make sure you have backups): Delete the partition using the gpt utility:

gpt remove -i 4 disk0

Make sure to substitute the index of the partition to delete (IN THE GPT) instead of "4" and the exact disk you're partitioning instead of "disk0"!

Finally, you'll need to delete the same partition from the MBR (you may need to unmount again at this point).

Option 1: Remove all trace of bootcamp (only boot OSX on this disk)

If you want to completely remove any trace of Boot Camp (no OSes other than Mac OS X) you can completely destroy the MBR partition table and replace it with a so-called "protective MBR":

fdisk -e /dev/disk0

This lands you at the fdisk command line - the parts in bold are what you type.

fdisk: 1>p

This will show your partition table, same as earlier. You want to replace it with a single protective partition of type EE, covering the whole disk.

fdisk: 1>erase

fdisk:*1>edit 1

Partition id ('0' to disable) [0 - FF]: [0] (? for help)EE

Do you wish to edit in CHS mode? [n]n

Partition offset [0 - 505856]: [63]1

Partition size [1 - 505855]: [505855] (just press enter here to go with the default - the exact number will depend on your disk size)

fdisk: 1>p

This should now show a partition table with the first entry of type EE, and the remaining 3 entries blank.

fdisk: 1>w

Writes your changes to disk. You'll need to quit out of fdisk with

fdisk: 1>q

Next: reboot and pray.

Option 2: Remove only the affected partition (go from triple boot to dual boot or so)

If you want to keep the hybrid MBR, just not the one partition, begin editing the MBR like so:

fdisk -e /dev/disk0

This lands you at the fdisk command line - the parts in bold are what you type.

fdisk: 1>p

This will show your partition table, same as earlier.

Find the entry that corresponds to the partition you're deleting, e.g. 4, then edit that entry (replace "4" with your entry):

fdisk:*1>edit 4

Partition id ('0' to disable) [0 - FF]: [7] (? for help)0

Partition 4 is disabled.

fdisk: 1>p

This should now show a partition table with the deleted partition missing.

fdisk: 1>w

Writes your changes to disk. You'll need to quit out of fdisk with

fdisk: 1>q

Next: reboot and pray.


The answer is to boot off the recovery HD partition, use disk until and select the Bootcamp partition. Then on the erase tab select the format and change it to Mac OS Extended journaled. Now you can erase the drive.


I am not certain we have the exact situation, but through following/translating advice on another thread, http://apple.stackexchange.com/questions/145292/i-deleted-my-bootcamp-partition-but-cant-resize-my-os-x-partition I was able to restore functionality to Bootcamp Assistant. I lack the "reputation points" to comment there, but wanted to pass on that this worked for me. My system/hardware specifications are as follows:
MacBook Pro (Retina, 13-inch, Early 2015)

OSX Yosemite: 10.10.5 (14F1605) Processor: 2.7 GHz Intel Core i5 Memory: 8 GB 1867 MHz DDR3 Graphics: Intel Iris Graphics 6100 1536 MB

My specific information:
I, unfortunately, followed errant advice from apple support, and followed instructions by phone support to enter Disc Utility and erased my BOOTCAMP partition and set the format to OS X Extended (Journaled). Following this action, Windows was erased, several megabytes of "other" remained, and my partition was still in place, with 98 GB of inaccessible storage.
This was how I created the same situation as you seem to be describing. As a result, my Disc Utility no longer responded to efforts to modify my partition, and my Bootcamp assistant now had a greyed out tab which, if I had been directed to it initially, would have erased the windows partition AND Restored a single drive.
Note that bootcamp began as part of a single drive, this is important. I have no idea if this solution will work for bootcamp set-ups on separate drives. My problem went to a supervisor, and after two weeks I have had no response from Apple support, so I researched online and found what worked!

SOLUTION: As advised on the thread, I ran Disc Utility again. Two members suggested setting the format to something other than OS X Extended Journaled. Re-erasing and formatting was the only option Disc Utilities provided.
One comment from user102419 suggested erasing and formatting to "microsoft FAT".
A second, more detailed answer from http://apple.stackexchange.com/users/5472/bmike suggested a similar quick fix, but specified formatting to MS DOS to trick the computer into believing Windows was still installed within the partition.
End result, this worked for me, but the terminology used for the drop-down menu in Yosemite was "DOS FAT".
Erasing and formatting the partition in DOS FAT resulted immediately in a return to functionality of the Bootcamp Assistant choice to add or remove Windows. I happily made the choice, pushed continue and was given the option to RESTORE my drive to a single 248 GB OS X.

The process took about 5-7 minutes...which is a long time when you are worrying you may have messed it up..... but, voila, 249.78 GB of available space on my Macintosh Hard Drive. No need to enter internet recovery mode, no need to erase the entire system and reboot from Time Machine.
I did back up everything before trying..just in case.

I hope this answer is helpful for you, and for others trying to reclaim space from a windows Bootcamp partition after following advice to erase windows through the Disc Utility.