Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

For some reason, the BootCamp Assistant app won't let me delete my BootCamp partition. How can I do so using Terminal and the diskutil terminal app?

share|improve this question
    
Have you tried Disk Utility in the Applications folder? –  Vickash Jun 28 '12 at 21:38
    
It was the second thing I tried; all the partition controls are greyed out. –  Jules Mazur Jun 29 '12 at 0:46
    
Did you customize the partitions after installing BootCamp? This discussion may provide some useful information: discussions.apple.com/thread/3698348. The executive summary is that if you've got more than two OS partitions, you may need to backup your OS X partition and reformat the drive (or at least delete the existing partitions), and then restore your OS X partition. –  Chris Page Jun 29 '12 at 12:24
    
No I didn't customize the partitions. After setting up BootCamp, I lost all control of partitions via Disk Utility. Can't resize, delete, or add partitions. –  Jules Mazur Jun 29 '12 at 14:23
    
I don't know if DU is supposed to do that, but I wouldn't be surprised if it's on purpose, to prevent you from getting into the situation described in that discussion I linked to. Why BootCamp won't let you uninstall is a mystery. You might try calling 1-800-SOS-APPLE for support. –  Chris Page Jun 29 '12 at 20:42
show 5 more comments

3 Answers 3

up vote 3 down vote accepted

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.

share|improve this answer
1  
As noted, this won't work if you're booted into normal OS X (you can't edit a drive you're using). iMacs have a major hardware defect where the DVD drive often breaks after only a few uses, so ... I couldn't boot from the official DVD. Obviously the Recovery Partition was no good either - but downloading Apple's "USB Recovery Disk creator" app, and booting from that, did the trick -- support.apple.com/downloads/DL1433/en_US/RecoveryDiskAssistant.dmg –  Adam Jan 25 '13 at 12:27
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.