Skip navigation

Repairing Boot Camp after creating new partition

179048 Views 1,254 Replies Latest reply: Apr 18, 2014 12:22 PM by Loner T RSS
  • gmtri Level 1 Level 1 (0 points)
    Currently Being Moderated
    Aug 3, 2012 11:08 PM (in response to gmtri)

    Ok, here is the output:

     

    /dev/disk0

       #:                       TYPE NAME                    SIZE       IDENTIFIER

       0:      GUID_partition_scheme                        *500.1 GB   disk0

       1:                        EFI                         209.7 MB   disk0s1

       2:                  Apple_HFS Macintosh HD            180.3 GB   disk0s2

       3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

       4:       Microsoft Basic Data BOOTCAMP                150.2 GB   disk0s4

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Aug 4, 2012 2:49 AM (in response to gmtri)

    Oops, wrong command. That one doesn't show where the free space is located.

     

    sudo gpt -r -vv show disk0

  • gmtri Level 1 Level 1 (0 points)

    Hi - here is what this command shows:

     

    gpt show: disk0: mediasize=500107862016; sectorsize=512; blocks=976773168

    gpt show: disk0: Suspicious MBR at sector 0

    gpt show: disk0: Pri GPT at sector 1

    gpt show: disk0: Sec GPT at sector 976773167

          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  352216120      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC

      352625760    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC

      353895296  329426048        

      683321344  293451776      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7

      976773120         15        

      976773135         32         Sec GPT table

      976773167          1         Sec GPT header

     

     

    Looks like the free space is between disk 3 and 4? Does it provide any clues?

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Aug 4, 2012 10:56 AM (in response to gmtri)

    And the result from

    diskutil resizevolume /dev/disk0s2 limits

  • gmtri Level 1 Level 1 (0 points)

    Unfortunately, this is what I get (current same as max):

     

    For device disk0s2 Macintosh HD:

            Current size:  180.3 GB (180334653440 Bytes)

            Minimum size:  34.5 GB (34458222592 Bytes)

            Maximum size:  180.3 GB (180334653440 Bytes)

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Aug 4, 2012 2:36 PM (in response to gmtri)

    I've never figured out why in some cases the resizevolume command won't use Free Space after the Recovery HD partition, and other times it will.

     

    Your options are:

     

    EASIEST

    Use gdisk to delete the Recovery HD entirely. Then resize disk0s2. Then use gdisk to reorder partitions, create a new hybrid MBR inserting partition 3 (Windows) into MBR, marked bootable, and write out the partitions. You lose Recover HD features, including restore OS feature, and FileVault 2.

     

    EASY

    Make the Free Space either a separate JHFS+ or NTFS volume.


    Use something like gdisk to make a new partition out of the Free Space, using an appropriate partition type code for either NTFS or JHFS+, whichever you've decided to create. This new partition will be indexed as partition 5, even though it will be located between partitions 3 and 4. Gdisk has an option to reindex so that they're in chronological order again, which I would do. Windows will go from partition #4 to partition #5 when you do that. Next, use gdisk to make a new hybrid MBR, and my suggestion is to only add Windows (partition 5), and mark it bootable. After rebooting, you can use Disk Utility to "erase" (i.e. format) it JHFS+/X or you can reboot to Windows and format it as NTFS.

     

    NOT QUITE AS EASY

    Absorb free space into the existing Windows volume.


    Use Gparted to move/resize the NTFS volume forward so it starts where the free space begins, and absorbs all of this free space. So this means giving it to Windows. Once you do this, you'll no longer have a hybrid MBR, and you'll need to go to gdisk to add partition 4 (Windows) to the MBR, and flag it bootable.

     

    MOST DIFFICULT

    Absorb free space into the existing Mac OS volume.


    Use gdisk to add a new partition of identical size that of Recovery HD. In your specific case, you'd make the starting sector 682051808, and length 1269536, and the partition type is Apple Boot. That way it's butted up against the Windows volume, and the end of Free Space. This is on YOUR disk, on any one else's disk the numbers would be different (subtract 1269536 from the start sector for the Windows partition). Then use dd to sector copy the Recovery HD partition to this new partition. Then use gdisk to delete the original Recovery HD partition.

     

    Now you'll have continguous free space right after Mac OS's partition and the resize command should work.

     

    Once this is all done you will need to use gdisk again to resort the partition index so they're in order, and create a new hybrid MBR with Windows partition 4 inserted into the MBR, marked as bootable.

     

    I'm vaguely familiar with iPartition. I don't know if it can do all or some of these things. But it's not free. gdisk is free, you can find it at sourceforge. And dd is included in Mac OS X. I have done all four of these numerous times on two Macbook Pros and it's worked flawlessly, but needless to say it's a bit to chew off.

     

    And this is why I don't use Boot Camp myself. I do all of my non-Mac OS stuff in VM's. Native booting (dual, triple, quad) booting fairly a PITA.

  • gmtri Level 1 Level 1 (0 points)

    Wow - never realised how difficult bootcamp can be. Unfortunately, I did not know that at the beginning. Could have saved a lot of headache  - guess, a learning now!

     

    On the options you describe, I prefer the "easy" option. If I have the space for windows, that's fine as long as all the of the mac features are not lost.

     

    Thinking about this a little further - if I understand this correctly, a root cause of all this issue is that windows don't see the correct partition for booting purpose when anything is done to the partitions on the disk. What if prior to doing any changes to partition, we attempt a change of partition reference in the windows boot file. In other words, in my case,

     

    1. change the partition reference to #5 in the windows boot file (possible ??).

    2. Shut down and boot into Mac

    3. Use disk utility to add a new partition instead of the free space (which is seen as grey area currently in the partition tab).

    4. Format the new partition as mac or windows capable (possible?)

    5. Apply changes, and reboot.

    6. See if windows boots up, and check all ok??

     

    I get a sense your "easy" option does something similar, obviously in a much better way. I just wanted to put my thoughts out there, and see if it made sense at all, purely for my own understanding and learning. Appreciate your thoughts on this very much.

     

    Now, assuming I am prepared to follow the "easy" option, what do I need to do please? I'd go with NTFS format or something that windows and mac can access (fat32 if possible?) Thanks.

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Aug 4, 2012 3:37 PM (in response to gmtri)

    Your particular problem I can't explain. I don't know why you have 170GB of Free Space. It looks like you resized a second time after installing Windows, possibly thinking you were going to give that space to Windows.

     

    The generic problem is that Boot Camp (specifically the CSM-BIOS used to support Windows) effectively depends on the use of two partition schemes, MBR and GPT, called hybrid MBR. You in effect have two partition maps on the disk when using Boot Camp, and this is inherently fragile and prone to confusion because there is no agreed upon standard for creating them and avoiding ambiguity.

     

    I am not going to recommend your number listed recipe because I don't understand it, and haven't tested it even if I can piece it together, and I also have no interest in testing it. In particular I don't trust Disk Utility to add partitions to an existing GPT, other users have already experienced Disk Utility obliterating the hybrid MBR making Windows unbootable, when adding partitions. So you'd have to use gdisk anyway to fix that, so you might as well use gdisk from the outset.

     

    Window's bootloader is fussy, and sometimes it will and sometimes it won't reboot after a partition change. I don't know why. But startup repair always fixed it.

     

    FAT32 is what you need to have read/write access in Mac OS and Windows. Or you need to get (buy, I think) one of the NTFS products from Tuxera or Paragon.

     

    So what you need to do is:

    1. install gdisk

    2. use gdisk to add a new partition, possibly its defaults will find and use the free space automatically, if not you'll have to give it a start sector, and then accept the default size; and give it a partition type code of 0700.

    3. use gdisk to reorder the partition numbers.

    4. use gdisk to create a new hybrid mbr, you'll need to add partition 4 (what will be the new FAT32 volume) and partition 5 (existing Windows partition), and mark 5 as bootable.

    5. write out the new partitions from gdisk (which also automatically quits gdisk).

     

    6. boot windows or mac os, and make sure you choose the correct partition to erase (format) as FAT32. Be really careful with this so that you don't nuke the Windows partition.

     

    Done.

  • gmtri Level 1 Level 1 (0 points)

    Thanks - that makes sense. I have the gdisk already from your earlier advice, so good to go. What commands to use? Having thought about it, I'd like to stick with NTFS as movie media files would be better with that, from what I understand. Also, I may invest in one of the NTFS products later if all goes well too here.

     

    Re. the free space, I have no idea, something to do with the disk utility partition interface from what I can recall.

     

    Thanks again...

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Aug 4, 2012 4:22 PM (in response to gmtri)

    sudo gdisk /dev/disk0 and then you're in interactive mode. Type ? for a list of options and submenus.

     

    Manpage

    About hybrid MBRs.

  • gmtri Level 1 Level 1 (0 points)

    Thanks - I shall have a read, and see how I go. It is a little scary to attempt more changes having come this far to get a working machine, but I think am getting the hang of it or at least parts of the steps you outlined. Shall keep posted on developments. Thanks...

  • lemonsoju Level 1 Level 1 (0 points)

    Firstly let me give a big thanks to Christopher Murphy - his solutioned helped me solve this problem. But it wasn't a complete solution for me because after booting into Windows, I couldn't see the new data partition.

     

    Situation:

    1. Reformat HDD and clean install of Mountain Lion

    2. Bootcamp and install Windows 7

    3. In Mountain Lion, shrink the Mac partition and add a new exFAT partition

    The idea was to have a position that I could share between OS X and W7 that wasn't part of either OS.

     

    To fix it, instead of entering "5", I entered "2 4 5" and then answered the questions as:

     

    Type from one to three GPT partition numbers, separated by spaces, to be

    added to the hybrid MBR, in sequence: 2 4 5

    Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): Y

     

    Creating entry for GPT partition #2 (MBR partition #2)

    Enter an MBR hex code (default AF):

    Set the bootable flag? (Y/N): N

     

    Creating entry for GPT partition #4 (MBR partition #3)

    Enter an MBR hex code (default 07):

    Set the bootable flag? (Y/N): N

     

    Creating entry for GPT partition #5 (MBR partition #4)

    Enter an MBR hex code (default 07):

    Set the bootable flag? (Y/N): Y

     

    Now I windows I can see the Mac OS partition, the Shared partition, and (obviously) the W7 partition.

     

    Here's the complete transcript:

     

    admins-MacBook-Pro:~ admin$ sudo gdisk /dev/disk0

    Password:

    GPT fdisk (gdisk) version 0.8.5

     

    Partition table scan:

      MBR: hybrid

      BSD: not present

      APM: not present

      GPT: present

     

    Found valid GPT with hybrid MBR; using GPT.

     

    Command (? for help): p

    Disk /dev/disk0: 1953525168 sectors, 931.5 GiB

    Logical sector size: 512 bytes

    Disk identifier (GUID): [removed]

    Partition table holds up to 128 entries

    First usable sector is 34, last usable sector is 1953525134

    Partitions will be aligned on 8-sector boundaries

    Total free space is 3021 sectors (1.5 MiB)

     

    Number  Start (sector)    End (sector)  Size       Code  Name

       1              40          409639   200.0 MiB   EF00  EFI System Partition

       2          409640       250409639   119.2 GiB   AF00  HDD

       3       250409640       251679175   619.9 MiB   AB00  Recovery HD

       4       251680768      1837617151   756.2 GiB   0700  SHARED

       5      1837617152      1953523711   55.3 GiB    0700  BOOTCAMP

     

    Command (? for help): h

    b          back up GPT data to a file

    c          change a partition's name

    d          delete a partition

    i          show detailed information on a partition

    l          list known partition types

    n          add a new partition

    o          create a new empty GUID partition table (GPT)

    p          print the partition table

    q          quit without saving changes

    r          recovery and transformation options (experts only)

    s          sort partitions

    t          change a partition's type code

    v          verify disk

    w          write table to disk and exit

    x          extra functionality (experts only)

    ?          print this menu

     

    Command (? for help): r

     

    Recovery/transformation command (? for help): h

     

    WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one,

    just hit the Enter key at the below prompt and your MBR partition table will

    be untouched.

     

    Type from one to three GPT partition numbers, separated by spaces, to be

    added to the hybrid MBR, in sequence: 2 4 5

    Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): Y

     

    Creating entry for GPT partition #2 (MBR partition #2)

    Enter an MBR hex code (default AF):

    Set the bootable flag? (Y/N): N

     

    Creating entry for GPT partition #4 (MBR partition #3)

    Enter an MBR hex code (default 07):

    Set the bootable flag? (Y/N): N

     

    Creating entry for GPT partition #5 (MBR partition #4)

    Enter an MBR hex code (default 07):

    Set the bootable flag? (Y/N): Y

     

    Recovery/transformation command (? for help): o

     

    Disk size is 1953525168 sectors (931.5 GiB)

    MBR disk identifier: 0x2242231D

    MBR partitions:

     

    Number  Boot  Start Sector   End Sector   Status      Code

       1                     1       409639   primary     0xEE

       2                409640    250409639   primary     0xAF

       3             251680768   1837617151   primary     0x07

       4      *     1837617152   1953523711   primary     0x07

     

    Recovery/transformation command (? for help): w

     

    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING

    PARTITIONS!!

     

    Do you want to proceed? (Y/N): Y

    OK; writing new GUID partition table (GPT) to /dev/disk0.

    Warning: The kernel may continue to use old or deleted partitions.

    You should reboot or remove the drive.

    The operation has completed successfully.

    admins-MacBook-Pro:~ admin$

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Aug 5, 2012 2:09 PM (in response to lemonsoju)

    So here's the small problem with adding partitions 2 4 5 to the MBR. You are correct to add partitions 4 5 to the MBR because Windows (booted in BIOS mode) only recognizes MBR on boot disks.

     

    However, by adding partition 2 to the MBR, you leave a small gap in the MBR that tells all MBR aware applications that you have a small 200MB region of free space which is fair game for any app to manipulate. This free space from the MBR's perspective, is actually your Recovery HD partition from the GPT's perspective.

     

    My suggestion is that you redo the hybrid MBR and add partitions 4 5 only. The result is that the GPT, EFI, Mac HD, Recovery HD will all be stuffed in the first MBR entry as 0xEE and will be protected from edits by MBR only aware applications. The Mac OS partition actually does not need to be exposed in the MBR. GPT partitions 4 and 5 will then reside in MBR partition 2 and 3.

  • Christopher Murphy Level 2 Level 2 (470 points)

    Oh and by "redo" I only mean the part in gdisk where you create a new hybrid MBR from the Recovery & Transformation menu.

  • gmtri Level 1 Level 1 (0 points)

    Hi Christopher - Tried to work through the changes on my computer, but no luck yet. Not sure where I am making a mistake, thought I'd check in here. And that's when I see lemonsoju's solution. Actually, I'd be pretty happy with his set up on mine with possibly a change to NTFS shared space for windows (and use the product you listed earlier for Mac access to NTFS)... Reading it a few times, I think it is workable on my end too given I am having no luck yet. Do you think his approach will work on mine? Thanks...

1 2 3 4 5 ... 85 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (21)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.