HOWTO: Linux on the Intel iMac - Triple booting

| |

Introduction - Why Macs?

I work as a System Administrator for a Computer Science Department and as a result I manage both server machines and lab machines. Some time ago the department decided (and I was in agreement) that it would be a good idea to offer the students additional variety in the computer lab by replacing some of the "Pee Cee" machines in the main undergrad lab with some Apple Macintosh systems. This would give students access to Mac OS X (pronounced "ten") in the lab in addition to Linux and Microsoft Windows.

Although Apple switched to Intel-based machines a few years ago, you can't just run their OS on any Intel/AMD machine as they have both licensing reasons and technical reasons why their OS should ONLY run on Apple hardware. They don't seem to be friendly to running Mac OS X inside of Virtualization either. Mr. Jobs, why do you hate us? I digress.

The first three years we had Macs in the lab they only ran Mac OS X and as time passed, fewer and fewer people used them. The usage slowdown was caused by a number of reasons that I'll not go into here. This year though, I decided not to give up on the Macs and to make them triple-boot... so if people don't want to use Mac OS X they don't have to, and the machines can get better utilization.

Looking for black magic?

Apple realized some time ago that people might want to dual-boot their new machines so they created Boot Camp. Indeed, Boot Camp does make it easy to dual-boot and they even give you all of the drivers needed to make Windows support their hardware... but what about triple-booting? Maybe someday the Boot Camp developers will implement triple-booting but for now it only supports dual-boot.

While Intel Macs are very similar to traditional PC machines there are a number of differences that make it challenging to setup a triple-boot scenario. The first thing is that they use an EFI type BIOS. The second thing is that they use a GPT (GUID Partition Table) type partitioning scheme rather than MBR. While GPT isn't as common yet, GPT is the wave of the future mainly because hard drive sizes are constantly growing.

I searched and searched for a recipe for triple-booting but most of the info I found was either outdated or for PowerPC based Macs. I finally found a HOWTO written by a fellow CS sysadmin that was both fairly recent and complete... although after doing it over and over I found a few points to refine and decided to write this.

Hardware I used

I did this recipe on two models of Intel iMacs:

  1. The 2006 Core Duo unit
  2. The 2009 Core 2 Duo unit

Although I only installed on two models of iMac, these intructions should work on any Intel-based Macintosh.

Reviewing the steps

  1. Repartitioning the hard drive to make room for additional OSes. This is complicated because of the GPT and the final solution has a hybrid GPT/MBR partitioning scheme.
  2. Installing a bootloader that understands the strange partitioning scheme needed that can actually assist.
  3. Installing the OSes and making them work well with the hardware.

Repartitioning the a hard drive

This is an easy step because Apple includes the tool you need. It is a command line tool named diskutil. To see how your hard drive is currently partitioned run the following command from the terminal.

diskutil list disk0

You should see three partitions: 0 = GUID_partition_scheme, 1 = EFI, and 2 = Apple_HFS Macintosh HD. Of course sizes will vary depending on what size hard drive you have. To repartition the hard drive you use the following form:

