Skip navigation

Repairing Boot Camp after creating new partition

177107 Views 1,254 Replies Latest reply: Apr 18, 2014 12:22 PM by Loner T RSS
  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Nov 10, 2012 1:28 AM (in response to Kazxn)

    Sorry if you need a simpler explanation it's start over with a reformat, and restore from backup.

  • Marionumber1 Calculating status...

    I'm running Mac OS X Lion and Windows 7 x64. I installed Windows 7 a few weeks ago, and it's working great. All the Bootcamp drivers are working, and I moved all of my Windows data from my old PC to my Bootcamp installation. However, I also want to install Ubuntu.

     

     

    I need to create a new partition to install Ubuntu, which I'm going to do by shrinking my Mac OS X partition and creating a partition in Disk Utility. But as I saw in this thread, this breaks the hybrid MBR. I know that I can use gdisk to recreate the hybrid MBR, but first I have a few questions.

     

     

    First, I want my Windows 7, Mac OS X Lion, and Ubuntu partitions to be in the hybrid MBR. My expected GPT disk layout is as follows:

     

    disk0s1: EFI System Partition

    disk0s2: Mac OS X Lion

    disk0s3: Lion Recovery Partition

    disk0s4: Windows 7

    disk0s5: Ubuntu

     

    And my expected MBR layout is this:

     

    1. EFI Protective Partition

    2. Windows 7

    3. Mac OS X Lion

    4. Ubuntu

     

    What command will I need to run in gdisk to accomplish this?

     

    Second, where will GRUB2 be installed? I heard somewhere that GRUB2 installs its code in the EFI Protective Partition. If I install GRUB2 on the boot sector of the Ubuntu partition, will its code be installed in the EFI Protective Partition as well?

     

    Third, in case this goes wrong, is there a way to clone my entire hard drive and restore it if something goes wrong?

  • Marionumber1 Level 1 Level 1 (0 points)

    EDIT: It seems that GRUB2 actually installs code on the BIOS Boot Partition. And that only happens on BIOS systems. I guess that my memory was a bit off.

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Nov 13, 2012 10:51 PM (in response to Marionumber1)

    I want my Windows 7, Mac OS X Lion, and Ubuntu partitions to be in the hybrid MBR.

     

    This leaves important areas of the disk unprotected.

     

    What command will I need to run in gdisk to accomplish this?

     

    The layout is not ideal. You should have Windows 7 last so that all you add to the MBR is the Windows partition, since that's the only OS that needs MBR.

     

    Second, where will GRUB2 be installed?

     

    In two pieces, first 440 bytes of LBA 0, which will squish the Microsoft BIOS bootloader currently there. The second is core.img and needs to go into its own partition.

     

    I heard somewhere that GRUB2 installs its code in the EFI Protective Partition.

     

    It will not do this because when booting Windows 7 on Apple hardware via Boot Camp, it uses a BIOS-CSM which means GRUB2 core.img needs to go on a BIOS Boot partition.

     

    If I install GRUB2 on the boot sector of the Ubuntu partition, will its code be installed in the EFI Protective Partition as well?

     

    No. And there is no boot sector for Ubuntu's partition using ext[234] because that boot sector is too small (512 bytes) to accept GRUB2's core.img which is usually around 26KB. On MBR disks that normally goes in the MBR gap, but there isn't such a thing on a Mac because the GPT starts where the MBR gap normally is.

  • Marionumber1 Level 1 Level 1 (0 points)

    I actually need the Mac OS X partition in the MBR so I can get files off of it from Windows. But Ubuntu can be on a GPT partition, right? Also, if GRUB2 can't install on an ext2, ext3, or ext4 partition, will I also need to make a FAT32 partition to install GRUB2 on?

  • Tom Carlson Calculating status...

    Hello Christopher,

     

    Thank you for the great service you are doing for all of us with this problem.

     

    I hope mine is a simple question. I added a Snow Leopard Boot partition to what had previously been a 2 partition physical drive. Of course, I then lost access to my Bootcamp drive. I really don't need that Snow Leopard Boot to be on this same physical drive: I have all four expansion drive bays on my mid 2010 Mac Pro filled with 2 TB drives, so can partition one of those and delete the Snow Leopard Boot partition off of the drive with Boot Camp. That will leave just two (visible) partitions on the original main physical boot drive--a Mountain Lion Boot partition and the Boot Camp partition. Should this work to restore my accessability to Boot Camp? Should all of my data still be intact?

     

    Thanks in advance! (I won't touch anything until I hear back here.)

     

    Tom Carlson

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Nov 14, 2012 11:43 PM (in response to Marionumber1)

    There is no particularly safe way to do what you want without rearranging the partitions - by safe I mean, ensuring that only OS X and Windows are exposed in the MBR, and everything else is in the 0xEE protective partition of the MBR. However functionally the hybrid MBR you proposed will work.

     

    You do not need to make a FAT32 partition for GRUB, you make a 1MB "BIOS Boot" partition, gdisk type code for this is EF02. It does not need to be formatted, grub-install will automatically find this partition and write core.img to it.

  • Marionumber1 Level 1 Level 1 (0 points)

    So the BIOS Boot Partition can be outside of the hybrid MBR? Also, what are some of the possible things that could happen if I added my Windows and Mac partition to the hybrid MBR? My hybrid MBR was already set up like this by Bootcamp.

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Nov 18, 2012 11:36 AM (in response to Marionumber1)

    BIOS Boot is unique to GPT, you wouldn't have an entry for it in the MBR as there isn't even a proper type code available for it.

  • Marionumber1 Level 1 Level 1 (0 points)

    So my expected GPT disk layout is this?

     

    disk0s1: EFI System Partition

    disk0s2: Mac OS X Lion

    disk0s3: Lion Recovery Partition

    disk0s4: Windows 7

    disk0s5: BIOS Boot Partition

    disk0s6: Ubuntu

    disk0s7: Swap

     

    And my expected MBR layout is this?

     

    1. EFI Protective Partition

    2. Windows 7

     

    My only other question is what will happen if I do put both the Windows and Mac OS X partitions in the MBR?

  • Christopher Murphy Level 2 Level 2 (470 points)
    Currently Being Moderated
    Nov 18, 2012 12:13 PM (in response to Marionumber1)

    That layout isn't ideal for hybrid MBR because the #1 MBR entry, 0xEE, to protect partitions you don't want exposed to MBR aware applications, can only include sectors for s1, s2 and s3. Then MBR #2 exposes s4 for Windows. So now what? How do you protect s5, s6, s7 with only two MBR entries left? Well you can't.

     

    So Windows should be s7. And if you want to read OS X you'd make it s6. That way you protect GPT partitions s1 through s5 as a single 0xEE entry, and then add s6 OS X to MBR #2. And add s7 Windows to MBR 3. That way all sectors have assignment in the MBR.

     

    Sectors not assigned to something in the MBR appear as free space to applications that only understand MBR, which obviously is risking data on those sectors. So you just have to be really aware of what your tools do if you're not going to do this conservatively.

  • Marionumber1 Level 1 Level 1 (0 points)

    So my expected GPT disk layout is this?

     

    disk0s1: EFI System Partition

    disk0s2: Lion Recovery Partition

    disk0s3: BIOS Boot Partition

    disk0s4: Ubuntu

    disk0s5: Swap

    disk0s6: Mac OS X Lion

    disk0s7: Windows 7

     

    And my expected MBR layout is this?

     

    1. EFI Protective Partition

    2. Mac OS X

    3. Windows 7

     

    Is it possible to change my partitions like this in Disk Utility?

  • Christopher Murphy Level 2 Level 2 (470 points)

    That's ideal. But Apple doesn't let you choose where Recovery HD goes in relation to OS X. To do what I'm suggesting requires some surgery to make happen, and I'm only familiar with command line tools to make that happen. The GUI tools simply don't allow it.

     

    1.

    You could do a rough partition layout with Disk Utility:

    GUI partition 1 should be sized as Lion Recovery + BIOS Boot + Ubuntu + Swap. You can get the size of a current Lion Recovery HD using 'diskutil list'. (This will actually be GPT partition 2, because GPT 1 is EFI System, which is hidden in the GUI.)

     

    GUI Partition 2 will be OS X.

     

    GUI Partition 3 will be Windows.

     

    2.

    Next install OS X which will split GUI partition 2 into two partitions: OS X and Recovery HD.

     

    3.

    Find the exact sector count for the Recover HD partition. Use gdisk to delete GPT partition 2 so that it's all free space, then create new partitions. The order doesn't matter but it's easier to let Ubuntu be last since the others are fixed sizes and Ubuntu can float in size. Lion Recovery should be the same number of sectors as the one created by the installer, BIOS Boot should be 1MB, and Swap should be system RAM size + 2GB. So create those partitions in gdisk and if necessary use the resort option from the main menu so they're all in order. When you create those partitions, you specify their partition type codes which will inform the firmware and bootloaders what they are. i.e. BIOS Boot is EF02, Swap is 8200, Recovery HD is AB00, Windows is 0700.

     

    4.

    Next you'll use dd to sector copy the current installer created Lion Recovery HD to it's new location. e.g.

     

    dd if=/dev/disk0s7 of=/dev/disk0s2 bs=256k

     

    The bs=256k just makes it go faster by using a larger block size, otherwise it's optional. Do make sure that you get the slice number correct because the destination, the one defined by of=, will have data overwritten, and you won't be asked for permission.

     

    5.

    Delete GPT 7 and 8 (original Recovery HD and Windows), and make a new partition GPT 7 which uses up all remaining free space at the end of the disk (effectively combines Recovery HD and Windows partitions).

     

    6.

    Use gdisk to create a new hybrid MBR adding OS X and Windows only to the MBR.

     

    7.

    Install Windows.

     

    8.

    Install Ubuntu.

     

    9.

    Ubuntu almost certainly uses parted, but I'm not sure if they look at the hybrid MBR and restore it after installation? Parted by default destroys hybrid MBRs. So just know that you may have to recreate the hybrid MBR using gdisk. Even if the system works, you should check and make sure the hybrid MBR is created correctly.

  • Marionumber1 Level 1 Level 1 (0 points)

    I see your reply on my email, but it doesn't appear here in the topic. So I guess I'll reply to this post.

     

    Anyway, I have two questions about that reply.

     

    1. You said that parted will destroy the hybrid MBR. Would I be able to change the GPT partition table to the disk layout that I posted using parted or gparted, then create the hybrid MBR that I posted?

     

    2. If I can't do that, I guess that I would need to use your layout. Would I be able to use dd to back up my Windows 7 and Mac OS X partitions instead of reinstalling them?

  • Christopher Murphy Level 2 Level 2 (470 points)

    @Marionumber1

    1. The question is confusing because you've posted more than one layout and I don't know which one you're talking about. But in any case parted/gparted can create any layout you want, but neither are capable of creating hybrid MBRs. You need a different tool for that. I use gdisk to modify GPTs and create hybrid MBRs from them.

     

    2. Yes but you need a disk at least twice the size of the partition you're duplicating if it's a same disk partition copy; and the file system can't be mounted so you'll have to boot from a LiveCD or something to do such copying.

     

    I see my post but not yours. I wonder if this thread is broken. For months when I click on the link in email notifications, it takes me to a page in teh middle of the thread, not the beginning or the end. So I wonder if the thread is breaking the forum's ability to resolve it. Kindof a long thread.

1 ... 14 15 16 17 18 ... 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.