Dual Booting
From Mactel-Linux
Most people will want to use both Mac OS X and Linux on their Mac hardware. This page describes various alternatives for choosing which system to boot when the Mac starts up.
See also: Boot Alternatives - Triple Booting
Contents |
General
Partitioning: By default, Intel Macs use the GPT (GUID Partition Table) format. The Linux kernel supports this format when you activate the corresponding configuration option. GNU parted also supports GPT and can be used to create root and swap partitions for Linux. (You do not need a swap partition for Linux to run, but it's a good old tradition.)
Boot loader: Currently, you should use LILO and Boot Camp to boot Linux. The proprietary ATI drivers require a Video BIOS, and that is only present when booted through Boot Camp. (The same applies to the Intel graphics in the Mac mini.) It is still possible to boot with elilo, but you'll only get unaccellerated 2D graphics (framebuffer).
External disks: Neither Mac OS X nor Linux care much about what kind of disk they are run from (internal, external, USB stick). The instructions here should work no matter where each partition is located. You should note though that Windows XP seems to prefer the internal disk, and the Mac OS X Installer will only install to a GPT-formatted disk.
Using the built-in chooser
Apple's firmware includes a built-in boot volume chooser that is activated by holding the Option (Alt) key while the machine boots. The chooser displays all HFS+ partitions that have been 'blessed' for EFI booting. This solution has the drawback that you must press the Option (Alt) key on each boot. It is not possible to select the Linux boot volume in the Startup Disk preference pane, and the built-in chooser cannot be configured.
Setup
You will need a second, small HFS+ partition. You may want to create it with Journalling disabled, making it easier to use it from Linux.
Copy the following files to that partition:
- elilo.efi (the OS loader, sometimes named e.efi instead)
- elilo.conf (configuration file for the OS loader)
- vmlinuz (the Linux kernel)
- initrd.gz (an initial ramdisk image, may be absent)
If you want to follow the EFI specification, put those files together in a directory named /efi/linux (or /efi/debian, for example). Technically, it will work in any directory.
To allow booting from this volume, you'll need to boot Mac OS X and use the bless command line tool. A typical command to do this looks like this:
sudo bless --folder . --file elilo.efi
The additional files linux.vollabel and enable.sh will take care of the blessing and will also set the label for the built-in chooser to "Linux". Copy both files to the same directory as e.efi and run ./enable.sh there.
The boot volume chooser will show the disk's custom volume icon if there is one. Just paste it into the "More Info" dialog in Mac OS X. Or use an icon tool of your choice. (There's a nice penguin icon in the Crystal icon set.)
Troubleshooting
When you see just a grey screen after selecting the Linux volume, then you're using an unpatched version of elilo. It is prompting for your input and will do as requested, but you can't see it because the console is not switched to text mode. You can:
- Press Return to let elilo boot the default kernel
- See the Building elilo page for patches that enable console mode switching in elilo
- Use ebounce.efi from the rEFIt project; it switches to text mode, then loads elilo
(More information on EFI Text Mode switching.)
When a gcc-4.1 compiled linux kernel doesn't boot and the screen doesn't change anymore after you press enter on the elilo command line then you should try gcc-3.4, because gcc-4.1 seems to make problems (for me this is absolutely reproducable).
Using rEFIt
rEFIt is an EFI boot manager designed for the Intel Macs. It also comes with some EFI tools. When installed, it will display its menu on each boot, and boot the first choice after a timeout of 20 seconds. (The timeout can be configured starting with version 0.6.)
When using rEFIt, you still need elilo as the actual OS loader. With rEFIt, elilo can be placed more flexibly -- on your main Mac OS X partition, or on the hidden EFI System Partition at the beginning of your hard disk. rEFIt takes care of switching to text mode when it starts elilo, so you can use a stock build of elilo.
Download links are on the rEFIt home page; the distribution packages contain setup instructions. Some Linux-specific notes:
- rEFIt scans the following locations on each accessible partition:
- / -- i.e. the root directory
- /elilo
- /boot
- /efi/* -- i.e. any directory inside the efi directory; this corresponds to the EFI standard
- Using the Startup Disk preference pane (or installing a Mac OS X update) will disable rEFIt when it is installed on the main Mac OS X volume. Run the enable.sh script again to get the rEFIt menu back.
Using elilo alone
Unlike GRUB or LILO, elilo does not have the capability to chain-load other OS loaders. Once elilo is loaded, you can only boot a Linux kernel or return control to the built-in boot manager. This is perfectly reasonable, because the EFI specification requires the firmware to have a boot manager that can handle multiple operating systems.
You can install elilo on the EFI System Partition (the hidden FAT32 partition at the beginning of the drive), and set it as the default boot option using bless --mount ... --file .... When you do this, you'll have to press Option (Alt) to boot Mac OS X via the built-in chooser, or do nothing to boot Linux.
You'll need to use one of the solutions above to get a proper dual-boot selection menu.
Using Boot Camp
Apple's Boot Camp solution consists of more than just the Boot Camp Assistant. The actual legacy boot capability is in the firmware updates that were released simultaneously, and the Mac OS X 10.4.6 update contains an updated Startup Disk preference pane and HFS+ hot resize support.
With the Boot Camp firmware update, the built-in chooser detects standard PC (BIOS) boot code and offers it for booting. That means that you can install LILO or GRUB on your internal disk, then hold the Option (Alt) key while booting and get an additional choice in the menu. The entry will be labeled "Windows" and show the grey Boot Camp icon.
It is recommended to use LILO, as there seem to be some problems with GRUB. In any case, do not install GRUB in the MBR. (Embedding stage1.5 in the first track will not work because that space is occupied by the GPT tables.)
Using this method has several drawbacks:
- Startup Disk will not recognize the Linux partition, since it specifically looks for a Windows installation directory. You'll need to press Option (Alt) on each boot.
- Most stock Linux distributions will not know how to deal with GPT-formatted disks in their installers.
- GRUB 0.9x and LILO also doesn't know about GPT; you'll have to mirror your partitions in the MBR table. (Partitioning with the Mac OS X diskutil command will take care of that.)
- Neither GRUB nor LILO can chain-load Mac OS X.
If you want a nicer boot menu, you can use rEFIt 0.6 or later. That is especially recommended for triple-boot setups (Mac OS X, Windows XP, Linux) because the built-in menu only displays a single entry for the internal hard disk, and you have to chain-load Linux from the Windows boot menu or vice versa. With the Linux loader in the partition boot sector (not the MBR), rEFIt can directly boot both systems.
Using rEFIt, Boot Camp and LILO
This is the way to go it you don't care about Windows and want only MacOS X and Linux with Boot Camp (in order to be able to use the ATI proprietary drivers). Note that as of version 0.6, rEFIt is able to boot any partition marked as bootable.
First, update MacOS X to the latest version using Software Update and upgrade the firmware to the latest version. Once this is done install rEFIt following the documentation and use the enable-always.sh command [1]. Use the Boot Camp to partition the drive in two. When asked whether to create a driver disk, answer "no" and clic on "reboot" at the end of the process. This way you have a shrinked MacOS X partition and a windows partition which you will replace with some Linux partitions.
Second, get the Live CD and boot on it (put the CD in the drive and hold the C key at startup).
Use Parted to edit the partition table. If you use fdisk or any other non-GPT aware editor, you'll see the "mirrored" table put there by the Boot Camp partitioner. GPT and MBR tables can coexist, but the Linux kernel and Parted will take the GPT table into account if present. Delete the Windows partition created by Boot Camp but don't touch the first two partitions. Create the swap and linux partition as the third and fourth primary partitions. Extended partitions are not recognised so use primary ones only.
Create the Linux filesystems on the newly created partitions (this could be done in Parted as well).
Mount the root partition on /mnt, along with any other Linux partition created before. Copy all the Live CD contents (except /proc, /initrd and /mnt) into /mnt. Create the /mnt/proc directory and chroot to /mnt. Mount the /proc virtual filesystem. Now you should be able to do pretty much anything needed to set up Linux. You may want to recompile the kernel, since the one from the Live CD may not include support for the root filesystem (e.g. ReiserFS).
Install LILO (apt-get install lilo) without guided configuration creation and bootloader installation. Create a /etc/lilo.conf by hand with the following contents:
append="noapic"
boot=/dev/sda
root=/dev/sda4
image=/boot/vmlinuz
label=Linux
read-write
Quit the chroot'ed shell and unmount the disk partition from /mnt. Type reboot to reboot. Hold the touchpad button on startup to eject the Live CD. The rEFIt menu should offer a choice between booting MacOS X and Linux. Before continuing select the partition tool entry to create a mirrored set of MBR partitions based on your GPT partitions. Once this is done select Linux and boot into the newly installed distribution.
Note about customization
It is strongly advised to dist-upgrade the newly installed Ubuntu distribution and to remove all the automatic mechanisms of the Live CD (X configuration, automatic root login, etc).

