I spent several hours today struggling to fix my iMac triple boot setup with Mac OS X Lion, Windows 7 x64, and Ubuntu 11.10. rEFIt does not handle the new Apple Boot partition included in the latest release of Apple’s operating system. This article provides an example of how to fix your MBR table manually without using the rEFIt partition sync tool.
This is not a triple boot setup guide. I’m providing this information here for any of those poor souls who are also struggling with this problem and looking for a solution.
## The Scenario and Problem ###
You have already gone through the motions of creating a triple boot setup. For example, you’re running Mac OS X Lion, had installed rEFIt, installed Windows 7 x64, and installed Ubuntu 11.10. However, when the rEFIt menu appears, selecting Linux boots Windows. Selecting Windows also boot Windows. Selecting Mac OS X boots Mac.
If this sounds like the problem you’re having, then read on.
## The Cause ###
You’ve followed all of the triple boot instructions that you can find online. For example, you’ve made sure to install the grub boot loader on the Linux partition rather than on the master boot record (MBR). Everything seems like it should work, but it doesn’t. Only stubborn old Ubuntu [or some other Linux distro] refuses to boot.
From what I can tell, the problem lies with rEFIt in combination with Mac OS Lion. Mac OS X 10.7 adds a new Apple boot partition. If you use the rEFIt partition sync tool, it may place this partition in your MBR table. Since the MBR table can only have 4 partitions in this implementation, that means that one of your other operating systems doesn’t make the cut. In my case, this was Ubuntu.
## The Solution ###
The solution is to fix the MBR table yourself without rEFIt, since rEFIt doesn’t handle this new development. The guide that follows only serves as an example. Your case will likely differ, so read through this for the general process and make adjustments where you need.
* Boot into Mac OS X
* Run the Partition Inspector application. This application is normally installed with rEFIt in /Applications/Utiltities.
* Launch terminal
* Run the following command to find out what disk# you should be using: `diskutil list` [hint: it’ll be all the one with your operating system partitions on it, usually disk0].
* Run the following command making any substitutions for disk number in your case: `sudo fdisk -e /dev/disk0`.
Upon running the fdisk command, it might complain at you and perhaps give you an error message that looks something similar to `fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory`. Just ignore that message. What’s important is that you should now be at the fdisk prompt which looks something along the lines of `fdisk: 1 >`
At this prompt enter `print` and you should get a readout somewhat like the following:
fdisk: 1 > print Disk: /dev/disk0 geometry: 121601/255/63 [1953525168 sectors] Offset: 0 Signature: 0xAA55 Starting Ending #: id cyl hd sec - cyl hd sec [ start - size] ------------------------------------------------------------------------ 1: EE 1023 254 63 - 1023 254 63 [ 1 - 39] 2: 0B 1023 254 63 - 1023 254 63 [ 40 - 409600] Win95 FAT-32 *3: AF 1023 254 63 - 1023 254 63 [ 409640 - 1763671872] HFS+ 4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
Now begins the fun. You need to update this table with the correct information, write it, and then reboot. To help make this process more clear, below is example output generated from the Partition Inspector application in my particular case. You will need to reference this information as you update the MBR partition. This example is also the finished product with everything working, so you can use the information under “Current MBR partition table” as an example of what you’re trying to achieve in the end.
*** Report for internal hard disk *** Current GPT partition table: # Start LBA End LBA Type 1 40 409639 EFI System (FAT) 2 409640 1764081511 Mac OS X HFS+ 3 1764081512 1765351047 Mac OS X Boot 4 1765351424 1892032511 Basic Data 5 1892034560 1953523711 EFI System (FAT) Current MBR partition table: # A Start LBA End LBA Type 1 1 39 ee EFI Protective 2 * 1765351424 1892032511 07 NTFS/HPFS 3 409640 1764081511 af Mac OS X HFS+ 4 1892034560 1953523711 83 Linux MBR contents: Boot Code: Unknown, but bootable Partition at LBA 40: Boot Code: None (Non-system disk message) File System: FAT32 Listed in GPT as partition 1, type EFI System (FAT) Partition at LBA 409640: Boot Code: None File System: HFS Extended (HFS+) Listed in GPT as partition 2, type Mac OS X HFS+ Listed in MBR as partition 3, type af Mac OS X HFS+ Partition at LBA 1764081512: Boot Code: None File System: Unknown Listed in GPT as partition 3, type Mac OS X Boot Partition at LBA 1765351424: Boot Code: Windows BOOTMGR (Vista) File System: NTFS Listed in GPT as partition 4, type Basic Data Listed in MBR as partition 2, type 07 NTFS/HPFS, active Partition at LBA 1892034560: Boot Code: GRUB File System: ext4 Listed in GPT as partition 5, type EFI System (FAT) Listed in MBR as partition 4, type 83 Linux
### Editing the partition table ####
This is an example of how the editing process will go based on my example scenario above.
We can cross reference the fdisk print report about the MBR and compare it to the GPT table. For example, in MBR slot #2 [in the fdisk print results above], it has a start of 40 and a size of 409600. This corresponds to the GPT entry “Partition at LBA 40.” This can also be found in the first group of results generated by the Partition inspector. This MBR entry #2 corresponds to GPT partition #1. It has a start of 40. You can calculate the end by subtracting 1 from the size. For example: 40 + 409600 – 1 = 409639 (the ending LBA).
In my case, MBR slot #4 is reportedly unused [in my case rEFIt reports this as the Apple Boot partition]. Comparing the MBR table to the GPT table we can see that the MBR table properly has my Mac partition, the EFI protection partition, and the Windows partition. So, I need to add my Ubuntu partition to the MBR table in slot #4.
Do not remove the “EFI Protective” partition from the MBR. According to the Myths page on the rEFIt Web site, this partition tells GRUB not to overwrite the GPT tables. Additionally, Curtis Shimamoto reports that the protective partition must start at LBA 1.
Referring to the Partition inspector, we can see that the “Partition at LBA 1892034560” is the Ubuntu partition. This is because its boot code is “GRUB” and its filesystem is ext4. Those are some distinct GNU/Linux markers right there. Before heading back to fdisk though we need to do a quick bit of math. fdisk takes a start LBA, but it takes a size instead of an end LBA, so the size must be calculated. Fortunately, Partition inspector provides this information in the first grouping of results under “Current GPT Partition Table.” Take the end LBA and subtract the start LBA and add 1 to obtain your size. For example, 1953523711 – 1892034560 + 1 = 61489152.
Now that we have the information that we need, it’s time to go back to the terminal which should still be waiting at the fdisk prompt. Since I want to update MBR table slot #4, type in `edit 4` The first thing it will probably say is `Partition id (‘0’ to disable) [0 – FF]: [B] (? for help) ?`. fdisk is asking for the partition type. If you enter “?” it will provide you with a list of all your options. In this case, for Linux, I’ll use “83”
If fdisk asks `Do you wish to edit in CHS mode?` say “n”.
fdisk will ask for the Partition offset. This is the starting LBA, so enter that. Remember that in my case it was 1892034560, but this is almost guaranteed to be different for you. The final question that fdisk will ask is for the size, so enter the previously calculated size.
Finally, write the MBR table with the `write` command. You will probably receive an error asking if it’s o.k. to make the changes after a reboot because the device could not be accessed exclusively. Say yes [“y”] and then quit with `quit`.
Repeat the process as necessary until your MBR table is completed.. If you’re only struggling with the new Apple boot partition taking up one of the MBR slots, then one pass similar to what I just did above should get the rEFIt triple boot menu back on track in and in working order.
## Concluding Remarks ###
This is certainly an inelegant solution, but it’s a satisfactory workaround until the problem with the gptsync tool can be resolved. I have filed a bug report that can be tracked if you’re interested in following this issue: [gptsync mishandles apple boot partition in Mac OS X Lion](https://sourceforge.net/tracker/?func=detail&aid=3434267&group_id=161917&atid=821764)
I had a corrupted microSD card from a GoPro which had no partition info at all on it. Apparently this is the only document on the internet (that isn’t a disguised ad for some product) which details how to re-write an MBR partition without wiping the card. Gold star, bravo
Hello
Now i understand why it not possible to get my triple boot MacOS Mavericks, Ubuntu and Ubuntu Studio working good.
Can you help/clear this out for me:
But i can’t fix it with your solution because i use ReFind and there is not a “Partition Inspector” application. Is this possible with Terminal?
I have taken a look in the MBR table with MacOS Terminal and see that there are also only four of them:
1 EFI
2 MacOS X
3 Recovery HD
4 Ubuntu
So it is never possible to do what i wanna do: triple boot MacOS Mavericks, Ubuntu and Ubuntu Studio?
Is there a solution to get an extra fifth line in the table?
5 Ubuntu Studio
The Recovery HD has to be in the MBR to boot from, or not?
Kind regards
Bart
Here’s my problem. I have two drives, one with 10.10, 10.11, and Win7. The second drive has my /Users/home and Ubuntu 15.04.
Partition Inspector doesn’t seem to see the second disk (//dev/disk1), so how to I add Linux from the 2nd drive to the MBR of the the 1st drive?
Below are Partition Inspector, fdisk and diskutil outputs.
Thanks for any suggestions you can offer.
*** Report for internal hard disk ***
Current GPT partition table:
# Start LBA End LBA Type
1 40 409639 EFI System (FAT)
2 409640 1698349335 Mac OS X HFS+
3 1698349336 1699618871 Mac OS X Boot
4 1699618872 1797013503 Mac OS X HFS+
5 1797275648 1953523711 Basic Data
Current MBR partition table:
# A Start LBA End LBA Type
1 1 1797275647 ee EFI Protective
2 * 1797275648 1953523711 07 NTFS/HPFS
MBR contents:
Boot Code: Unknown, but bootable
Partition at LBA 40: EFI
Boot Code: None (Non-system disk message)
File System: FAT32
Listed in GPT as partition 1, type EFI System (FAT)
Partition at LBA 409640: MacBoot
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 2, type Mac OS X HFS+
Partition at LBA 1698349336: Recovery?
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 3, type Mac OS X Boot
Partition at LBA 1699618872: El Capitan
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 4, type Mac OS X HFS+
Partition at LBA 1797275648: Windows
Boot Code: Windows BOOTMGR (Vista)
File System: NTFS
Listed in GPT as partition 5, type Basic Data
Listed in MBR as partition 2, type 07 NTFS/HPFS, active
diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS MacBoot 869.3 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
4: Apple_HFS El Capitan 49.9 GB disk0s4
5: Microsoft Basic Data Windows7 80.0 GB disk0s5
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *750.2 GB disk1
1: EFI ESP 209.7 MB disk1s1
2: Apple_HFS MacOSX 700.2 GB disk1s2
3: Microsoft Basic Data Ubuntu 49.7 GB disk1s3
sudo fdisk -e /dev/disk0
fdisk: 1> print
Disk: /dev/disk0 geometry: 121601/255/63 [1953525168 sectors]
Offset: 0 Signature: 0xAA55
Starting Ending
#: id cyl hd sec – cyl hd sec [ start – size]
1: EE 1023 254 63 – 1023 254 63 [ 1 – 1797275647]
*2: 07 1023 254 63 – 1023 254 63 [1797275648 – 156248064] HPFS/QNX/AUX
3: 00 0 0 0 – 0 0 0 [ 0 – 0] unused
4: 00 0 0 0 – 0 0 0 [ 0 – 0] unused
sudo fdisk -e /dev/disk1
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
Enter ‘help’ for information
fdisk: 1> print
Disk: /dev/disk1 geometry: 91201/255/63 [1465149168 sectors]
Offset: 0 Signature: 0xAA55
Starting Ending
#: id cyl hd sec – cyl hd sec [ start – size]
1: EE 1023 254 63 – 1023 254 63 [ 1 – 409639]
2: AF 1023 254 63 – 1023 254 63 [ 409640 – 1367492920] HFS+
3: 83 1023 254 63 – 1023 254 63 [1368164704 – 96984424] Linux files
4: 00 0 0 0 – 0 0 0 [ 0 – 0] unused
Hello my friend please can u help me !!
i cant mount the partition of windows
and this is the information that i get…
https://imagizer.imageshack.us/v2/320xq90/r/912/eoeUe4.jpg
https://imagizer.imageshack.us/v2/320xq90/r/911/i7dqrQ.jpg
plzz waiting for your help thkx u so much…
Are you trying to boot the Windows partition or mount it from within OS X? If the former then the screenshot makes it appear that it’s a dual boot system instead of triple. If that’s indeed the case, then you should be able to use Bootcamp without having to go through the hassle mentioned in this article.
If mounting the partition from within OS X, what is the error that you receive? If Disk Utility doesn’t give an error message, try from the command line. For example, something along the lines of this:
diskutil list # Find the appropriate disk and replace /dev/disk3s1 below
sudo mkdir /Volumes/windows_hd
sudo mount -t msdos /dev/disk3s1 /Volumes/windows_hd
thank you for your answer:
now i’m trying to mount the partition of windows, before to install Refit it was working fine wind and MAc .
using Disk Utility and trying to mount its geving me error :
“invalid BS_jmpBoot in boot block 762cfc”
And executing the first and segund line :
iMac-de-IMAC:~ imac$ sudo diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.1 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS IMAC 100.0 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
4: Microsoft Basic Data 250.0 GB disk0s4
iMac-de-IMAC:~ imac$ /dev/disk0s4
-bash: /dev/disk0s4: Permission denied
iMac-de-IMAC:~ imac$
Thank you very much for your comprehensive guide! It has helped me to get a triple-boot setup working (Mac OS X together with two different Linux flavours) which I had to install on a friend’s old MacBook according to the friend’s needs.
Some hints, maybe helpful for someone else:
I my case, the problem was not caused Mac OS X Lion, but by the swap partition which I had created before the two Linux OS partitions. My partition scheme was:
1: EFI Protective
2: MacOS X
3: Linux Swap
4: Linux flavour no. I (OS)
5: Linux flavour no. II (OS)
6: Linux /home partition (user data)
Only the first four partitions got listed in the MBR table, and so only Linux flavour no. I worked. The solution was easy: the swap partition does not need to be listed in the MBR. So I copied the data for Linux flavour no. I from MBR entry #4 to MBR entry #3, and added the data for Linux flavour no. II to MBR entry #4, both according to your guide.
Now everything is working correctly — rEFIt allows to select Mac OS X or Linux flavour I or Linux flavour II at startup.
Hi Jon,
changed partition size and lost Win7 bootcamp. Is it repairable?
Andrew
** Report for internal hard disk ***
Current GPT partition table:
# Start LBA End LBA Type
1 40 409639 EFI System (FAT)
2 409640 122479951 Mac OS X HFS+
3 122479952 123748879 Mac OS X Boot
4 143280128 490233855 Basic Data
Current MBR partition table:
# A Start LBA End LBA Type
1 1 409639 ee EFI Protective
2 409640 122479951 af Mac OS X HFS+
3 122479952 123748879 ab Mac OS X Boot
4 * 143280128 490233855 07 NTFS/HPFS
MBR contents:
Boot Code: Unknown, but bootable
Partition at LBA 40:
Boot Code: None (Non-system disk message)
File System: FAT32
Listed in GPT as partition 1, type EFI System (FAT)
Partition at LBA 409640:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 2, type Mac OS X HFS+
Listed in MBR as partition 2, type af Mac OS X HFS+
Partition at LBA 122479952:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 3, type Mac OS X Boot
Listed in MBR as partition 3, type ab Mac OS X Boot
Partition at LBA 143280128:
Boot Code: None
File System: Unknown
Listed in GPT as partition 4, type Basic Data
Listed in MBR as partition 4, type 07 NTFS/HPFS, active
Can you help me out with this?
*** Report for internal hard disk ***
Current GPT partition table:
# Start LBA End LBA Type
1 40 409639 EFI System (FAT)
2 409640 436441079 Mac OS X HFS+
3 436441080 437710615 Mac OS X Boot
4 437710616 476510975 Mac OS X HFS+
5 476773120 484586799 Mac OS X HFS+
6 484848944 488230911 Mac OS X HFS+
7 488493056 976773119 Basic Data
Current MBR partition table:
# A Start LBA End LBA Type
1 1 409639 ee EFI Protective
2 * 409640 436441079 af Mac OS X HFS+
3 436441080 437710615 ab Mac OS X Boot
4 437710616 476510975 af Mac OS X HFS+
MBR contents:
Boot Code: Unknown, but bootable
Partition at LBA 40:
Boot Code: None (Non-system disk message)
File System: FAT32
Listed in GPT as partition 1, type EFI System (FAT)
Partition at LBA 409640:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 2, type Mac OS X HFS+
Listed in MBR as partition 2, type af Mac OS X HFS+, active
Partition at LBA 436441080:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 3, type Mac OS X Boot
Listed in MBR as partition 3, type ab Mac OS X Boot
Partition at LBA 437710616:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 4, type Mac OS X HFS+
Listed in MBR as partition 4, type af Mac OS X HFS+
Partition at LBA 476773120:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 5, type Mac OS X HFS+
Partition at LBA 484848944:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 6, type Mac OS X HFS+
Partition at LBA 488493056:
Boot Code: Windows BOOTMGR (Vista)
File System: NTFS
Listed in GPT as partition 7, type Basic Data
fdisk: 1> print
Disk: /dev/disk0 geometry: 60801/255/63 [976773168 sectors]
Offset: 0 Signature: 0xAA55
Starting Ending
#: id cyl hd sec – cyl hd sec [ start – size]
1: EE 1023 254 63 – 1023 254 63 [ 1 – 409639]
*2: AF 1023 254 63 – 1023 254 63 [ 409640 – 436031440] HFS+
3: AB 1023 254 63 – 1023 254 63 [ 436441080 – 1269536] Darwin Boot
4: AF 1023 254 63 – 1023 254 63 [ 437710616 – 38800360] HFS+
Looks like you have all MBR slots filled with OS X drives. you will need to pick one to bump from the list and replace with the Windows 7 entry.
Thank you so much!
I am a 14 year old Korean boy and I tried to triple boot it with windows 8 and ubuntu. In my case, windows failed to boot. Thanks to this nice guide, I successfully managed to fix my computer without wiping the whole hd.
Your are awesome!!!!!!!
Hi Jon!
Awesome guide, very comprehensible and taught me a lot.
And yet there’s a huge problem:
I’m trying to achieve a triple boot with OSX Mavericks, OSX Snow Leo and WinXP.
As you state, the MBR can only have 4 entries/slots, plus the EFI Protective one should not be removed.
So I end up with my MBR being as this:
Partition Inspector:
*** Report for internal hard disk ***
Current GPT partition table:
# Start LBA End LBA Type
1 40 409639 EFI System (FAT)
2 409640 322059287 Mac OS X HFS+
3 322059288 323328831 Mac OS X Boot
4 323328832 360859647 Mac OS X HFS+
5 361121792 488396799 EFI System (FAT)
Current MBR partition table:
# A Start LBA End LBA Type
1 1 409639 ee EFI Protective
2 * 409640 322059287 af Mac OS X HFS+
3 322059288 323328831 ab Mac OS X Boot
4 323328832 360859647 af Mac OS X HFS+
MBR contents:
Boot Code: Unknown, but bootable
Partition at LBA 40:
Boot Code: None (Non-system disk message)
File System: FAT32
Listed in GPT as partition 1, type EFI System (FAT)
Partition at LBA 409640:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 2, type Mac OS X HFS+
Listed in MBR as partition 2, type af Mac OS X HFS+, active
Partition at LBA 322059288:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 3, type Mac OS X Boot
Listed in MBR as partition 3, type ab Mac OS X Boot
Partition at LBA 323328832:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 4, type Mac OS X HFS+
Listed in MBR as partition 4, type af Mac OS X HFS+
Partition at LBA 361121792:
Boot Code: Windows NTLDR
File System: NTFS
Listed in GPT as partition 5, type EFI System (FAT)
and fdisk printed this:
Disk: /dev/disk0 geometry: 30401/255/63 [488397168 sectors]
Offset: 0 Signature: 0xAA55
Starting Ending
#: id cyl hd sec – cyl hd sec [ start – size]
1: EE 1023 254 63 – 1023 254 63 [ 1 – 409639]
*2: AF 1023 254 63 – 1023 254 63 [ 409640 – 321649648] HFS+
3: AB 1023 254 63 – 1023 254 63 [ 322059288 – 1269544] Darwin Boot
4: AF 1023 254 63 – 1023 254 63 [ 323328832 – 37530816] HFS+
Please help me, how can I add the WinXP back to the MBR?
Or is it simply impossible to use those three OS on one harddrive?
Thank you SO so much in advance!
Yours OldGregg!
You are the man!! Thanks for this!
I had been trying to triple boot using Mavericks, Windows 8.1 Pro, and Windows 7. I was frustrated as I had triple booted my MacBook Pro in the past, but I was hitting my head against the wall on this one.
Your guide pushed me in the right direction.
I had 5 partitions listed using Partition Inspector and 4 of them were taken up in the MBR. In the MBR, OSX had 3 (EFI, OS, and Recovery), which had one left for Windows 8.
The fifth partition was Windows 7.
Since the MBR did not need a pointer for Recovery, I edited the MBR and overwrite the Recovery partition information with the Windows 8 info. I then overwrite the fourth entry with the Windows 7 partition info.
All is good now!
/dev/disk0
: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *320.1 GB disk0
1: Apple_HFS 10.9 32.2 GB disk0s1
diskutil mergePartitions “Journaled HFS+” “Mac OS” disk0s1 disk0
“The given partitions are not ordered sequentially on disk”.
THANK YOU. I’ve put over a dozen hours into getting this to work. You are a saint for posting this online. You truly have made a difference in my life, I was on the edge of despair. Thank. You. So. Much.
I had been working on this for days before I found this guide. It solved my problem in minutes.
Thanks a bunch!
I just wanted to say I followed your workaround to the letter and got my triple boot going with Mountain Lion, Windows 8 and Backtrack 5 R3. You are a lifesaver. Have a great day.