This page covers Intel-based Macs – all models since 2006, including MacBooks and ?MacBook Pros
Jan 01, 2017 BURG – is a beautiful boot loader based on GRUB. It uses a new object format which allows you to choose from: Linux, Windows, OSX, Solaris, FreeBSD, etc installed on your computer. Has a custom menu that works in both text and graphical mode.
The most delicate part of installing operating systems, other than drive partitioning (which can destroy data), is configuring the boot loader, which can render your system unbootable. Best practice on ?IntelMacs has been changing with improved development of GRUB and supporting software.
This page only covers changing boot loaders, and does not cover the far more dangerous process of partitioning. For partitioning Intel Macs, see ?IntelMac/Partitioning.
On an Intel Mac, currently the best stable (lenny) configuration is:
chain loading by first loading rEFIt (in EFI), then using the BIOS version of GRUB 2 (grub-pc) to load Linux (or Windows).
This allows multi-booting to Linux, Mac OS X, and Windows, yields accelerated graphics, and does not require LILO to be run every time a kernel or init ramdisk change occurs.
In future, this may be replaced by:
a single stage boot, with the EFI version of GRUB 2 (grub-efi).
This is similar to rEFIt + GRUB 2 (BIOS version), but somewhat simpler. Currently there are limitations in Linux and X.org which need addressing (their video drivers need BIOS to initial video hardware for acceleration), but longer-term this should be an acceptable solution.
In the past, (etch?), practice was:
This worked, but had the usual limitations of LILO (system wouldn’t boot if forgot to run lilo after kernel changes, etc.), and was necessary because GRUB Legacy does not (easily) support Intel Macs.
Any OS can be selected as default if you use rEFIt (version 0.14+) then the BIOS version of GRUB 2, or just GRUB 2 in EFI.
First, make a rescue CD/DVD, or get a Live DVD (or Live CD, or Live USB) and test it by booting with it. If rEFIt is properly configured, you will be able to boot from discs or USB drives from the rEFIt screen. Alternatively, holding the Option key during boot should start the Apple Startup Manager, while holding the ‘C’ key during boot should boot to CD (or DVD) – these should work even if rEFIt is broken.
Having a separate working computer available is wise, in case of difficulty it allows you to research the problem without needing to reboot the non-working computer.
Likely worst case – assuming you do not change partitions, which can destroy data – is to render the hard drive unbootable, requiring the use of a boot CD/DVD.
Booting from a CD/DVD should always work (assuming firmware is ok: you do not need to change firmware in any way to install Debian or change the boot loader), but in worst case scenario, you can always remove the hard drive, connect it to another computer (such as in a USB hard drive enclosure), and fix it there.
Similarly, if the firmware is corrupt, you can restore the firmware as described at Apple support (About the Firmware Restoration CD (Intel-based Macs)) or by taking it to an Apple store, but this should not prove necessary.
This is mentioned simply to alleviate fears – if you’re only changing boot loaders, not booting from hard drive (and requiring rescue CD/DVD) is likely the worst case.
Complexity in Intel Mac booting is due to the transition from BIOS firmware to the EFI system.
In parallel with this is the transition from the BIOS system of partitioning (MBR) to the EFI system of partitioning (GPT). During this transition you’ll want to use a GPT/MBR hybrid system, but these are potentially very painful. Notably, the GPT and MBR partition tables can get out of sync, so after using non-GPT aware partitioning tools, you must use gptsync (either in Mac OS X or Debian) to sync the partition information. In squeeze, gdisk is a GPT-aware fdisk, but in lenny, you’ll need to use gptsync in addition to fdisk, and gptsync is useful if you’ve used Mac OS X partitioning.
There are 3 components in the boot process, as described here:
rEFIt (EFI bootloader) – chooses partition
GRUB (BIOS bootloader) – boots Debian
In general, once set up, you will not need to touch the firmware or rEFIt, but you can safely upgrade these without harm, and they will not touch your Linux partition.
You mostly needn’t concern yourself with this, except as backup.
This is sometimes upgraded, which is a reason to keep Mac OS X around; see #Upgrading EFI Firmware, below.
It is also possible to:
See:
http://support.apple.com/kb/ht1379
http://www.hackerskitchen.com/mac-old/nvram-detailed.html#nvram
http://www.hackerskitchen.com/mac-old/#specific
for details on firmware hacking. These should not be necessary, but are included for reference.
rEFIt is an EFI bootloader, particularly for Intel Macs.
rEFIt can be installed via Mac OS X, which is the easiest way to use it. There is also refit, which is a re-packaging that has licensing that is conformant to Debian Free Software standards (rEFIt itself does not). The Debian package is not necessary to use rEFIt, and requires manual installation in Mac OS X, but it may prove useful.
rEFIt 0.14 (2010 March) has some useful enhancements, notably more configurable default boot, and detection of GRUB 2, so it is a recommended upgrade.
A subtlety is that the Mac firmware (specifically the PRAM (Programmable RAM), which stores variables) stores which partition to boot, which it calls “blessing”. Mac OS X is in the second partition, while rEFIt is installed in the first (EFI boot) partition (it also has files in the OS X partition, but copies these to the EFI boot partition). Blessing is done so the Mac will use rEFIt (or other EFI-capable bootloader) to boot.
A sub-subtlety is that when returning from Safe Sleep, Macs will boot – which should always be the Mac partition, not rEFIt, but due to a bug they may boot into the “blessed” partition, rather than into Mac. Thus rEFIt includes a program “rEFItBlesser” which blesses the Mac partition on startup, then blesses the rEFIt partition on shutdown. Thus you may sometimes boot into OS X instead of into the rEFIt menu, particularly after installing or upgrading rEFIt or following power loss or OS X Safe Sleep. Rebooting should bless rEFIt on shutdown and thus reboot into rEFIt. On reinstall you may need to reboot twice – the first time rEFItBlesser now starts, and blesses on shutdown, the second time it boots into rEFIt.
See No rEFIt menu after Safe Sleep or power loss for details.
There are many possible configurations, depending on whether you want to boot only Debian or wish to multi-boot, and what boot loader you use in EFI.
For concreteness and maximal compatibility, one may assume that one wishes to triple-boot to Mac OS X, Debian, and Windows (possibly non-EFI aware, e.g., prior to 2008). In that case one:
The other boot options, in order of complexity:
Note the key distinction between installing GRUB 2 in EFI versus on the partition. Concretely, grub-install /dev/sda installs GRUB 2 to the hard drive (EFI), while grub-install /dev/sda3 (note the “3”, indicating partition) installs GRUB 2 to the partition. (Formally, when installing in the partition, GRUB is in the “Partition Boot Record” or “PBR”; see Volume boot record.)
It is also possible to multi-boot without using rEFIt (holding down the “Option” key at boot to access the built-in Mac multi-boot), but rEFIt makes matters much easier.
On top of this is the distinction between using a pure GPT system (which to the eyes of MBR has only a single partition) versus using a hybrid GPT/MBR system, which to the eyes of MBR has up to 4 primary partitions, consisting of a GPT partition, the Mac OS X partition, the Debian Linux partition, and optionally a Windows partition.
If you wish to retain OS X, which you may desire either to use OS X applications, to easily upgrade EFI firmware, or simply as a backup system, then easiest is to use Boot Camp to resize/repartition, and retain the Mac OS X partition. Alternatively, you can wipe the hard drive and use Debian only (or Debian and Windows, or other combinations).
One can set any OS as the default, as follows:
If rEFIt is in EFI, use rEFIt version 0.14+ and configure the refit.config file as documented there to select default system.
You can also triple-chain: first rEFIt → GRUB 2 on the Linux partition, then GRUB 2 to another OS (such as Windows).
See: ?Debian Install Tutorial for MacBook
Installing Grub2 has also been fine for Lenny. This is the grub-pc version which boot through rEFIt (not grub-efi). This is tested on amd64 and i386.
Lenny install CD can install GRUB as bootloader. Its dialogue can be misleading if you wish to install bootloader to MBR. You must create proper MBR/GPT hybrid. It can be done by:
gptsync command on Linux
menu from rEFIt boot loader
If you wish to switch from lilo to GRUB (BIOS version), while still using rEFIt in EFI:
First, please read and understand some basics at: Debian Reference: 3.3. Stage 2: the boot loader.
Second, make rescue media (a rescue CD) using grub-rescue-pc, or some Live CD/DVD, such as Knoppix, and test it.
Third, check which partition Linux is on, either using gparted in Debian or the disc tool in Mac OS X. It is probably /dev/sda3 (third partition ‘3’ on primary drive ‘a’), assuming you’re also booting into Mac OS X (EFI is partition 1, Mac OS X is partition 2), but please check.
Also, you will need to ensure the rEFIt is at least at version 0.9 (0.14 is preferred); previous versions don’t play nice with GNU parted and GRUB 2; see [http://refit.sourceforge.net/doc/c4s5_parted.html rEFIt: Linux partition shows as EFI System (FAT)] for details.
To test your Live CD/DVD:
…or similar (above works in Knoppix), and then chroot to it:
At this point you should be booted as usual into your system, and should be able to edit files, run aptitude, etc.
Now you are ready to install the packages:
This is safe – it installs the packages, but does not change the boot loader.
grub-pc is GRUB 2 (BIOS version), while os-prober detects other OSes and automatically includes them in your GRUB menu (lenny version detects Windows, while squeeze version detects Windows and Mac OS X), and gptsync ensures that GPT and MBR partition information are in sync, just like it says on the tin.
Now for the actual installation:
Note that:
you cannot use reiserfs in your main partition (or rather, should not); this is potentially very dangerous and risks FILESYSTEM DESTRUCTION (quoting grub-install), and you are recommended to instead convert your filesystem to ext3, as per Serverfault: How to convert a reiserfs partition to ext3? (make sure to update fstab to read ext3 instead of reiserfs)
At this point GRUB should be correctly installed.
The need for gptsync to be run in Linux is as follows: for GRUB 2 to successfully load, the partition number must be 83 (Linux). However, the gptsync included in rEFIt in Mac OS X does not set this partition number, and thus will not load GRUB 2; this may be fixed in rEFIt 0.14.
You may instead be able to run grub-install '(hd0)' ((hd0) in GRUB = sda in Linux), but this may instead install GRUB to EFI. Alternatively, grub-install '(hd0,3)' ((hd0,3) in GRUB = sda3 in Linux) may work.
To ensure that the menu is correctly updated, edit /etc/kernel-img.conf to include the following lines (these were previously documented at zless /usr/share/doc/grub/README.Debian.gz):
You can test that this updates GRUB by reconfiguring your running kernel:
(BTW, the difference between GRUB and LILO is that GRUB can successfully load the kernel even if the menu hasn’t been updated, since it can read the file system, while LILO simply fails. However, this requires manually finding and entering the path to the kernel.)
If you are ready to reboot, cross your fingers, and reboot, either interactively or via the command line:
(If you find yourself here after your system failed to reboot, we are very sorry – if you can identify the problem, please correct it above.)
Upgrading EFI Firmware (which Apple does through Software Update) does not affect boot loaders in any way, and is completely fine – rEFIt, GRUB 2, elilo, LILO, and Windows should continue to work exactly as before.
In fact, upgrading EFI Firmware may improve boot loaders – early firmwares sometimes caused problems with failing to recognize keyboards, preventing you from selecting different boot options in GRUB 2.
You can see the latest EFI Firmware at Apple Support here: EFI and SMC firmware updates for Intel-based Macs.
/GRUB Legacy – out of date, but kept for reference
CategoryMacintoshComputer
Originally written: 1/2011; Last Web page update: 6/17/2013 (last major update: 5/4/2012)
I'm a technical writer and consultant specializing in Linuxtechnologies. This Web page is provided free of charge and with no annoyingoutside ads; however, I did take time to prepare it, and Web hosting doescost money. If you find this Web page useful, please consider making asmall donation to help keep this site up and running. Thanks!
Donate $1.00 | Donate $2.50 | Donate $5.00 | Donate $10.00 | Donate another value |
Note: This page is written using a rather elderly 32-bit Mac Mini as a reference, and using Ubuntu 12.04 as a reference. Developments in the last year have rendered certain of the procedures on this page sub-optimal. I've tried to point these out, but I haven't fully researched better replacements, and I lack the modern hardware on which to test some of the better methods on more recent 64-bit Macs. Thus, you may need to deviate from these instructions on modern computers.
When installing Ubuntu Linux on an Intel-based Macintosh, most peoplefollow any of several guides available on the Internet, such as thisUbuntu document. Most of these guides, however, rely on features of theMacintosh that are intended to enable it to boot Windows. In particular,these guides typically end up creating a configuration that boots Linuxusing its Compatibility Support Module (CSM), which provides BIOSemulation on the Mac. In this mode, the Mac sets up a Basic Input OutputSystem (BIOS) layer that the OS can use, rather than rely on the ExtensibleFirmware Interface (EFI) that OS X uses to run on the computer. BIOSemulation is expedient, and it's the only way that most versions of Windowscan boot directly on a Mac, but it's got several drawbacks:
As far as I can tell, BIOS emulation mode only works when a hybrid MBRis present on the hard disk or when a BIOS-bootable optical disk isinserted in the optical drive. Thus, you can't use BIOS emulation mode witha conventional GPT disk unless you plan to use a bootable optical disc toboot Linux.
Ubuntu can use the BIOS emulation and hybrid MBR that enable Windows toboot on Macs, but it doesn't need to! If you don't use thesefeatures, you won't see their problems. Hybrid MBRs, in particular, are aBad Idea (with a capital B and a capital I). I've seen numerous problemsreported at the Ubuntu Forums relatedto Ubuntu installations on Macs with hybrid MBRs, and more problems withsimilar configurations elsewhere. See my hybrid MBR Web pagefor a technical description of what they are and what can go wrong withthem. In short, they can get out of sync, cause confusion about whichpartition is which, and become damaged in frustrating ways. Whenever Ithink I've heard of every possible problem with hybrid MBRs, I stumbleacross a new one. You're better off without one, if that'spossible—and it is, if you dual-boot OS X and Linux but notWindows.
The trouble is that Ubuntu doesn't support installing to a Mac in EFImode, at least not as of version 12.04. (Some sources claim that this nowworks on some later versions, but I haven't tested this claim—indeed,I lack the hardware to do so!) The normal 64-bit discs can boot on PCs ineither BIOS mode or (if the PC supports it) UEFI mode (UEFI being,essentially, EFI 2.x). These discs reportedly do not boot on Macs(although I suspect they might with the help of rEFIt or rEFInd). The 32-bit Ubuntuinstallation discs lack EFI support. Ubuntu has also released 64-bit discimages for Macs. Ironically, these boot only in BIOS mode! Therefore, torid your computer of the dangerous hybrid MBR, you'll need to jump throughsome hoops. An alternative to all of this is to run Ubuntu in a virtualenvironment, such as VirtualBox.This can be a good solution in some cases, but it doesn't give Linux directaccess to the hardware and you'll lose some speed.
Although my opinion is that Intel-based Macs are best booted using EFIand a GPT with a protective MBR rather than a hybrid MBR, there aredrawbacks to doing it this way. These include:
If you're running Fedora, CentOS, Mandriva, OpenSUSE, Gentoo, Debian, ormost other Linux distributions, the procedure I'm about to describe willprobably work; however, some details may differ. In fact, at one time oranother, I've installed Ubuntu, CentOS, and OpenSUSE on my Mac Mini, allusing EFI-mode boots. It's possible that your preferred distributionalready supports direct EFI installation, in which case the problem ofinstalling to a Mac in EFI mode may not exist. Check your distribution'sdocumentation to be sure.
I've tested this procedure only on my first-generation Intel-based MacMini. This computer uses a 32-bit CPU and 32-bit EFI, so I've tested onlythe 32-bit version of Ubuntu. It's possible that the 64-bit version hasdifferent requirements, or you may need to do things differently on newer64-bit Macs. You can check which type of EFI you've got with the followingcommand, typed in an OS X Terminal:
The result should include the string EFI32 or EFI64;the meaning of each should be obvious.
Before proceeding, you'll need to download a few items:
With these items in hand, you can proceed with installing Ubuntu, andthen fix it up so that it doesn't use a hybrid MBR.
If you've already got a working dual-boot configuration with OS X andUbuntu, you can skip this section and jump ahead to 'Fixing the Installation.' You may be able to skip someof the steps in that section, too, such as rEFInd installation.
To install Ubuntu Linux 12.04 on an Intel-based Mac, follow thesedirections:
When the installation finishes, the computer will reboot—straightinto Mac OS X! (See the below note if it doesn't boot, though.) You mustnow proceed with fixing it up in various ways..
If you've followed the directions, your computer should now be bootedinto OS X, looking very much like it did before. Ubuntu isinstalled, however, and your disk has a hybrid MBR. You must now take stepsto return the hybrid MBR to a safer protective MBR, as the GPT standardrequires, and to set up a boot loader that enables you to select which OSto boot when the computer powers up. To do so, follow these steps:
Update:If you're using a 3.3.0 or later kernel, you can skip most of the rest of this page, and instead perform a much simpler operation:
At this point, it should be possible to boot Linux by rebooting thecomputer and selecting one of the vmlinuz-version entriesin rEFInd's menu. If this doesn't work, continue with the main proceduredescribed here..
At this point, if you did everything exactly correctly, you should beable to boot Ubuntu in EFI mode. When you reboot, your rEFInd menu shouldinclude a new Ubuntu option, as shown below. Select it and your GRUB menushould appear; it will resemble the one shown earlier, although it may usea different font and color scheme.
Once you're satisfied with your ability to boot and use both Linux andOS X, you can delete the BIOS Boot Partition from your hard disk. It'sno longer needed, but OS X may want free space where it resides in thefuture. You can use GParted, parted, gdisk, or any otherpartitioning tool to delete this partition.
Although my own system doesn't seem to suffer from its presence, it'sconceivable that some Macs will experience boot-time slowdowns because ofthe presence of the BIOS version of GRUB's boot code in the hard disk'sMBR. If you think this is happening, you can type
If you've not used it before, you may want to peruse the rEFInd documentation. Althoughthe default options work well for most systems, you may want to tweak someof them or install ancillary programs, such as an EFI shell program.
You may want to add an entry for the ESP to your /etc/fstabfile so that it will be mounted automatically whenever you boot. Thefollowing line will do the trick on most systems:
You can tweak this entry as you see fit. The /dev/sda1specification works for most people, but you could change it to use aLABEL or UUID specification, as inUUID=2B68-9A85. This will make the configuration more robustshould the disk identifier change because you boot with a different diskconfiguration or you repartition the disk. If you this change, you'll needto obtain the label or UUID value for your ESP. Typing
Although GRUB 2 often works in a configuration like the one I've justdescribed, it also often misbehaves. For instance, on my brand-new Ubuntu12.04 installation (less than 24 hours old as I type), GRUB 2 often givesme a 'file not found' error when selecting the Ubuntu entry; then if Iselect the same entry, it boots fine. On other installations andcomputers, GRUB 2 has resulted in kernels that begin to boot and then fail;it's begun returning a grub> emergency prompt for no apparentreason; and it's done a poor job of detecting OSes and kernels. What'smore, on my Mac, Ubuntu's packaging system keeps trying to replacegrub-efi with grub-pc, which would result in anunbootable installation if allowed to continue! For these reasons, GRUB 2is the EFI boot loader that I favor least. That said, some peoplesay it works acceptably for them, and it's Ubuntu's default boot loader, soUbuntu's installation scripts usually do a tolerable to good job ofautomatically configuring it. These are the reasons I provided instructionsfor installing GRUB 2. I personally try to remove it as soon as possibleafter an installation, or at least shove it out of the way so that it can'tdo any real damage.
If you have problems with it, you can switch to another EFI boot loader.My EFI Boot Loaders forLinux Web page describes the options that are available. If you'vefollowed the directions on this page, my personal favorite is actuallyquite close to working: If you can install a Linux kernel with the EFI stubloader support enabled, rEFInd can launch it directly, without the helpof GRUB. The major hurdle to overcome on this score is that Ubuntu 12.04installs a 3.2.0 kernel, but the EFI stub loader became available with the3.3.0 kernel. This is why I recommended installing Ubuntu 12.04.2, 13.04,or a more recent version of Ubuntu; these versions ship with 3.3.0 or laterkernels. In broad outline, to use the EFI stub loader, you must:
This refind_linux.conf file is taken from a workinginstallation, but you'll need to adjust the UUID value for your owncomputer if you use it as a model. When you boot, rEFInd uses the firstline's options by default, but by pressing F2 or Insert when you select akernel in rEFInd, you can choose another option set.
The beauty of this method of booting is that you don't need to changeconfiguration files when you install a new kernel—just place it, witha suitable filename, in the kernel directory and rEFInd will detect it anduse the options from refind_linux.conf to boot it. Although GRUB 2is supposed to be as easy to use, it accomplishes this goal by running aseries of configuration scripts whenever you install a new kernel andupdating its configuration file. This process can go wrong, particularly inadvanced or exotic setups.
If you have problems with GRUB 2, ELILO and GRUB Legacy are the bestoptions, as described on my EFI boot loaders page.Each has advantages and disadvantages. On my Mac Mini, ELILO doesn't work,but that may be a model-specific quirk. Unfortunately, you'll need toadjust either boot loader's configuration whenever you upgrade your kernel,so keep an eye on that!
You can consult the UEFIBooting page tolearn about more options for GRUB on a Mac. Some of that page'sinstructions didn't work for me, though; presumably they're either specificto particular Mac models or the page is dated.
I hope you've found this Web page informative. I realize the proceduresoutlined here are complex, but in my opinion, it's worth getting rid of theflaky and dangerous hybrid MBR even if doing so requires investing theeffort described here.
The following sites have additional information that you might finduseful:
If you have problems with or comments about this web page, pleasee-mail me at rodsmith@rodsbooks.com. Thanks.
Return to my main Web page.