2012-04-13

Setup a triple-boot Mac with Mac OS X, Windows and Ubuntu

This article describes a way to setup a triple-boot Mac with Mac OS X 10.7.3, Windows 7 and Ubuntu 11.10. As an addition to that I will write another post on how to reuse the Ubuntu partition in VMware Fusion in Mac OS X.


rEFIt Bootloader
(taken from refit.sourceforge.net/screen.html)

I did this on my MacBook Pro from late 2011, but it was hard for me to gather all the necessary information on the web in order to reach my goal of a triple boot Mac (Mac OS X, Windows 7, Ubuntu) with the possibility to reuse (at least) the Ubuntu partition in a virtual machine using VMware Fusion under Mac OS X.
I've read a lot of forum and blog posts, but unfortunately most of them are outdated or not complete. After I had setup everything successfully (that took some days!), I decided to write it down in this blog to make it easier for other people who want to do the same thing.




UPDATE - Sept 2012

There seems to be another, pretty easy way to setup a triple-boot mac without using any additional bootmanager! Please see my new post about this here.





I hope that I can remember all the steps I did because it was a lot of trial and error. But I tried to write down some notes about the important things. Unfortunately I can't provide a lot of screenshots and I don't have the time to do the whole thing again. I'm sorry.


What you will need:

  • Windows installation DVD
  • Ubuntu installation DVD AND live USB stick (both are necessary because of a strange boot bug/problem when booting the ubuntu live system on a Mac)
  • some time ;-)



First of all, please make a backup of all your data (e.g. with Time Machine)!


Also make a backup of the hybrid MBR of your disk using gdisk for Mac OS X.

To do that: 

  • run "sudo gdisk /dev/disk0"
  • in the disk menu, enter "b"
  • enter a filename for the backup file (it will be saved in your home folder)
  • enter "q" to quit gdisk


Now, let's start...


1. Create additional partitions for Windows, Ubuntu (and rEFIt)


I created three additional partitions using the Mac Disk Utility: One for windows, one for ubuntu AND one for the rEFIt bootloader (please see my note about the new project called "rEFInd"!!!).
The last one is necessary because somehow it's not possible to install rEFIt in the normal way on the Mac partition if you use Mac OS X Lion! But it's possible to install it manually on a separate partition. To boot from that partition later you can hold down the "alt" key on startup (like I do) or you can bless the partition so that the MacBook Pro automatically starts from that partition when you turn it on (see this forum post).

