Clarifications of the Hybrid MBR

Discussion in 'Windows, Linux & Others on the Mac' started by JK43232, Mar 8, 2012.

  1. JK43232 macrumors newbie

    Joined:
    Dec 14, 2009
    Location:
    Columbus, Ohio
    #1
    Hello All,

    I am in the process of trying to wrap my head around some details regarding a multi-boot setup with OS X Lion and Windows 7 on an early 2011 15" MacBook Pro.

    Specifically, I am trying to get a clear understanding of a Hybrid MBR in relation to this. I have scoured this forum along with the Apple forums and to some extent the InsanleyMac forums. I have found a lot of info, but in some cases, the info is confusing because various sources seem to contradict each other.

    I am looking for some details about the hybrid MBR and how it is actually created.

    Below is what I have come to understand so far . . .

    My questions are in BOLD . . . and indented . . .



    Most of the sources explain that the hybrid MBR is a modified GPT Protective MBR.

    "The protective MBR is an MBR that defines a single partition entry (of type 0xEE) that covers the entire area of the disk used by GPT structures and partitions. It is designed to prevent GPT-unaware programs from accidentally modifying a GPT disk." (Apple TN2166)

    The MBR has space or slots for four partition entries (primary partitions) and in the case of the protective MBR only one is used to define the entire area of disk that is partitioned via GPT??? -- CORRECT??


    A hybrid MBR is a modified GPT protective MBR.

    It uses up to three of the MBR's four primary partitions to point to the same space that's marked out by three GPT partitions. (The remaining MBR primary partition contains the EFI System Partition)

    In the case of Lion, the Recovery HD accounts for one more of these partitions, leaving two that can point to GPT partitions???? -- CORRECT??​


    In the thread "Boot camp partition not recognized" in this Mac Rumors Forum a post from "Infrared" states: --

    "As you may know, your drive has two partition tables. A GUID partition table and an MBR partition table. It's a hybrid scheme."

    "When you use Disk Utility to add a FAT partition, say, it alters both partition tables."

    The reference to TWO partition tables refers to a partition table contained within the protective MBR as well as the GPT partition tables?? -- CORRECT??​


    Even without a "hybrid MBR" there are still two partition tables are there not?? -- CORRECT??​



    If I understand the above correctly:

    hybrid MBR refers to the fact that the four partition entries in the protective MBR now point to the same space as the first four GPT partitions. (There is no longer an entry in the protective MBR of type 0xEE that covers the entire area of the GPT partitioned disk . . .)??? -- CORRECT??​



    Once I am clear on WHAT a hybrid MBR is, I have a couple of questions regarding how they are created . . .

    Thanks

    John
     
  2. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    Is there a particular reason you need more partitions than Boot Camp Assistant will support?

    What specifically are you trying to accomplish in the end?

    B
     
  3. JK43232 thread starter macrumors newbie

    Joined:
    Dec 14, 2009
    Location:
    Columbus, Ohio
    #3
    I am mostly just trying to gain some knowledge about the hybrid MBR as used on a Mac when using a Boot Camp partition.

    It started when researching possibilities for using more than one partition in order to dual-boot 10.7 and 10.6 along with a Boot Camp partition.

    I am mostly aware of the pitfalls involved with multiple partitions but I am also aware that it is possible to achieve a multi-boot system as I have one currently with 10.5, 10.6, and Boot Camp that I hae been using for a couple of years with no problems.

    Because Lion is a bit more of a challenge with the added Recovery HD, I am trying to get some details on on how the hybrid MBR works.

    I might point out that I am doing my exploration on a second MacBook Pro and not my primary MacBook Pro because I know that it is easy to screw things up. All the more reason I am hoping to gain some insight to the hybrid MBR from other participants in this forum.

    Sort of reminds of the good old DOS days of spending hours/days trying to load drivers in different orders in upper and lower memory to get them all to fit. . .

    Ultimately, what I am specifically trying to accomplish is to learn something new . . .
     
  4. murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #4
    MBR and GPT are two different partitioning methods. APM is a third. MBR pre-dates GPT. The UEFI spec defines the GPT, and suggests that LBA 0 (the first sector of a drive) contain a protective MBR, which is an MBR with a single partition entry, type 0xEE, covering all sectors from LBA 1 (the start of the GPT) to the (second to) last LBA. The UEFI spec also distinguishes between such a protective MBR and a legacy MBR which is one that doesn't contain an 0xEE entry.

    The GPT of such a disk contains three entries: EFI, Mac OS, Recovery HD. Before Bootcamp, the MBR contains one 0xEE entry for the whole disk. After Bootcamp, the MBR contains entries in all four locations: an adjusted 0xEE for blocks that contain the primary GPT itself, and EFI partition; an entry 0xAF for Mac OS, an entry 0xAB for Recovery HD, and entry 0x07 for Windows.

    It's much easier to visualize this if you use GPT fdisk, from Source Forge, also knowns as gdisk to view the actual GPT entries. And the included fdisk from Apple to view the MBR.


    The original reference is misleading in that you don't really have two independent partition tables, by default. You have just one, GPT. Which comes with a recommended protective MBR, which is an MBR that has a single protective entry, type code 0xEE, spanning the whole disk. This is just to protect the primary GPT and the contents of the disk from legacy OS's and apps that don't know what GPT is. That's it. It's not an independent partition table.

    Disk Utility doesn't have a way for you to add any partitions to a disk, you have to re-partition from scratch. When you do this, that disk gets a whole new GPT with however many partitions you define (plus a hidden EFI System partition), and a protective MBR with a *SINGLE* 0xEE entry.

    In the case of Boot Camp, first it resizes an existing JHFS+/X volume, adjust the entry in the GPT, creates a new GPT entry for the freed up space (for Windows), formats it FAT32, and then creates a hybrid MBR which contains a resized 0xEE entry for just the blocks containing the primary GPT and EFI System partitions. And separate entries for Mac OS, Recovery HD, and Windows.

    If you were to use command line tools to resize that JHFS+ partition yet again, you'd have one messed up disk because it will not update the hybrid MBR. Just the GPT.

    Here is a good time to point out that hybrid MBRs are flakey, dangerous, non-standard, and depart from the UEFI spec considerably. They even depart from Apple's own technote on this, yet they use them. I'm not a fan, but this is consequence of not having UEFI 2.x firmware on Apple hardware, which is the minimum required for a Windows 7 x86_64 UEFI installation, instead of a BIOS based installation. Windows BIOS installs only use MBR for boot disks. And Windows UEFI installs only use GPT for boot disks. Since we don't have UEFI 2.x firmware, but Apple and Intel did include a CSM-BIOS with most Apple hardware - we're in this hybrid MBR business.



    Not really. That protective MBR is just a place holder to protect the data on the disk from legacy MBR only tools and operating systems that do not understand GPT.


    It's confusing, I admit it. A protective MBR as defined in the UEFI spec is an MBR that contains a single protective 0xEE partition entry. That's it.

    A hybrid MBR is not defined anywhere. It is an MBR that contains one protective 0xEE entry: it is protecting the blocks for the primary GPT and the EFI System partition; and it contains one or more additional entries.

    Further, there is NO requirement that the MBR entries at all match up with GPT entries. In order for me to triple boot Apple hardware, I generate my own hybrid MBR using gdisk. I have a GPT with 8 entries, depending on which OS's are installed and how they're configured. I will generally make Windows the very last GPT entry. The MBR 1st partition is defined for the blocks making up *all* of the GPT first 7 partitions, with type code 0xEE, and the MBR 2nd partition defines the blocks identical to the GPT's 8th partition entry for Windows. So in the MBR, I'm only exposing the Windows blocks. I mark that bootable, because that's what Apple's EFI implementation needs to activate the CSM-BIOS to find and run the bootloader code in the first 440 bytes of the MBR.

    It all gets VERY confusing because different hardware treats hybrid (non-standard!) MBRs differently.


    Umm, definitely not. As soon as the 0xEE entry is missing from an MBR, it is no longer a protective or hybrid MBR. It is a valid legacy MBR and the UEFI spec language fully supports treating such a disk entirely an only as an MBR disk, and the GPT is to be ignored.

    And think of the reason why. When you use a legacy tool for partitioning a disk, like fdisk, that has no idea what a GPT is, what's it going to modify? Only LBA 0. It will only alter the MBR. It has no way of blanking out the primary or backup GPT, which means they will be left intact.

    The only way to resolve this ambiguity fairly is to treat a disk that has a valid legacy MBR (no 0xEE entry) as strictly MBR.

    Remember, the 0xEE entry starts at LBA 1. LBA 1 is the primary GPT header, and subsequent sectors contain the GPT entries themselves. If they are not protected by an MBR partition entry of 0xEE, then those sectors are NOT allocated as far as MBR aware applications/systems are and are fair game for being overwritten.
     
  5. JK43232 thread starter macrumors newbie

    Joined:
    Dec 14, 2009
    Location:
    Columbus, Ohio
    #5
    Thanks for the info :)

    Couple of things . . .


    Actually, I found that if you partition a disk using Disk Utility and set the format for one of the partitions "MSDOS", you in fact end up with a "hybrid MBR". I confirmed this using gdisk and fdisk.

    I also found that I can then install Windows 7 on that partition and it is bootable from both "Startup Disk" and option-boot



    What is the implication now that the newer MacBook Pros have an upgraded firmware that is EFI version 2.7???? Are these new versions of EFI on the Mac UEFI compliant???




    That is indeed interesting. Although I am not comfortable enough yet to attempt a similar apporoach, it might be interesting to explore this later. For now I am able to get 10.7.3, 10.6.8, and Windows 7 triple booting on my MacBook Pro and still have an additional partition for keeping some data separate from the boot volumes. That is good enough for now until I am ready to sacrifice the optical drive for a second hard drive. . .
     
  6. murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #6
    That makes zero sense. fdisk is an MBR only utility, if you've made an MBR disk using Disk Utility, fdisk could only confirm it's an MBR disk. It has no ability to see GPT structures and would not know if it were "hybride". And I just tried this with 10.6.8's Disk Utility and gdisk reports it as MBR only.

    If Lion's Disk Utility behaves differently, which I find difficult to believe, it is a very ill conceived feature that significantly departs from the UEFI spec which very clearly defines that a disk which does not contain a PMBR, with a *SINGLE* 0xEE entry, is to be considered only an MBR disk. Not GPT. There is no such standard thing as a hybrid MBR disk. It's why they are a bad idea to begin with. To make them on purpose with Disk Utility I would consider improper design or a bug.

    Negative. The confusion is that Apple uses a versioning scheme for firmware updates that's independent of the (U)EFI specifications. To date, all of Apple's firmware is based on Intel EFI 1.10. Not UEFI 2.x or greater.
     
  7. srs5694 macrumors newbie

    Joined:
    Mar 18, 2012
    #7
    Murphychris has provided some pretty good information, but I want to clarify a few points. I'm the author of the GPT fdisk (gdisk) partitioning tool, so I know a thing or two about the topic. FWIW, you may want to read my page on the topic. It may answer some of your questions.

    Not quite. To be identified as a GPT disk, the MBR must contain a 0xEE protective entry. This entry is not equivalent to the first partition (normally the EFI System Partition, or ESP) on the disk, although it's often close. Apple tools typically start the ESP at sector 40, but the 0xEE protective entry normally begins at sector 1. Apple's 0xEE entry in a hybrid MBR usually ends at the same point as the ESP, but some other tools can end it at other points. The 0xEE entry doesn't really define a partition, in the sense that the GPT data are what define partitions, and the 0xEE entry doesn't correspond to any valid GPT partition. The 0xEE entry's sole purpose is to identify the disk as a GPT disk -- to make GPT-unaware utilities think the disk is in use by an unknown OS and to let GPT-aware utilities know to interpret the GPT data (stored elsewhere).


    Actually, there's another thread on this forum (here) that's devoted to the quest to boot Windows 7 and 8 in EFI mode on Macs. Some posters claim to have succeeded in doing this. The major challenge turns out to be driver support, not the EFI version. Apparently it's much easier with Windows 8 than with 7, FWIW. That said, my own Intel Mac is a 32-bit model, and since Windows supports (U)EFI booting only in 64-bit versions, I can't test this myself or comment on it other than to point to that thread.

     
  8. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #8
    Just wanted to take a quick second to thank you for gdisk. It has proven to be an invaluable tool for my arsenal.

    Thanks!

    B
     
  9. MJL macrumors 6502a

    Joined:
    Jun 25, 2011
    #9
    +1
     
  10. JK43232 thread starter macrumors newbie

    Joined:
    Dec 14, 2009
    Location:
    Columbus, Ohio
    #10
    Thanks srs5694 . . . I learned a lot from your site . . . and gdisk is how I confirmed the hybrid MBR . . .



    Possibly I stated things in a confusing manner.

    I was attempting to convey that when using Apple's Disk Utility to partition a disk, AND direct Disk Utility to format ONE of the partitions as "MS DOS (FAT), and the remaining partitions as "Mac OS X Extended", the result is a modified MBR that differs from the normal Protective MBR. I thought that such a modified MBR was commonly called a Hybrid MBR.

    I was going to post some Terminal results to show what I meant but as I am relatively new to these forums, I have to figure out the proper way to import formatted text from TextEdit into a message a maintain the spacing, tabs, etc. once in the post.

    Based on other info found in various forums, it appears to me that for the most part, Boot Camp Assitant simply reduces the size of the current single partition, reclaims that space for the BOOTCAMP partition (and formats it as MS DOS ???) so that the Window 7 installer will allow it to be formatted NTFS and install Windows 7

    I am seeking to determine if there is a compelling reason (other than the risk of messing around with partitions and the syncing of the GPT and MBR) why one could not forgo Boot Camp Assistant and create an MS DOS formatted partition and install Windows 7. (Keeping in mind that Windows (MBR) will only allow installation on one of the four primary partitions . . .)

    Thats it :)
     
  11. murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #11
    My statement was poorly qualified. I think a pure Intel EFI 1.10 implementation would be problematic for Windows. But Apple, on more recent hardware for the past couple of years, isn't using a purely Intel EFI 1.10 compliant firmware. They have been taking bits of UEFI 2.x, and have in effect created a hybrid firmware. Maybe one of the more significant inclusions was GOP, which is UEFI graphics. And UGA, which is Intel EFI graphics. Apple used to use UGA, now they are using GOP. I have one laptop that's UGA based, and another that's GOP based.

    So it remains a bit unclear, like many things (U)EFI on exactly what's required to make both the hardware and the operating system happy and bootable. And this is assuming there are no bugs in the firmware related to either the successes or failures.

    Wow. Ick.

    I've just reproduced this behavior. Even if the partition scheme is set to GPT, so long as the total number of partitions in the Disk Utility GUI is 3 or less, and one of the partitions's volume format is set to FAT, both GPT and MBR are populated. If 4+ partitions, then only an 0xEE entry is in the MBR.

    I think this is a bad idea on the part of Apple. The only use case I can think of is that it's the only way, short of using gdisk, to partition and format an external disk that can dual boot Mac OS and Windows. But still..wow, ick.

    Anyway, I think what will push better behaviors in this regard in the near future will be 2.2+TB disk support. To support 2.2+TB disks in any sense approaching rationality (let alone the "Apple" way), they're going to need to get their EFI firmware booting Windows 8 with an EFI boot, so they can totally dump MBR - which of course only supports 2.2TB or less.

    ----------

    By the way, this behavior is not reproducible on disks larger than 2.2TB. Two partitions, one FAT, but only one 0xEE entry in the MBR. With Apple's existing tools, people can not install Windows on such a disk.
     
  12. AllanH, Apr 20, 2012
    Last edited: Apr 20, 2012

    AllanH macrumors newbie

    Joined:
    Jul 16, 2008
    #12
    quick simple "relevant" question

    Is there a performance drop of a win7 install on a GUID vs MBR formated disk?

    im about to install win7 on a new ssd & im rrrrreally tempted to drop bootcamp and just /alt boot between os´s, if; theres a performance-increase or stability-improvement at all.

    anything relevant at all, a gamer would notice in fps performace ect... or video crunching with the install on a MBR rather than using Bootcamps Hybrid?

    Sorry for barging in, just seems to me, You Lot were the ones, that could give a trustworthy answer to that.

    (im not worried about startupdisk ect ... just purely performance)

    thanx for giving a newb a minute!

    edited for self newbness
     
  13. AllanH macrumors newbie

    Joined:
    Jul 16, 2008
    #13
    ok i know im disturbing science....

    ...to re-ask the "simple" newbish question in a simpler manner (and rape your thread a little more):

    i have an ssd to install windows on (no other partitions other than what the os´s create ofc (recovery, ect...)). Single disk for Win7.

    option 1:

    Format the drive with MBR, install win7, install the drivers (with a usb stick, dvd , wutever)

    Install windows (so no bootcamp hybrid on this install)

    Accept that booting between os´s will be with /alt and not within os.

    option 2:

    Do the install the usual osx way with bootcamp.

    Question:

    Between 1 & 2 , Will there be any noticeable performance difference?

    It would be acceptable to alt-boot if there is a performance increase.

    Is there?

    (dont hate the newb) :eek:
     
  14. murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #14
    You don't have a choice between GPT and MBR with Windows on Apple hardware. Windows will only use an MBR, the GPT is ignored.

    Keep in mind these structures are tiny. The MBR table itself is 64 bytes. The GPT header is 94 bytes, and each entry is 128 bytes. The entire GPT is read and processed in thousandths of a second. Neither of these things are file systems.

    You are confused about what Boot Camp is: there's an Assistant that runs on Mac OS which helps resize Mac OS volumes and re-partition the disk so there's room for Windows, and it will help you make install media, and download Windows drivers to a USB stick or optical media. That's it. There is no such thing as "booting with Boot Camp" or "into Boot Camp" or all of the other ways people on the forums use the term. You are using the exact same booting process whether you use the Option key at startup, or the Startup Disk panel in System Preferences. There's no such thing as "dropping bootcamp" to boot Windows.


    No.


    No.

    No.



    Has less to do with being a noob than asking the exact same question five times, five different ways. Kinda weird.
     
  15. AllanH macrumors newbie

    Joined:
    Jul 16, 2008
    #15

    yea the weed was good this weekend , Sorry

    So, on another note: THANK YOU!

    Couldnt have cleared the confusion about it better!

    Thanx a Ton for your time ... kind regards & respects.
     
  16. notmyreal macrumors newbie

    Joined:
    Jun 25, 2012
    #16
    please excuse the long reply but the difficulties I'm facing seem to belong here the most rather than a new thread:

    I installed rEFIt, and (I think) it successfully created a Hybrid MBR (or at least am partway toward creating one), and upon rebooting the Macbook Pro the rEFIt menu shows up and works fine and the original OSX install is still working, but the newly created Partition was only 200MB, which clearly isn't big enough for a Windows7 install (which is my first goal, to be followed by creating more Partitions to facilitate a Triple-Boot with Ubuntu, Win7, and Snow Leopard on an '11 Macbook Pro).

    and I have been trying to follow these threads for tips but am having issues:

    * http://ubuntuforums.org/showthread.php?t=1910328
    * http://refit.sourceforge.net/tripleboot/
    * http://forums.macrumors.com/showthread.php?t=1336597

    Namely… upon seeing the new Partition is only 200MB I tried using diskutil > resizevolume to simultaneously shrink the OSX Partition and create two new Partitions (for Win7 and Ununtu respectively) using the following (I am, clearly, a novice to these tools but have done many similar things on the Win platform… please let me know if I'm making some obvious rookie mistake) using the following:

    diskutil resizevolume /dev/disk0s2 465.3G "MS-DOS FAT32" "Ubuntu" 10G "MS-DOS FAT32" "Windows" 20G

    which started out fine but threw the following error:

    "Started partitioning on disk0s2 Macintosh HD
    Verifying disk
    Error: -9915: Could not modify partition map because filesystem verification failed"

    after that I tried a few things a few times each…

    * using gdisk to delete the 200MB partition to try to start over (works fine, didn't help)
    * firing up BootCamp (doesn't work, I forget the error)
    * uninstalling and reinstalling rEFIt (easy and repeatable, but no help)
    * various attempts to use diskutil > resizevolume (with varying degrees of success)

    and now… I'm back to a (seemingly) successfully installed rEFIt, and OSX works fine, but with a deleted 200MB Partition (I did this previously), but most notably the following evidence that something is jacked up with the MBR/Partition table:

    using gdisk from a Terminal it's currently reporting only one Partition via p (print partition table), which is the correct number of Partitions but...:

    Number Start (sector) End (sector) Size Code Name
    2 409640 976248839 465.3 GiB AF00 Customer

    and a contradictory report from diskutil from a Terminal which reports:

    /dev/disk0
    #: TYPE NAME SIZE IDENTIFIER
    0: GUID_partition_scheme *500.1 GB disk0
    1: Apple_HFS Macintosh HD 499.6 GB disk0s2

    and Disk Utility GUI from OSX 10.6.8 reporting and throwing the following error:

    - it only sees one Partition, 499.63GB on the Partition tab

    - and the Verify Disk button throws the following errors:

    "This disk needs to be repaired. Start up your computer with another disk (such as your Mac OSX installation disc), and then use Disk Utility to repair the disk."

    and the details say:

    "Verifying volume “Macintosh HD”
    Performing live verification.
    Checking Journaled HFS Plus volume.
    Checking extents overflow file.
    Checking catalog file.
    Checking multi-linked files.
    Checking catalog hierarchy.
    Invalid directory item count
    (It should be 33 instead of 32)
    Checking extended attributes file.
    Checking volume bitmap.
    Checking volume information.
    The volume Macintosh HD was found corrupt and needs to be repaired.
    Error: This disk needs to be repaired. Start up your computer with another disk (such as your Mac OS X installation disc), and then use Disk Utility to repair this disk."

    so, what gives?

    What is the accurate description of its current state (other than jacked up…)?

    and, how do I:

    (A) get the HD/MBR/Partition Table back to factory state such that I can start over from the beginning (without harming the current OSX install which is still fine)?

    and/or

    (B) get from here to a successfully resized/shrunk OSX Partition and the creation of the other Partitions needed to facilitate the Win7 and Ubuntu installations in triple boot via rEFIt?

    I/we have been seemingly getting closer over the last few days but seem to be dancing around the outside, almost getting it right, but something is clearly wrong. Please help.

    Thanks in advance…
     
  17. murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #17
    Report the results of the following commands which are read only. Please format the results with CODE tags using the # button in the formatting bar.

    Code:
    sudo gpt -r -vv show disk0
    diskutil resizevolume /dev/disk0s2 limits
    Later, you report gdisk says the single Mac OS volume is already 465.3GiB. So your command is invalid because you've asked for a Mac OS volume resized to its current size while asking for two new partitions. You're better off using percentages.

    diskutil resizevolume /dev/disk0s2 94% "MS-DOS FAT32" "Ubuntu" 2% "MS-DOS FAT32" "Windows" 4%

    Those sizes are small though. And Disk Utility is reporting directory problems which is the likely real source of the error you're getting when resizing.

    You should reboot single user mode, and use:

    Code:
    fsck_hfs -r /dev/rdisk0s2
    This rebuilds the catalog btree which the GUI utility doesn't ever do as far as I know. You should have a current backup of important information before doing this. If it fails catastrophically, the disk will likely be unrepairable.

    That was a mistake. A 200MB partition is almost certainly the EFI System partition. Based on the gdisk report of a single partition, pretty sure you deleted your EFI System partition. If you have a screen shot of your partition table before you started, which you should have done before starting, you can create a new 1 partition with the proper start and end sector with type EF00. If you didn't, I'm pretty sure the default is start sector 40, and end sector 409639.

    The contradiction is what?

    A Snow Leopard "1 partition" disk in the GUI is actually two partitions. A Lion "1 partition" disk in the GUI is actually three partitions.
     
  18. murphychris, Jun 25, 2012
    Last edited: Jun 25, 2012

    murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #18
    Further, rEFIt is no longer maintained. You should use rEFInd.

    http://www.rodsbooks.com/refind/
    http://sourceforge.net/projects/refind/

    Next, you might read this:
    http://forums.fedoraforum.org/showthread.php?t=273123

    You will almost certainly need more than one partition for Ubuntu. I don't know what its defaults are, and if it can EFI boot your particular Mac model. Conceivably EFI booting Ubuntu could use the EFI System partition (if you restore it correctly) and a single additional partition for boot, root and use a swapfile instead of swap partition, although this limits your file system choices. For CSM-BIOS booting, Ubuntu probably wants a BIOS Boot partition for the GRUB2 bootloader, a boot partition, and an LVM partition (for root and swap).

    I have found it's easier to shrink the Mac OS partition and leave newly created space as Free Space, rather than it being formatted FAT32. A single range of free space is fine. Then use the Ubuntu installer to use the free space and its defaults for the initial partition layout to make sure you have the parts it wants, while also customizing those defaults to create an additional partition for Windows.

    As soon as you need more than four partitions, gptsync built into both rEFIt and rEFInd will not create the proper hybrid MBR. You'll have to create it manually with gdisk. My recommendation is that you stuff all GPT partitions except Windows into the MBR partition 1, protective MBR, code 0xEE. And then put the last GPT partition, Windows, in MBR partition 2 with the boot flag enabled. Basically this will tell any MBR only aware application that all of your non-Windows partitions are reserved for GPT usage, exposing only the Windows partition. Boot Camp Assistant almost certainly won't like it, but it's not designed for triple booting anyway so you shouldn't plan on ever using it.

    Note, you MUST have created the partition for Windows, formatted or not doesn't matter, and created the hybrid MBR before you run the Windows installer.
     
  19. notmyreal macrumors newbie

    Joined:
    Jun 25, 2012
    #19
    thank you for the help.

    I'm beginning to work my way through it after having read your replies and the links, and I'll post the results as I go.

    starting with:

    ok:

    Code:
    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     409606         
         409640  975839200      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
      976248840     524295         
      976773135         32         Sec GPT table
      976773167          1         Sec GPT header
    
    and:

    Code:
    For device disk0s2 Macintosh HD:
            Current size:  499.6 GB (499629670400 Bytes)
            Minimum size:  204.7 GB (204667121664 Bytes)
            Maximum size:  499.8 GB (499763888128 Bytes)
    
     
  20. notmyreal macrumors newbie

    Joined:
    Jun 25, 2012
    #20
    ok. it found and fixed two errors, and completed successfully:

    [​IMG]
     
  21. murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #21
    OK so the fourth entry in the gpt show results:
    Code:
            34     409606      
    This is your deleted 200MB EFI System partition. You should consider resurrecting this because Apple uses it to stage firmware updates, and could use it for other purposes at anytime without notice as it's required by the EFI spec. I suggest doing this before anything else because doing it later gets more complicated. How to do it? Either repartition your drive with a single partition, and restore from backup, or use gdisk.

    Once installed, type:
    Code:
    sudo gdisk -l /dev/disk0
    and post the results.

    The single GPT entry present, as you provided, is compatible with the resizevolume limits results. Nothing has been resized. You have a single Mac OS volume only. Now that you've reconstructed the catalog, I suggest you rerun the command and post the results, to confirm the new limits:
    Code:
    diskutil resizevolume /dev/disk0s2 limits
     
  22. notmyreal macrumors newbie

    Joined:
    Jun 25, 2012
    #22
    before seeing your response I removed rEFIt and installed rEFInd, which went without issue:

    Code:
    Installing rEFInd on OS X....
    Installing rEFInd to the partition mounted at '/'
    Copied rEFInd binary file refind_x64.efi
    
    Copying sample configuration file as refind.conf; edit this file to configure
    rEFInd.
    
    Installation has completed successfully.
    
    then I followed these instructions:

    ok:

    Code:
    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.
    Disk /dev/disk0: 976773168 sectors, 465.8 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): 40B881F4-3BFF-4136-9E42-EBF5FE40FF95
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 976773134
    Partitions will be aligned on 8-sector boundaries
    Total free space is 933901 sectors (456.0 MiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       2          409640       976248839   465.3 GiB   AF00  Customer
    
    then I did this:

    ok:

    Code:
    For device disk0s2 Macintosh HD:
            Current size:  499.6 GB (499629670400 Bytes)
            Minimum size:  204.9 GB (204879499264 Bytes)
            Maximum size:  499.8 GB (499763888128 Bytes)
    
    also, I (think I) successfully used gdisk to recreate the deleted partition:

    Code:
    Disk /dev/disk0: 976773168 sectors, 465.8 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): 40B881F4-3BFF-4136-9E42-EBF5FE40FF95
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 976773134
    Partitions will be aligned on 8-sector boundaries
    Total free space is 524301 sectors (256.0 MiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1              40          409639   200.0 MiB   EF00  
       2          409640       976248839   465.3 GiB   AF00  Customer
    
    what do you suggest next?

    thanks...
     
  23. murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #23
    OK good.

    So the next thing is you can do the live resize on the volume using diskutil, but instead of your original command, I'd use percentages. For example:

    Code:
    diskutil resizevolume /dev/disk0s2 90% "MS-DOS FAT32" "Ubuntu" 4% "MS-DOS FAT32" "Windows" 6%
    [NOTE that the above code horizontally scrolls!]

    See how that goes. If no errors supply the results from:
    Code:
    sudo gdisk -l /dev/disk0
    sudo fdisk /dev/disk0
    This will produce the entries in the GPT and MBR.
     
  24. notmyreal macrumors newbie

    Joined:
    Jun 25, 2012
    #24
    ok, so I did that and it failed the first time:

    Code:
    sudo diskutil resizevolume /dev/disk0s2 90% "MS-DOS FAT32" "Ubuntu" 4% "MS-DOS FAT32" "Windows" 6%
    Password:
    Started partitioning on disk0s2 Macintosh HD
    Verifying disk
    Resizing
    Error: -9939: The partition cannot be resized.
    
    I don't know what that error really means, or what part(s) of the process of resizing the MAC OS partition and creating the other two failed (via your diskutil code that's meant to do all three at once), but out of curiosity I tried to execute a simplified version of the diskutil code to only resize the MAC OS partition (to the 90% you suggested) and it worked fine:

    Code:
    sudo diskutil resizevolume /dev/disk0s2 90%
    Password:
    Started partitioning on disk0s2 Macintosh HD
    Verifying disk
    Resizing
    Finished partitioning on disk0s2 Macintosh HD
    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                  Apple_HFS Macintosh HD            450.1 GB   disk0s2
    
    I googled for an answer re what the initial error code meant, and while I didn't find a solid answer - I did see a suggestion that it could be a problem with the disk and to run Verify Disk from the Disk Util gui - which I did, and it came back saying the disk was OK, no errors at all.

    I've stopped short of trying to create the other two partitions yet...

    What do you make of that error?

    Why do you think the diskutil code you suggested to create all three failed?

    What do you suggest now?

    Thanks...
     
  25. murphychris macrumors 6502a

    Joined:
    Mar 19, 2012
    #25
    Not sure. Maybe it wants R instead of a % for the last entry, it may be that due to rounding that using % for all three partitions you end up with a request that's asking for more space than exists for the last volume. Anyway, you now have free space at the end of the disk, and you can use gdisk to split that up however you want.

    Code:
    sudo gdisk -l /dev/disk0
    I would do what you were doing before. I'd add a partition for Ubuntu first, and Windows second. Accept the default starting sector gdisk comes up with, for the ending sector you can add a size instead, e.g. 20G. For the partition type code it's 8300 for Ubuntu and 0700 for Windows.

    Realize that Ubuntu will split the partition you hand it into additional partitions. That's normal.

    After you're done installing Ubuntu, you have more gdisk work to do. And until you install Ubuntu and I know whether it CSM-BIOS boots, or EFI boots, I can't tell you what to do next without it getting insanely complicated.
     

Share This Page