Pure EFI Linux Boot on Macbooks

My company was really kind to get me a Macbook Pro (the 13.3-inch “5.5” variant). It is an awesome piece of hardware! (especially after my own PoS HP laptop I’ve been cussing at for a while now)

That said, I still don’t like the idea of running a proprietary operating system on it (as beautiful as OS X is ;)), so I continue to happily use Gentoo. The standard amd64 install works just fine with some minor hiccups (keyboard doesn’t work on the LiveCD, kernel only shows a console with vesafb).

The one thing that did bother me is BIOS-emulation. For those coming from the PC world, Macs don’t have a BIOS. They run something called EFI which is significantly more advanced (though I think the jury’s out on quirkiness issues and Linus certainly doesn’t approve of the added complexity).

Anyway, in order to support booting other OSes (=> Windows) exactly as they would on PCs, Apple has added a BIOS emulation layer. This is how Ubuntu (at least as of 9.10) boots on Macbooks. Given that both the bootloader (be it Grub2 or elilo) and the Linux kernel support booting in an EFI environment, it rubbed me the wrong way to take the easy way out and just boot them in BIOS mode. There is a reasonable technical argument for this – I see no good reason to add one more layer of software (read bugs) when there is no need at all. After a lot of pain, I did manage do make Linux boot in EFI-only mode. There is not enough (accurate, easily-findable) documentation out there, so this is hard-won knowledge. :) I’m putting this up to help others avoid this pain.

Here’s what I did (I might be missing some stuff since this was done almost a month ago). The basic boot steps look something like this:

  1. EFI firmware starts on boot
  2. Starts rEFIt, a program that extends the default bootloader to provide a nice bootloader menu, shell, etc.
  3. Scans FAT/HFS partitions (no ext* support, despite some claims on the Internet) for bootable partitions (i.e. having a /efi/… directory with valid boot images)
  4. Runs the Grub2 EFI image from a FAT partition
  5. Loads the Linux kernel (and initrd/initramfs if any) from /boot
  6. Kernel boots normally with whatever your root partition is

Now you could use elilo instead of Grub2, but I found this it to not work well (or at all) for me, so I just used a Grub2 (1.97.1, with some minor modifications) (just adds an “efi” USE-flag to build with --with-platform=efi). While I could make /boot a FAT partition, this would break the installkernel script (it’s run by make install in your kernel source directory), which makes symlinks for your latest/previous kernel image.

Instructions for installing the Grub2 EFI image are here. Just ignore the “bless” instructions (that’s for OS X), and put the EFI image and other stuff in something like /efi/grub (the /efi is mandatory). You can create a basic config file using grub-mkconfig and then tweak it to taste. The Correct Way™ to do this, though, is to edit the files in /etc/grub.d/.

Of course, you need to enable EFI support in the kernel, but that’s it. With this, you’re all set for the (slightly obsessive-compulsive) satisfaction of not having to enable yet another layer to support yet another proprietary interface, neither of which you have visibility or control over.