diskutil resizeVolume disk0s2 {#}G \
"MS-DOS FAT32" Linux {#}G \
"MS-DOS FAT32" Windows {#}G \
"MS-DOS FAT32" Swap {#}G

You'd replace {#} with the desired number of GBs you want the drive to be. In my case the iMacs I'm using have 320GB hard drives but some space is lost because of overhead. I settled on the following:

diskutil resizeVolume disk0s2 200G \
"MS-DOS FAT32" Linux 43G \
"MS-DOS FAT32" Windows 50G \
"MS-DOS FAT32" Swap 4G

Note that the last partition you make won't actually be what you told it to be as it will use whatever is left.

Why specifiy "MS-DOS FAT32" as the partition type? Well diskutil is nice but it only knows about a handful of filesystems and Linux and Linux swap aren't included. When we install Linux we'll edit the existing partitions and change them to ext3 and Linux swap. For the Windows install we'll also change the partition set asside for Windows to NTFS.

There is some debate on whether it is safe to issue the diskutil repartitioning command from a live system or not. Some recommend booting from the Mac OS X install media so that the disk/partitions you are working with aren't live. I haven't had any trouble doing it from a live system with the drive in use. Perhaps it is a matter of changes from Tiger to Leopard. I've only used Leopard based machines and haven't had any trouble as diskutil has been totally non-destructive with the commands I've used.

Your mileage may vary so if you have data you care about on your Mac, make sure to back it up completely before starting.

After issuing the diskutil command in the form mentioned above, it will verify the disk first and then repartition it. It usually only takes a few minutes.

Installing a bootloader

Download rEFIt and install it. rEFIt is a fantastic bootloader and I wish the bootloaders we have for Linux were as fancy. rEFIt is not only a bootloader but it is smart and looks at the partitions and automatically makes entries when it finds an OS. It also assists in partitioning because it helps construct and maintain the needed GPT/MBR hybrid partition table. After installing rEFIt make sure to run the /efi/refit/ script so that the rEFIt bootloader will always appear rather than requiring holding down a key on the keyboard during power up.

Now that the bootloader is installed properly, reboot.

Syncing the partition table

One of the rEFIt features and an option on the rEFIt menu is "Start the Partition Tool". Any time you change the partition table select "Start the Partition Tool" from the rEFIt menu. It will let you create and manage the needed hybrid GPT/MBR partition table. Since we recently repartitioned the hard drive with the diskutil command you want to "Start the Partition Tool". Once back at the rEFIt menu, select "Reboot". I don't know if rebooting is technically required after running "Start the Partition Tool" but it seems to avoid some minor issues so I recommend it.

Installing Linux

I'm a big Fedora user and I recommend it. The Fedora 11 LiveCD media require three Linux partitions -- an ext3 /boot partition, an ext4 / partition, and a swap partition. You will notice from the diskutil command line I used above that I only made two partitions for Linux (one for / and one for swap). As a result you CAN NOT use the Fedora LiveCD media. In my early testing I tried making three partitions for Linux but either I made a mistake or it simply won't work. As a result I settled for having two partitions. So, to install Fedora 11 you'll need to use the DVD install media although the minimalistic netinstall media might work, I haven't tried it.

Put the install media into the optical drive and reboot. You can either hold down the c key on the keyboard to tell it to boot from the optical drive, or you can select the icon for the install media that shows up on the rEFIt menu. Please note that rEFIt reads all of the drives/partitions before showing the menu and will not refresh if you put in a CD/DVD... so if you put the install media in at the rEFIt menu, you'll have to reboot for it to see the media. I wish that rEFIt had an option to rescan for optical media insertion as well as a feature to eject inserted media... but it doesn't.

I'm not going to cover all of the install steps but just know you want to pick custom disk setup, select the first MS-DOS partition, edit it to make it ext3 and mounted on / and make sure to select the format option. Edit the last partition and make it Linux swap and format it. Also when it comes to the grub install screen make sure that it installs the grub bootloader to /dev/sda3 rather than the MBR of the drive. The install should proceed normally. When done reboot.

Since we changed the partitions some during the Linux install, at the rEFIt menu select "Start the Partition Tool" again to sync the partition table. Then reboot. Linux should be functional now.

Installing Windows

I used a Windows XP Pro SP3 install CD. I recommend that you find install media that has Service Pack 3 already installed because during my testing I used SP2 media and had a problem with it. Windows will install fine but in order to have a fully functional and more secure Windows you have to install all of the updates... and before the network card will work you'll have to install the Boot Camp drivers (located on your Mac OS X install media). After installing the Boot Camp drivers I was unable to get Service Pack 3 to install. It always gave me an error about there not being enough disk space for the SP3 update even though there were tens of GBs of free disk space. While there may be a way around using SP2 media and getting the SP3 update to install, it just seems to go more smoothly if you use install media that already has SP3 installed. Supposedly Vista works fine (and probably Windows 7) but I haven't tried them.

Boot the Windows install media just like you did the Linux install media. Install Windows just like you normally would as I'm not going to cover the normal installation steps. The only difference is that you need to make sure you select the remaining MS-DOS partition as the target and format it as NTFS. I've always selected the NTFS Quick format option. If you want, I guess you could format it as FAT32 but I don't recommend that unless you have a good reason to do so.

Anyone who has installed Windows knows that it is a two stage/boot process. The first stage lets you pick the partition, format it, and then copies all of the data files it needs to the hard drive. Then you have to reboot to the second stage where it actually has a GUI interface and installs everything... and of course, asks you for the license key. When the machine reboots you'll get the rEFIt menu as usual. I find that it is a good idea to "Start the Partition Tool" and reboot even though it tells you nothing has changed. It seems to go better that way although maybe I'm just imagining it. I have had a few occasions where the second pass refused to boot on the first attempt and it ended up just sitting at a black screen. I just cycled the power and tried again and it worked.

After the second stage is done and it reboots, again from the rEFIt menu select "Start the Partition Tool" and reboot. Again, it may or may not be required but it seems to avoid little quirks.

After installing Windows the first thing you want to do is install the Boot Camp drivers so all of your hardware works properly... especially the NIC... so the next thing you can do is install the remaining Windows updates.


With both Linux and Windows installed and rEFIt bootloader letting you easily pick between Mac OS X, Linux and Windows, at boot time... the job is all done.

The instructions I give above I've used at least a half dozen times on a half dozen machines and it has always worked for me. As Mac hardware changes and updates to Mac OS X happen... and depending on what Linux distros or Windows versions you use... the recipe might need slight modifications for your tastes. Please feel free to provide feedback in the comments so we can keep this information as up-to-date as possible.

I would like to offer up a big "thank you" Ashley AT for the original HOWTO that educated me enough on the process to do my first successful triple-boot install.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Triple booting, Mac OSX, WIndows 7, Ubuntu

I am using an iMac, to which I added Windows 7 through Bootcamp. I also installed rEFIt and they all worked happily together. I even have a disk image backup of my iMac on an external disk and rEFIt sees it and can boot from it.

Today I installed Ubuntu on the same system. rEFIT sees the Ubuntu install as well as all the others that existed before Ubuntu. However now when I start either Windows 7 or Ubuntu I am taken to the Grub Boot Loader and presented again with all the OS's on the system. from there I can start both Windows or Linux. Obviously it is annoying going through 2 boot-loaders to load either Windows or Linux. How do I get rid of Grub and have rEFIt go directly to Windows or Linux (as it does for Mac) instead of going through Grub?

Thank you in advance.

Scott Dowdle's picture

Two bootloaders?

I don't know of any way to make the second bootloader go away but you can modify its config so you don't see it and it automatically loads the default OS. Just edit your menu.lst in /boot/grub/ (I think that is where it is in Ubuntu) and make the timeout=0 and/or add a hiddenmenu line.

There is actually a third bootloader and that is for Microsoft Windows. Which you pick Windows from rEFIt's menu, control passes to the Windows partition which also has a bootloader but it doesn't display itself as such so it's like it isn't there but it is. The hint in the previous paragraph mimics the same behavior.

Scott Dowdle's picture

Re-imaging and fixing the MBR

While the main article explains how to setup your Intel iMac to triple boot, it does not explain how to maintain the setup over time... with re-imaging of the Linux and Windows partitions. Here's how.

I use Clonezilla for partition imaging of the Linux and Windows partitions. For example since writing the main article I've switched from Fedora 11, to Fedora 12, and now to Fedora 13.

Linux Post-install tips

When making your image for Fedora make sure to remove any machine specific identifiers related to the hard drive or networking. To do this I usually edit the following files and remove UUID references or MAC references:

(remove drive UUID reference and replace with /dev/sda#)

(remove drive UUID reference and replace with /dev/sda#)

(remove hostname if present)

(remove hostname if there)

(remove MAC address if present)

(remove MAC address if present)

Using Clonezilla to save and restore partitions

I'm not going to give you step by step instructions on using Clonezilla, you should already be familiar with it. For imaging the Linux and Windows partitions you have to use partsave and to restore them use partrestore. Do not try to image the entire drive because, so far as I know, Clonezilla does not completely understand the Mac disk layout and the Mac partitions.

Making Linux bootable again

After re-imaging sometimes grub bootloader is broken on your Linux partition. How do you fix it? It's easy. I just boot up with the Fedora netinstall media. Make sure you use the media for the arch you are using (x86_64 for me). Select rescue mode from the CD boot menu. Then once booted you do what you do on a traditional PC:

  1. Hit enter through the prompts until you get a shell
  2. cd /mnt/sysimage
  3. chroot .
  4. grub-install /dev/sda3

How to reset the Mac GPT MBR

If for some reason you make a mistake and install grub on /dev/sda (the MBR) rather than /dev/sda# you are going to have two Linux icons show up in the reFIT menu and the first one won't work. How do you get rid of it? Simple.

  1. Boot into Mac OS X
  2. Open a terminal
  3. sudo fdisk -u /dev/disk0

That will prompt you to rewrite the GPT MBR so answer y.

Now reboot and your reFIT menu will only show one Linux icon and your system will be back to normal.

* Please note that any reference to /dev/sda# you should replace # with your specific partition number. In the main article the example given is /dev/sda3

OSX 10.6.3 CentOs 5.3 Mac Pro

I've followed your directions to try to get my new Mac Pro to dual boot. I couldn't use the diskutil command to repartition the disk. The rEFIt screen shows a Linux partition, but it never boots. I get a grayed out penguin and that's all. I booted into "Linux Rescue" mode and modified the /etc/fstab, /etc/grub.conf file to remove the "LABEL" entries. I then recreated the initrd, but none of this makes any difference.

Scott Dowdle's picture

Snow Leopard?

So, was this with Snow Leopard or Leopard? I did the recipe on two different models of iMac and Leopard. I haven't tried Snow Leopard yet but hope to over the summer. I know the rEFIt developers came out with an update.

I wonder why diskutil doesn't work for you? If you couldn't use it, how did you repartition your dive? If diskutil doesn't work, that's Apple's problem because that is their software and not a third-party's.

I don't have any advice at the moment because as I said, I haven't tried Snow Leopard yet.

Mac Paritition lost after rEFIt install

I installed rEFIt on a 4 day old 27 inch iMac so that I can install Linux as the third OS. I had already installed Windows 7 as the second OS using boot camp. Just before the rEFit install, I also shrinked the Mac partition by 20GB to create some free space for the Linux. Let me also mention that I am only 4 days old in the Mac world.

When I restarted after installing rEFIt, it booted directly into Windows. Since rEFIt apparently needs two reboot to find itself, I rebooted again, and again found myself in Windows. Upon checking from the Windows Disk management, I can see the 200MB GPT partition, the Macintosh HD partition and the Boot camp partition. I can also access the Macintosh HD partition as E drive from the Windows side.

Looks like the partitions are fine, but the MBR seems to be corrupt. The rEFit install should have cleanly replaced the Mac MBR. But that hasn't happened.

If I press option while booting, it gives me only one OS choice, Windows. The iMac doesn't recognize the Mac partition for now. Therefore, I tried the repair option using disk utility in the OS X install disk. That utility isn't even capable of deciphering the partition info, it thinks it is a MSDOS partition. When I clicked on repair, it gave up saying it can't repair the partition.

Tomorrow is going to be a long day. I hope can can recover the Mac partition without having to re-install. I am finding no way to boot into Mac OS X for now although the partition look healthy and I can access all the Mac partition files from Windows 7.

Scott Dowdle's picture


I don't really have any advice for you. I didn't use boot camp at all... (not as a partitioner anyway) so I'm guessing you did things a little differently than I did.

If you end up totally reformatting the system, I recommend you follow my howto as much as possible (varying the partition sizes of course) and I expect you'll have more lucky.

Oh, one more thing to mention... when I talk about swap in my howto, it doesn't actually work... because when Linux boots it can't see the partition. What I ended up doing is making a swap file on the / partition and then adding it to the /etc/fstab. So, to save some disk space, you can ignore the parts about making swap and manually make a swap file post-install.

triple boot snow leopard, fedora 12, Windows 7 imac

I sure hope this guide still works because I'm getting ready to do it. Currently I have Sl, W7 on a bootcamp partition. I tried to shrink my mac partition with Drive Genius to try and set up fedora, but it wouldn't let me because of windows. So this guide seems to make the best sense of it, my previous logic may not have worked anyway. I guess fedora 12 would install grub. Well, wish me luck.

Scott Dowdle's picture

Haven't tried it yet

Please let me know if it works for you!

I haven't refreshed my lab yet but I plan to either over the Xmas break or over the Summer break.

Installing Vista

For those of you that would like to install Windows Vista, here are the details on how I got it to work properly. I had to work around a problem where the Vista installer said, "Windows is unable to find a system volume that meets its criteria for installation".

1. Boot from Vista DVD.
2. Delete the partition you created for use with Windows.
3. Create a new partition in the exact spot that the old partition was in the list.
4. Format the partition.
5. Type SHIFT + F10 to get a command line.
6. Type "cd \windows\system32" then "diskpart.exe"
7. Type "select disk=0" (this assumes that you have one disk).
8. Type "select partition=2" (this assumes that your Windows partition is the first partition after the 200 MB EFI partition).
9. Type "detail partition". You'll notice that is says, "Active: No".
10. Type "active" then "detail partition". You should see "Active: Yes". Then type "exit".
11. Hit the blue Back arrow towards the upper left-hand corner, then click the Next button and select the partition you just made active.



I seem to have approached this all wrong, for instance only reading the instructions when it went wrong;))

XP would not install cleanly, went onto the Hard Drive but never rebooted and completed install.

Vista I got installed using BootCamp and its 12 pages of help. Well it is in and working eventually.

Then I go into OSX and install rEFIt.

So I have about 600 gig for OSX and 333 gig for Vista.

Using Vista disk mangement I shrank the partition by about 106 gig. Formatted it and...

I have yet to re-boot and see if rEFIt and OSX are comfortable with that.

Vista shows C: Vista 324Gb, D: 600GB MacIntosh HD, F: 106Gb Linux_Area. With a couple of small unused parts.

Hopefully more later;))

Scott Dowdle's picture

Windows Vista is dead... Windows 7 killed it

We have MSDN AA at work and I've had access to the final release version of Windows 7 Pro for about two months now.

I've installed it in a KVM VM and it works pretty well... and totally blows the doors off of Vista. Really.

In fact, a co-worker claimed that he tested a computationally heavy application on a particular job that takes over 20 minutes on Windows XP and it only took 9 minutes with Windows 7 on the same exact hardware. I didn't see it in person but that is what he is claiming.

I agree that windows 7 is drastically better

Windows7 is a new benchmark for Linux. I had initially thought that Vista would be a motivator for linux to make a run for the desktop and that turned out to be somewhat true. The only problem was that they(we?) only had to beat vista! That is setting the bar pretty low. Windows7 is a very nice system and should drive Linux to create even better stuff!

Another member of this list and I were is some Microsoft Training this last week and got to have a heated discussion with the instructor about OSS vs Microsoft. I think we won that one :) We even had 3 blue screens on the training workstations in class.

Only Two Partitions for Linux

"In my early testing I tried making three partitions for Linux but either I made a mistake or it simply won't work."

I tried this using three partitions for an install of CentOS 5.3 and it wouldn't work. So I'm guessing you didn't make a mistake, but rather there's a problem with either rEFIt having too many slices (I had 6 slices) or grub booting from that specific slice (I think it was slice 3 on my disk). It's really not a big deal to give linux 2 partitions when you're dealing with a workstation, so no biggie.

Thanks for the great tutorial!

re: partitioning the HD

what about gparted?


You can resize and renature Mac partitions using Acronis. Might be a bit simpler. Also avoids having to run the Apple tool on a live hard drive.

Nice article. Thanks for the tip about the bootloader, have to check it out.

Scott Dowdle's picture

Acronis what?

What Acronis product are you referring to?

Just to clarify, I didn't have any problems at all on 6 different systems, with running the diskutil on a live system. If I was concerned I could have easily taken a little extra time and booted from the Mac OS X install media (as mentioned in the article) and run diskutil from there.

I'm looking for some software that will aid me in disk/partition imaging/cloning so I can get one machine setup just perfect and then duplicate that to all of the Macs in the lab. So far I haven't found anything. I checked out Symantic Ghost (or whatever they are calling it these days) as well as Acronis products... and none of their online literature mention compatibility with Mac. The listed filesystems included various Windows and Linux filesystems but not HFS. I did not look at every Acronis product offered so perhaps one of their products do offer some sort of Mac compatibility but not their imaging product.

If anyone has a good recipe for cloning Mac disks for this triple-boot setup, I'd love to hear about it.

Scott Dowdle's picture

Alternative to Fedora DVD install media?

Just wanted to mention that after verifying that the Fedora DVD install media worked fine, I decided to rebuild my MontanaLinux LiveDVD remix of Fedora 11 but altered it to have an ext3 / filesystem. This ended up saving me a lot of time on later Intel iMac Linux installs because the remix has all of the updates applied (and there are thousands since the release of the original media) and has all of the software (some third-party) installed that I like.

Changing the / filesystem from ext4 to ext3 is as easy as replacing the number 4 with a number 3 in the fedora-live-base.ks file:

part / --size 6000 --fstype ext4
part / --size 6000 --fstype ext3

Of course making that change means you can't take advantage of the newer ext4 filesystem but given the fact I'm using rather small hard drives, it is an easy compromise.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.