CAUTION:
There are already 3 partitions on the disk: An EFI partition, the Mac partition (that's the only one you see in the Disk Utility) and a recovery partition.

IT'S REALLY IMPORTANT THAT THE WINDOWS PARTITION IS THE 4TH PARTITION!!!
Otherwise there will be an error during the windows installation.

I think this is because Apple boots the DVD in a BIOS emulation mode (and it wasn't possible for me to boot it in EFI mode). Windows isn't able to install to a disk that uses a GPT instead of a MBR (actually we have a hybrid MBR here) unless the installation DVD is booted from EFI. And because a MBR can only handle four primary partitions and there are already three other partitions on the disk, the windows partition has to be the first one after the recovery partition.


To achieve the right order, I created the partitions as follows:

  1. the rEFIt partition (HFS+, 1,07 GB - that was the minimum possible size)
  2. the Ubuntu partition (FAT32, I chose 80 GB)
  3. the Windows partition (FAT32, I chose 115 GB)

diskutil list /dev/disk0 returns something like this:












(I don't know why some labels are missing now, it renamed the Windows partition to "BOOTCAMP" after I installed the BootCamp drivers for Windows. Partition 2 is my "Mac HD", 4 is the Windows partition and 5 the Linux one)



2. Install rEFIt


After I had created all the partitions, I installed rEFIt to the last partition (disk0s6). To do this, I downloaded and installed rEFIt manually according to the instructions in the rEFIt documentation:
Simply copy the "efi" folder and the "rEFIt.icns" file to the partition and run the "enable.sh" script. (I think I had to change the permissions of the "efi" folder to run the script successfully).

To test if the installation succeeded, just restart the Mac and hold down the "alt" key. You will see a new disk entry in the Apple bootloader with the label of the rEFIt partition ("rEFIT"). After selecting this one, the rEFIt bootscreen should show up.

(If you want your Mac to automatically boot from the rEFIt partition, follow the instructions in this forum post.)



3. Install Windows 7


Just insert the Windows installation DVD and start the Mac while holding down the "C" key (or boot it from rEFIt).
In the installation, make sure to select the right partition and format it to NTFS.

Every time windows wants to reboot during the installation, boot to rEFIt and select the new Windows icon there to start it from your harddisk.

After the installation is complete, install the BootCamp drivers for Windows.



4. Install Ubuntu 11.10


There is a problem when starting the Ubuntu 11.10 installation/live system from a DVD or USB stick: The boot process stops at some point and complains about a missing live file system. This only happens on a Mac.

As a workaround for that, I inserted the installation DVD and the USB stick and started the Mac while holding down "C".

In the installation process, select the "advanced installation option" and select the created linux partition, format it with ext4 and set the mount point to "/".

Install the GRUB bootloader directly to the linux partition (I think in my case it was "/dev/sda4").



5. Fix the hybrid MBR


After the installation of ubuntu is complete, it's not possible to start ubuntu (or even windows) with rEFIt anymore. That's because the hybrid MBR doesn't have enough slots for all partitions (the ubuntu one would be the 5th), you need to create a new customized hybrid MBR.

At this point maybe it's also possible to just run the Partitioning Tool  from the rEFIt bootloader to sync the GPT with the MBR, but I didn't try that.

To create a new customized MBR I rebooted to Mac OS X and followed the instructions from this forum post. There are also two screenshots there which are very useful!

The author of that post wrote:
"In order to fix this we are going to create a new hybrid mbr table. i have attached screenshots of this process.
reopen terminal and again type 'sudo gdisk /dev/disk0'. this time enter 'r'. and then 'p'. this will print your partitions. now you need to create your hmbr so type 'h'. it will now ask you for the partitions you wish to enter. referring to the printed partition list, add your lion, windows and linux partitions. (in my case 2 4 5). next it will ask you to place efi partition first, select 'y'. now it will ask you for the mbr hex code for each partition. the codes you want are 'AF' for lion, '07' for windows, and '83' for linux. don't set any of the bootable flags. once finish enter 'w' to write these changes to the disks. You can also enter 'q' if you want to quit without saving changes. reboot and now you should be able to boot into each of your OSes."

That worked for me! :-)


Now you have a triple-boot Mac!
If you just start your Mac the normal way, it will directly boot to Mac OS X and if you start it while holding down the "alt" key, you can select the rEFIt partition to boot to the rEFIt bootloader.



In addition to that:

If you also want to use the Ubuntu partition in VMware Fusion under Mac OS X, please read my second post.



Since the rEFIt project seems not to be maintained anymore, there is now another project called rEFInd which is a fork of the rEFIt project (developed by the author of gdisk)!





5 comments:

  1. What if I already have a set up system as such: Refit with OSX 10.6.8, Win7 64bit, ubuntu 12.4 64bit.

    Is there a way to modify your instructions so I can upgrade to 10.7 without losing all my hard work. I can back up data, but I don't want to start over. I'm not sure what order the partitions are in.
    Any advice would be great--Thanks!

    ReplyDelete
  2. I've never had Mac OS X 10.6 (it's actually my first Mac and it already came with OS X 10.7 Lion). So I'm not sure if I can give you any helpful advice.

    But I think these are the main differences that may be important:
    - rEFIt doesn't work on the Mac partition under OS X Lion (that's why I installed it to ta separate partition). But you can check out rEFInd, the link is above at the end of my post.
    - OS X Lion uses an invisible recovery partition (at least on pre-installed Macs). So I think you will also have to fix the hybrid MBR as I described in step 5 and perhaps you won't be able to boot to the recovery partition afterwards, depending on if you need a separate rEFIt partition or not

    I hope this information was useful for you!? ;-)

    ReplyDelete
  3. this method is better, no need for refit or refind

    http://www.youtube.com/watch?v=O40UG1guLeo

    ReplyDelete
  4. hi...Im student from Informatics engineering nice article,
    thanks for sharing :)

    ReplyDelete
  5. Hi Dear,

    i Like Your Blog Very Much..I see Daily Your Blog ,is A Very Usefull For me.

    You Can see Graphene Earbuds, Triple Drivers, special earbuds.

    Our company, Grande Technology Co., Ltd. was founded by several music lovers and sound engineers. Our company is established in 2007, and AUDBOS is our brand. We strive hard to achieve excellence, specialize in creating better quality. AUDBOS headphone provides better sound than other similar products. We are not afraid of challenges of innovation; we are in pursuit of customers’ expectation of sounds. Working beyond customers’ imagination is our goal, and constantly self-transcendence. To bring customers better quality of sounds than you expected. AUDBOS is always good sound.Get the best sound and invest in our range of in special earbuds, the highest quality at the lowest prices only at audbos.com.

    Visit Now - Triple Drivers


    ReplyDelete

Copyright

Creative Commons License
All the content in this blog is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.