Add yours

  1. Nice! Now I just need an EFI emulation layer for my BIOS.

  2. I had a bit of rough time myself: http://debarshiray.wordpress.com/2010/01/15/fedora-11-12-on-an-intel-macbook-getting-it-to-boot/ However although I am now able to boot it without rEFIt it takes a very long time to get to GRUB after the power button is pressed.

  3. Nice! elilo is a lost cause – as it appears to not support 64bit EFI 1.x. In the non-mac EFI world (such as it is), there was 32bit EFI 1.x and then 64bit UEFI. Apple decided to do their own thing, as usual :-)

  4. Have you had much luck with the touchpad? Multitouch never worked well enough for me to drop OSX completely

    • I’m using it quite happily. There’s no multitouch yet (guess it’ll be a while before apps actually start using it). I do sometimes end up touching the pad while typing, which is really annoying. I’ve enabled the disable-touchpad-while-typing thing, which helps a bit.

  5. While I don’t have full EFI (yet?), a few months ago I upgraded all my disks (both direct and running kernel/md RAID, and some of my USB sticks as well) to GPT. I haven’t (yet) switched to grub2, but Gentoo’s grub (0.97-rWhatever) has GPT patches at least for BIOS mode, and that’s what I’m using.

    To do the partitioning I used gdisk, at the time using the bugzilla ebuild (#286535), but alexxy added it to the tree (with a bump) on Dec 6, 2009.

    Some notes:

    I chose gdisk as it seems to have more advanced GPT operations available than parted, it was more directly analogous to fdisk/cfdisk which I had been using and was comfortable with already, and I preferred to use separate filesystem tools anyway. (The description of the parted reiserfs support didn’t leave me very comfortable, that’s what I’m using on both my machines, with ext4 no journal on the thumb drives, and probably btrfs by the end of this year, so the filesystem support wasn’t going to meet my needs anyway.)

    FWIW, for those who want it, gdisk offers better hibred GPT/MBR support, too, tho the documents recommend against it, preferring the protective MBR only. The documents also cover the technology a bit better (without getting /too/ techincal) than parted docs do, I suspect, which was nice learning about it, and will certainly come in handy in a disaster recovery situation, should I ever find myself needing that backup partition table…

    AFAIK, kernel EFI support is simply GPT support. No big deal using GPT on BIOS once I enabled that.

    Two things I like about GPT: It’s very nice having partition labels in the partition table (I put the same label in both the GPT partition entry and the filesystem label, helps keep things straight), and I LOVE not having to worry about primary/logical partitions any more! =:^)

    But I still have to upgrade to grub2 one of these days…


    • Please read up a bit before you post. EFI and GPT are completely unrelated. The first is a standard for system bootstrap/firmware, and the second is a disk partitioning type.

  6. I had luck with pure EFI booting using sys-boot/mbr-gpt and then grub1, however that precludes dual-booting.

    Do look at efibootmgr as well however.

    • Ah yes, I should have mentioned that it’d be easier to actually get a single-boot system going, but I wanted to keep OS X around to play with. :)

  7. Without the bios emulation, how do the nVidia and noveau drivers work on the MacBook? Any luck?

    • I haven’t tried the Nouveau drivers (yet), but the NVidia binary drivers work flawlessly.

      • Can you provide your GRUB2 configuration file, which modules are compiled and running in your kernel, and your X configuration?

        So far NVidia’s drivers have only complained that the hardware is in use and it can’t initialize. If I try to use any other framebuffer driver besides efifb, I get no display at all on boot and can’t tell what’s going on.

  8. Hey its fantastic to see others using pure EFI on their Macbook pros. I to have a Macbook pro and I encountered alot of issues with this. The first is that on kernel 2.6.32-rc7 was the first kernel to support my audio drivers. The second was that 2.6.31 somewhere broke EFI booting and caused a system lock on boot. I could not ever isolate or resolve this issue with kernel developers (albeit because my C is not very good). A few other issues I had was the lack of bcm4322 support, though that is changing and also that my model has both a 9600GT and a 9400. Now when booting EFI its all great as you can actually access the 9400, and use it rather than the 9600(which makes your laptop feel like its on fire!), but I could never successfully disable the 9600, only idle it so it kept it cooler (50 degrees C rather than 60 – 70). Even alot of other things like pommed, and lm_sensors all stopped working on an EFI system, so there are a huge number of issues still present. I would love to know what kernel version you are using, what hardware you got supported etc, as it might be a great step forwards in my efforts to get linux compatibility to the Dual gfx card models.

    • Ah, I have only the 9400M (this being the 13″ model). I’ve had no major kernel issues (running

      pommed runs fine-ish for me. The ambient light sensor is not awfully sensitive, but it’s good enough. As for the bcm4322, I’m using the binary STA driver (yes, icky, but it seems to work if you’re not using NetworkManager).

      lm_sensors integration is not great, but the Apple SMC driver does expose a whole bunch of devices, so it should be a matter of adding support. That said, between hddtemp, the nvidia driver and the ACPI thermal zone drivers for the CPU, you should be able to track all the important temperatures.

      Ah, a couple of other things: the built-in mic sensitivity is awfully low, and unlike your 15″ MBP, the 13″ has only one audio port, so you need to manually toggle between input and output modes. I’ve yet to figure out if/how this works with the hda driver.

      Finally, I can’t seem to get USB suspend to work on a bunch of USB devices (card reader, IR receiver) so battery life is on the lower side of 3 hours. I’d really like to try to see how to improve this.

  9. Ahh okay, I had usb suspend working, it just worked out of the box for me, and audio was great but for some reason on my model kernels after 2.6.31 would not boot at all. You would select the entry in ELILO, and it would go to a black screen and nothing would happen. Its not the gfx card, its something in EFI booting itself on that kernel revision or higher on my model. Even on working efi kernels such as 2.6.30, there is horrid tearing all over the screen.

    I also never managed to get the STA drivers working, but that was a few months ago, so I may want to try again. You can fix up the pommed sensors in their configuration if you have time and a torch to shine at the sensor, you can adjust it to a good level, I had is responding about the same as OSX does.

  10. Really good work! Thanks for sharing!

  11. rEFIt does support ext2/3 and reiserfs. These are case sensitive (unlike HFS+ most of the time, and msdos), so you need to store you grub binaries in /EFI/ not /efi/. See here:


  12. Hello Arun, thank you for you post. I am trying to run few linux distro from a USB key, but as you correctly mention there is not enough and easy documentation out there. I am not a linux expert, but I am a quite enthusiastic linux user. Unfortunately booting Linux from an external disk is not well-supported by Apple’s firmware for the reason you have mentioned already. There are two ways to face this issue. This limitation could be fixed by either patching the Apple firmware to include a USB driver in BIOS mode, or the Linux operating systems to remove the dependency on the BIOS. You have chosen the second way, that is also what I would like to do in order to bypass this issue. As I mention before I am not an expert of Linux OS, so to simplified my life I use user-friendly tools to deal with Linux. At the moment in order to load Linux distro onto a USB Key I am using a very handy tool called “LinuxLive USB Creator” http://www.linuxliveusb.com/

    This is the easiest way I have found to create a bootable linux distro into a USB Key, and is working pretty good on PC/Intel machines. But when I try to boot up the usb key from my Macbook “santa rosa”, using The rEFIt Project, it not working for the reason you have already mentioned in your post. I can see that you were able to sorted out this.

    Possibly I need an help in order to understand how to modify the already installed Linux distro (into the USB) to meet the requirement in order to avoid the classic bios boot and use instead the EFI one. I can run the Linux Distro into a Virtual box while I am running OSX and change the grub and the kernel, but I need an help to do this.

    Thank you Toni

  13. Enjoy daily galleries http://sexyboobyvideos.relayblog.com/?nya

    watch softcore porn videos hair porn upload porn boobs tits fuck porn forums the max st lucian porn

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.