How-to: Triple boot a Mac with Windows and Linux
Volume Number: 22 (2006)
Issue Number: 11
Column Tag: Triple boot
How-to: Triple boot a Mac with Windows and Linux
by Criss Myers
Preface
Apple Mac's migration to Intel's X86 Architecture in January 2006 presented a unique opportunity that, in theory, enabled any X86 OS, be it Solaris, Unix, Linux or Windows to run on Apple Macintosh hardware. Finally the barriers between Linux, Mac and Windows were broken down as each could be run natively on the same machine, allowing a like-for-like comparison of OSes and hardware.
Architectural differences between Apple's X86 machines and other X86 machines
There are, however, a few technical issues that need to be overcome to enable a Mac Intel machine to be dual or triple booted.
Firstly, Mac uses the Intel Core Duo chip which uses Intel's advanced EFI (Extended Firmware Interface) to boot the operating system, a system already used by Intel's Itanium systems and far more advanced than the much outdated BIOS developed in the 1980s. Microsoft's Windows XP and their Future OSes such as the long awaited Vista will not use EFI for some time. In April 2006 Apple launched a Firmware update to EFI for all Mac Intel Machines that allows the EFI's in-built chooser to see Windows legacy bios boot sectors and boot them. An open source project called rEFIt can see all legacy bios sectors and identify them as either Windows or Linux and even recognize boot sectors on external drives as well. This project can be either installed onto the Mac OS partition, and blessed so that it can be the default boot partition, or burnt on to a CD and booted from there. There is also now a "Start up Item" which keeps rEFIt active across Mac OS X updates and prevents problems with Safe Sleep.
Secondly, Apple opted to use the more advanced partition table called GPT (GUID partition table) as opposed to MBR (master boot record) that most other OSes use. Windows XP, Vista and RedHat Enterprise Linux use this MBR, the problem is therefore that these OS's will not be able to read or mount the partitions if the Mac hard drive is formatted as GPT. OS X is not able to read MBR tables. From release 10.4.5, Apple's Disk Utility can format and create both MBR and GPT but not both together. Windows partition tool can only create MBR, Linux's fdisk can only create MBR and Linux's Parted (alternative partition tool) can only create GPT. Therefore a Mac machine can be formatted for single boot of OS X 10.4.5, Windows XP SP2 or a Linux/Unix distribution, but to create a GPT / MBR dual boot machine would be a problem. To solve this problem Apple updated their Disk Utility in OS 10.4.6 to create a GPT table and then mirror it to an MBR table, so that both OS's could read it. They incorporated this into their BootCamp beta, which will later be incorporated into OS 10.5 Leopard.
Apple created BootCamp to enable the installation of Windows XP on to a Mac as a dual boot setup. BootCamp firstly creates a Windows Driver CD for the particular hardware it is running from, then it allows the user to partition the Mac hard drive into 2 partitions without reformatting the drive (via a GUI to the command line diskutil). It then reboots the Mac from the Windows XP SP2 disk. BootCamp can also restore the drive to a single partition again.
A Mac machine cannot be dual or triple booted straight out of the box. Some of these technical issues, however, have been solved by Apple in response to the customers desires to dual boot their Macs. There are also a few Linux distros that have been adapted to work on Mac Intel, such as Debian and Ubuntu. However until the next version of RedHat Enterprise Linux is released there is no current version adapted for Mac Intel.
So to dual boot a Mac for OSX Tiger and Windows XP is easy, Apple has done all the work and created all the tools to do it, the problem comes when you need to triple boot.
There are plenty of resources online to guide you through dual booting a Mac with OSX and Windows XP, Apples BootCamp section of their site has lots of information.
<http://www.onmac.net>
<http://www.maconintel.com>
<http://fedoraproject.org/wiki/FedoraOnMactel>
All of these have information on dual booting a Mac, but very limited information on triple booting.
As pointed out by the fedora project:
"Right now, we've only tested Dual Booting with OS X. If you want to Triple Boot, you're going to have to do some investigation on your own."
There follows a step-by-step guide to triple booting a Mac Intel with any distribution of Linux.
Hardware and Software Required
Here are the items we need to accomplish this:
This guide presumes that the reader will have a basic knowledge of Linux, the command line, and how to boot from non Mac install CDs.
Step 1: Preparation
Install 10.4.5 that came with the Mac, connect it to the internet and download the following from the above links :
Firmware update for your particular model. NOT the SMC update.
Download the following files and them burn to CDs:
- Ubuntu LiveCD
- Linux - I am using RedHat Enterprise Linux 4, Disks 1-4
- rEFI Tools 0.7 ISO
From the Linux install disk 4, copy lilo.rpm to the USB pen drive.
Install any required firmware update, then install 10.4.6, do not install 10.4.7 otherwise you will not be able to install the Keyboard Update. Install the Keyboard Update, which will prevent the Keyboard from being unresponsive when booted from the Linux CDs.
We will now create an XP Drivers CD. To do this, install BootCamp beta and then create the drivers CD for your particular hardware from the BootCamp menu. If BootCamp doesn't recognize your Firmware update, Apple suggests you install 10.4.7 Combo or reinstall BootCamp.
Step 2: Creating a working Linux system
We are now ready to begin the triple boot process. Even though we can partition the drive into 3 partitions we cannot install Linux directly onto the second partition. This is due to the fact that when we partition the drive it will create a GPT record and an MBR mirrored record. Windows XP will simply ignore the GPT record as it has no understanding of what a GPT record is. RedHat Linux's installer Anaconda, however, is more sophisticated and will recognize the GPT record, but because it cannot install onto a GPT drive it will then try and reformat the drive. This maybe a problem with many other distributions of Linux and Unix. As we know that the only formatting tool that can support both MBR and GPT together is Apple's diskutil we have to format the drive under OS X. We will work around this problem as follows.
Boot the Mac from the Linux install CD1 and when asked to partition the drive do so manually and create a single root "/" partition with the same size as that which you intend to use for your final setup. I am using an 80GB hard drive so I will use 15GB for Windows, 15GB for Linux and the remaining for OSX, this means I will create a 15GB root partition which will be called sda1 (Mac Intels use Serial IDE drives so they get the names sda1, sda2 etc rather than hda1.) Do not create any logical volumes or swap partitions.
When prompted, do not install any boot loader, as we cannot use GRUB on Mac Intels: it will hang at Stage 2 of the boot process. LILO is the only boot loader that works. LILO is not a default option under RedHat's Anaconda, and therefore, we will install the bootloader later. If your distribution of Linux allows you to install LILO then install it on to the root partition not the MBR, finish the installation and skip the next part and go straight to rebooting from the rEFIt disk.
Install the rest of Linux to your requirements as per normal.
We will now install LILO. Boot the Mac from the Ubuntu LiveCD, connect the USB pen and copy lilo.rpm from the USB pen drive (sdb1) to the Linux partition sda1. Reboot from the Linux install CD and enter the rescue mode, chroot to /mnt/sysimage, then install the LILO RPM. Reboot again from the Ubuntu LiveCD, mount the Linux partition /dev/sda1 as mnt/linux and create the following LILO configuration file in /mnt/linux/etc/lilo.conf :
boot=/dev/sda1
map=/mnt/linux/boot/map
install=/mnt/linux/boot/boot.b
default=Linux
LBA32
image=/mnt/linux/boot/vmlinuz-2.6.9-34.EL
initrd=/mnt/linux/boot/initrd-2.6.9-34.EL.img
label=Linux
root=/dev/sda1
read-only
Install LILO with the following command :
/mnt/linux/sbin/lilo -C /mnt/linux/etc/lilo.conf -v
You should get confirmation of the LILO install without any errors.
For RedHat Enterprise users, change the fstab file in /etc , the first part of the first line should be changed from:
LABEL=/
To:
/dev/sda1/
Reboot the Mac from the rEFIt boot CD and you should now get the Linux partition as a boot option.
We now have a single boot Linux Mac, we will transfer this data onto an external drive for later use.
Boot the Mac from the Ubuntu LiveCD, mount an external DOS formatted USB drive. Copy the raw data from the Linux partition to this drive as follows :
dd if=/dev/sda1 of=/dev/sdb bs=512
This will take sometime. Many, many long hours, so go make a coffee.
Step 3: Install OSX and Partition the drive
Reinstall OSX from the install DVD that came with the Mac as per normal, creating 1 standard partition. Connect to the internet and run software update to install all the latest updates, this will install 10.4.7.
GPT supports up to 128 partitions, but MBR can only support 4 primary partitions, and GPT cannot read extended / logical partitions. Windows XP wants to install only on to C:\ which is the last partition, and the first partition will be the EFI boot partition, therefore there are only 2 left, 1 for OS X and 1 for Linux, thus you cannot create a Linux swap partition. This should not be a real problem.
Boot camp can only make 2 partitions, so we need to run the diskutil command via terminal to create the new partitions.
The following command will repartition an 80GB hard drive (disk0s2) into 15GB for Windows, 15GB for Linux and the remainder for OS X.
diskutil resizeVolume disk0s2 44.2G Linux RedHat-EL 15G MS-DOS WindowsXP 15G
Step 4: Install Windows XP
Boot from the Windows XP Service Pack 2 Install CD. Install Windows XP as usual on to C:/ (the fourth partition). Apple recommends that you format as Fat32 rather than NTFS but I have had problems with both formats. If you format as NTFS you will not be able to write to this drive from within OS X.
Reboot into Windows XP, insert the drivers CD and install, then most of the hardware will work under XP. You now have a dual boot Mac.
Step 5: Install Linux
Boot from the Ubuntu LiveCD, mount the USB external hard drive and copy the Linux system back to the third partition, sda3,as follows :
dd if=/dev/sdb of=/dev/sda3 bs=512
Once transferred we will need to make minor changes to the LILO bootloader and the file system table fstab, so that we can load Linux from sda3 rather than sda1 as previously.
1. Edit the fstab file and change sda1 to sda3.
2. Edit the LILO configuration and change sda1 to sda3.
3. Install the new LILO configuration with the following command :
4. /mnt/linux/sbin/lilo -c /mnt/linux/etc/lilo.conf -v
5. Reboot from the rEFIt CD, select the Linux partition and it should load normally.
You now have a working triple boot Mac running OS X 10.4.7, Windows XP SP2 and RedHat Enterprise Linux 4. These will all run normally as if they were running from any standard X86 hardware. You can either boot using the rEFIt CD or you can install it onto the Tiger partition. Then each time you boot you can select the appropriate OS, or wait for it to time out and boot into OS X.
Conclusion
In this guide we installed RedHat Enterprise Linux but the same process should work for any version of Linux booted via LILO, the same should also work for Solairs and Unix but may need tweaking to resolve the change in bootup from sda1 to sda3.
Criss Myers is a Senior Mac IT Technician for the Faculty of Science and Technology, at the University of Central Lancashire, Preston, United Kingdom. He has been a Systems Server Administrator from the very first version of OS X Server. He Works with Macs as well as Linux, Unix and Windows.