Remove Boot Camp Partitions from a Three Partition Setup

A while back, I split my MacBook Pro hard drive into three partitions so I could have a small FAT32 partition for sharing files between Windows and Mac OS X. After getting a dedicated Vista system, I wanted to delete the extra partitions I created and get all my disk space back. The only problem is that Boot Camp refuses to work on a disk that is partitioned this way, and the command-line tools are complex. I finally got up enough courage to give them a whirl.

This stuff is tricky, and I expected there was a very good chance I’d make a mistake that would force me to restore from backups. If you decide to give this a try, be careful.

I used SuperDuper to clone my Mac hard drive (in case I screwed up big time) onto an external disk drive, booted into the cloned operating system (your Mac OS X install disc should work too), and got a list of gpt partitions:

$ sudo gpt show rdisk0
gpt show: /dev/rdisk0: Suspicious MBR at sector 0
    start      size index  contents
        0         1        MBR
        1         1        Pri GPT header
        2        32        Pri GPT table
       34         6        
       40    409600     1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
   409640 142270944     2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
142680584    262144        
142942728  10485760     3  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
153428488  41680896     4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
195109384    262151        
195371535        32        Sec GPT table
195371567         1        Sec GPT header

To delete the 5GB and 20GB partition, I used this command:

$ sudo gpt remove -i 4 rdisk0
gpt remove: /dev/rdisk0: Suspicious MBR at sector 0
gpt remove: /dev/rdisk0: 1 partition(s) removed

$ sudo gpt remove -i 3 rdisk0
gpt remove: /dev/rdisk0: Suspicious MBR at sector 0
gpt remove: /dev/rdisk0: 1 partition(s) removed

Using the original output of gpt, I calculated the disk space I had to work with (10485760+41680896)/2=26083328K and restored my original bootcamp config:

$ sudo diskutil resizeVolume disk0s2 72842723328B \
  "MS-DOS FAT32" Windows 26083328K
Started resizing on disk disk0s2 Macintosh HD
Verifying
Resizing Volume
Adjusting Partitions
Formatting new partitions
Formatting Disk
100% ..
Finished resizing on disk disk0 

Then I rebooted from my internal hard drive, used Boot Camp Assistant to restore the Mac to a single partition, and it reclaimed all that disk space.

This entry was posted in hacks, mac. Bookmark the permalink.

