Tag Archives: Partition Failed to Unmount Disk

Bootcamp Partition Lost Repairing Mac Partitions

Today I changed my Macbook partition sizes and Windows Bootcamp would not show in the Boot menu. Here are the steps I used to fix it. I got these from an Apple forum post.

The 45 page long Apple forum post I used is here: https://discussions.apple.com/thread/4144252?start=0&tstart=0

Warning and disclaimer.  I am in no way responsible for you following these instructions and breaking anything.  Please read them carefully, if there is anything you do not understand or do not know then please STOP!  Although what we are doing is simple, a mistake can lead to big problems that I do not know how to fix.  Read the instructions carefully and consider your options.

How It Started – Macbook Resizing OS X Partition

I had a partition of Macbook OS X Mountain Lion and Windows 7 on Bootcamp.  I needed more space on the Windows side so I decided to use Disk utility on the Macbook to shrink the size of the Mac partition, and use the spare space to make a third partition in exfat format.  Bad idea! because modifying the core Mac partition modifies the MBR (Master boot record), and removes Bootcamp from the startup menu.

Bootcamp still exists in it’s own partition, it’s just that the boot process on the Mac does not know to look there for a bootable thing.

The solution is to fix the Master Boot Record and tell it that it should add the Windows 7 Bootcamp partition to the bootable drives list it has.

Warning 2 – this is simple, but scary.  We will be using terminal and reading things carefully.  If you can not do either of these two then find someone who can.  I will provide full instructions to allow me to repeat this process to fix the partition MBR if it ever happens for me again, so you know it should be good.

How to Fix the Broken Bootcamp Partition after Resizing Mac OS X Partition

First, we need to download some software to handle the partition fixing.  Get gptfdisk from here:

http://sourceforge.net/projects/gptfdisk/

Download the latest version (I used 0.8.6) and because you’re on a Mac you will need the .pkg version.

Once you have downloaded gptfdisk double click the file and install the .pkg file that downloaded.  That’s all the software we’ll be using.  Now it’s just you and terminal.

NOTICE – Now is a good time to plug your Macbook in to charge, you don’t want the power going out while changing the MBR.  Trust me.  Also a great time to BACKUP everything on your Mac and Windows Bootcamp partition.  I just backed up my Mac side because I like to live dangerously and my Windows Bootcamp partition is just for games and testing.

Now back to fixing.

Open terminal.  For a quick shortcut to open it press (CMD + spacebar) to open the spotlight quick search and type terminal.  That will open terminal.  It has >_ as it’s icon.

Let’s see what the state of your MBR is first.  Type these three things.  After each one press enter.  You will need your password for them because we use sudo.  None of the lines change anything on your computer and are used so you can get information about the state of your MBR and partitions.  Type carefully, and that is a vee vee not double you on line 1, and it is disk-numberzero not disk-oh.

  1. sudo gpt -r -vv show disk0
  2. sudo fdisk /dev/disk0
  3. diskutil list

One shows you disk status and partitions.  Two shows you types and three shows you your hard disk partition setup.  Three is the most important.

Output of line 3:

#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *250.1 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS SSD 125.0 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s5
4: Microsoft Basic Data exfat1 24.2 GB disk0s6
5: Microsoft Basic Data BOOTCAMP 100.0 GB disk0s4

IMPORTANT! note down the number on the left of BOOTCAMP when you do line three above!  For me this number was 5.  For you it might be 4.  This is what we will use to tell the MBR it’s a boot drive.

That’s the setup and preparation complete.  Now it’s time to go deep.  Open a new terminal window.  Anywhere that says <enter> means press enter.

Type the following line to start disk:

sudo gdisk /dev/disk0

r <enter>        go to the recovery & transformation menu

h <enter>        create a new hybrid MBR.

STOP! the next line is the most important.  Use whatever your bootcamp partition was above when we did line 3.  My Bootcamp partition on my Mac was 5.  Yours may be 4 or even 3.

5 <enter>        add partion 5 to the MBR.  Your’s may be different! Use what you got from line 3 above.

y <enter> if you are asked “Place EFI GPT (0xEE) partition first in MBR (good for GRUB)?”

<enter>          accept the default MBR hex code of 07

y <enter>        set the bootable flag

n <enter>        do not protect more partitions

o < enter>       print (display) the MBR.

You will see a message telling you it’s go time to actually write the partition.  It will say “Disk size is …” and list two MBR partitions it will make.   This is essentially a notification of what the new MBR will look like.  Look at it and if it looks acceptable then hit w <enter> to write out the table:

w <enter>     Recovery/transformation command (write partition table to disk)

y <enter>  Say yes to question: do you want to proceed.

It will recommend you reboot your Macbook.  Do it and when it’s booting up hold the left ALT/option key like you always do to boot up into Bootcamp.  It should work.

If it did work, great!  Don’t do it again :)  If it didn’t work…try the link at the top to the Apple forum post.  It’s 45 pages long right now so good luck with that but the guy seems very helpful.

Final disclaimer.  This post is for my personal use only and I accept no responsibility for anything you do with it or if anything bad or good happens because you followed the instructions above.  This fix worked for me once and will hopefully work next time I accidentally destroy my Bootcamp partition and stop Windows bootcamp from booting or showing in the startup choice menu when starting my Mac.