21 Responses to Remove Boot Camp Partitions from a Three Partition Setup

  1. Mike says:

    Thanks for this article it really helped me. I thought I might clarify a few things that I came across while trying to go through the same process. I’m more familiar with Linux then OSX so there may be better ways to do this then how I’m describing.

    1. I order to run gpt at all I had to reboot OSX with the installation disk (hold down c at startup)

    2. Even when I wanted to run gpt from the terminal from the CD I got the error:
    gpt show: unable to open device ‘/dev/rdisk0′: Resource busy

    to get around this I would boot up the “Disk Utility” after each gpt command. I would have to click on my mac hard drive and “Unmount” it. I don’t know why each time that I ran gpt (including just gpt show) I would have to do this to unmount the hard drive again (that includes between each gpt remove).

    3. After removing the partitions I had to do a bit of math to figure out how you arrived at the Byte value of resizing the disk0s2, however when I did the same things (multiplied the output of gpt show for partition 1 by 512) diskUtil resizeVolume complained that there wasnt’t enough space. To this end I found an easier solution. Once back in ordinary OSX (not the terminal from the install disk) I ran

    sudo diskutil resizeVolume disk0s2 limits

    Now that I have run this the output of is:

    For device disk0s2 Macintosh HD:
    Current size: 119690149888 bytes
    Minimum size: 22949769216 bytes
    Maximum size: 119690149888 bytes

    Before I was able to resize the disk0s2 partition to the current size and resize the Windows MS-DOS partition to the Maximum size minus the “Current Size”. I put these values (ended with B) at the end of your step 3 and continued on.

    Thanks for this writeup I wouldn’t have been able to do this without this article as this seems to be the only writeup on the net that explains how to get rid of those extra partitions.

  2. Bryce says:

    Rather than running Disk Utility after each gpt command you can instead run

    diskutil unmount disk0s2

  3. Embarassed says:

    Thank you for the help. I did get hung up on the last step despite the above. Like the last comment, I booted off the OSX install disk (holding the “c” key on boot after the chime). I have /dev/disk0 instead of /dev/rdisk0 as above. Otherwise things were similar until the final step which kept reporting an error. I’ll also mention, I have a 250GB drive, and when I added the partitions I did 186 + 32 + 32, so I thought maybe the space issue was why there was an error and I went around and around. I made a dumb mistake, but I’ll give a practical example using my own numbers to try and clarify.

    $ diskutil resizeVolume disk0s2 limits
    For device disk0s2 Macintosh HD:
    Current size: 180388626432 bytes
    Minimum size: 126665043968 bytes
    Maximum size: 249715376128 bytes

    When it worked, I did this:

    $ sudo diskutil resizeVolume disk0s2 180388626432B “MS-DOS FAT32″ Windows 69326749696B

    Again the last value is Maximum size minus Current size in Bytes. What was tripping me up was that I kept putting in the Maximum size instead of the Current size just following disk0s2… Nobody really made that clear, and I wanted to mention it in case someone else gets hung up there. It might be a dumb mistake, but if it can help someone else out there I though I should mention it…

  4. Actually,
    I had windows xp instlaled using boot camp on my macbook.
    I reformatted the mac but the windows xp installation partition remained untouched. Then post-mac installation, I could not configure boot camp.
    It was saying it needs a non-partitoned mac extended filesystem.
    So all i did was reboot the macbook using the supplied CDs and reformat the partiton as MSDOS partion. After rebooting the boot camp started working.

  5. Pingback: Un-partitioning - MacNN Forums

  6. its1louder says:

    I had three partitions from fooling around on refit, but when I decided I’d rather use parallels with VM’s then triple boot I had to ditch the extra partitions. This page helped me but I can clean up the proceedure a bit.

    * boot from cd but don’t use installer past language select – pull down a terminal. You will be logged in as root so sudo is unneeded.

    * diskutil unmount disk0s2 -> OSX remounts the mac partition after every step so I had to keep doing this.

    * gpt remove -i 4 disk0

    * diskutil unmount disk0s2

    * gpt remove -i 3 disk0

    * reboot to Harddisk

    * diskutil resizeVolume disk0s2 limits -> note and .

    * diskutil resizeVolume disk0s2 -> doesn’t work for some reason. so try

    * diskutil resizeVolume disk0s2 B DOS FAT32″ Windows B -> don’t forget the B as the units for the two sizes!

    * reboot and use boot camp util to remove the one partition.

  7. Josh says:

    Thanks for the the post. I’ve been looking high and low for details on how to remove a triple boot setup with refit. Instructions worked perfectly!

  8. Alan says:

    Thanks to everyone for the comments here. I had the same problem and this really helped me get it sorted out. I also have an extra piece of advice.

    I was having trouble with the last step also even with my numbers right, but I finally tried repairing the disk first and that solved the problem. So I’d recommend repairing the disk from the DVD-boot Disk Utility before going back into the HD boot and doing the last step.

  9. Rob Craig says:

    Hello all,

    Does the diskutil resizeVolume do a non-destructive resize? Or will I loose data?

    I have a bootcamp Windows XP partition that I need to resize because I’m out of space. Can I use the diskutil to resize this partition without loose my data?
    Thanks,
    Rob

  10. sean says:

    I reinstalled my mac osx on my macbook pro and found out that the windows partition from bootcamp still existed (thought it would remove the partition).

    how can i remove this partition so that i only have one mac partition?

    pls help.

  11. benn says:

    i got the same problem as sean.
    im runnign bootcamp on my powerbook and simply out of space.
    i need to remove bootcamp (only have one partition) but cannot seem to do it.
    i wish they had made it clear when installing that it would be a pain in the ass to remove it!

  12. all2ez says:

    For anyone looking for another solution to this problem, I followed this page and it works without needing the command line stuff:

    http://wiki.onmac.net/index.php/Triple_Boot_via_BootCamp#Restoring_your_Mac_to_its_original_state

    I had 30GB HFS+ Mac partition, 80GB FAT32 data partition, and 32GB NTFS Windows XP partition. I used the partition editor on the Ubuntu live cd to delete the FAT32 and NTFS Partitions.

  13. jeangui111 says:

    I had an issue with the gpt command to remove the Fat32 partition I created after having resized my Mac OS partition.
    The “gpt show disk0″ command gave me “unable to open device ‘disk0′: Resource busy” error.

    What I did to remove the partition is:
    ——————————
    * Boot with Mac OS X install disk by olding the “option” key.
    * Launch “Disk Utilities”
    * Select the 2 partitions under the internal disk (both Mac OS and Fat32 partition)
    * Unmount both of them
    * Quit the Disk Utilities
    * Launch “Terminal”
    * Enter the “gpt show disk0″ command to be sure that my Fat32 partition was partition 3
    * Quit the Terminal

    For an unknow reason, both partitions are automatically mounted back again.

    * Relaunch “Disk Utilities”
    * Select the 2 partitions under the internal disk (both Mac OS and Fat32 partition)
    * Unmount both of them
    * Quit the Disk Utilities
    * Relaunch “Terminal”
    * Enter the “gpt remove -i 3 disk0″ command to remove Fat32 partition
    * Quit the Terminal

    Reboot as usual => That’s it!

    now I’ve got free space, and I can resize my Mac OS partition to its initial size.

  14. Garry van den Berg says:

    Dear Brian,
    I used Bootcamp until I instaled Leopard I deleted the Bootcamp partition and installed everything. I installed Bootcamp 2 and there is 131 GB left of the 250 and I can not install Windows on my iMac. Do you have a solution?
    Thank you very much!!
    ;)
    Best Regards Garry

  15. Designer says:

    Thanks a lot for sharing this with us. Extremely helpful!

  16. Emmanuel says:

    Hello,
    I accidentally formatted my hard drive under Bootcamp as NTFS. I cannot install Windows XP and I can’t install Leopard either (the Disk appears to be only readable).
    I have now 131 Go out of 250 as NTFS and I don’t know what happened to the other 120 (or so) Go. Will these commandes help removing the wrong partition ?
    Thank you for your help !

  17. N00b says:

    I’m sorry if this question seems incredibly n00bish, but bear with me; I’ve only had my new iMac for about a week. Couldn’t you just go into Disk Utility, delete the the Windows partition and the extra 3rd partition, and resize the OSX partition to take up the free space? Or am I missing something important?

  18. n00b says:

    Unless I’m not grasping the goal of this article at all (which I might not be), there is a much easier way to do this. Just fire up Disk Utility, delete the extra 3rd partition, and expand the OSX partition into the free space. Boot camp sees it as a normal harddrive again, and you are home free.

  19. Brian Jepson says:

    Good question, n00b. This is a rather old article (2 years old almost to the day). AFAIK, Disk Utility either didn’t support this, or it didn’t support it reliably.

  20. @Noob:
    Disk Utility does not delete partitions at all (I’m running Mac OS 10.5.6, Leopard). You still have to use gpt in order to delete the partitions. Gpt as a tool is part of the EFI specification; diskutil has no extensions that may use gpt to delete partitions.

    Initially I thought pretty much as you did that Disk Utility would delete the extra partitions but it didn’t; so if you haven’t tried, please be extra careful.

    @Brian Jepson (cc et. al):
    Thanks for posting such a great guide, and thanks to the other people posting extra details about their experiences, this really helped me fixing this problem. I found annoying not being able to delete partitions using diskutil, but being patient, reading carefully and having the OS X installation disc handy really helped get things moving.

    Your guide, even if it’s 2-years old, it is still as valid today as when you originally wrote it. :-)

  21. Curtis Zhao says:

    Ummmm…. Carlos Orozco, can you please tell me where to find the “gpt” software because I am having trouble finding it and it is really bugging me that I cannot delete these two useless hard drive partitions that are sitting on my desktop.

    Plz and thank you

    Curtis Zhao

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>