Ubuntu – Can’t get Ubuntu to boot from EFI in Mac


I am trying to get an old ca. 2006 macbook (technical specs here) to boot Ubuntu 14.04.2 LTS. I'm on day two of this now, having wiped the hard drive numerous times and reinstalled from the disk around 8 times now. I'm still fairly new to the Linux world.

I have been following the instructions here to get things going, and after much struggling, I got all the way to running grub-install and htfs-bless. This is supposed to enable the boot-up process on my mac to recognize Ubuntu during startup (so that I don't have to manually boot from GRUB, which is what I have to do now).

I run the following command (as root)

grub-install --target x86_64-efi --boot-directory=/boot --efi-directory=/boot/efi --bootloader-id="$(lsb_release -ds)"

It returns the following:

Installing for x86_64-efi platform.
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try: 'modprobe efivars' as root.
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try: 'modprobe efivars' as root.
Installation finished.  No error reported.

So it reports a fatal error (twice), but then finishes the installation with no errors. No idea.

It suggests that I try modprobe efivars from root, which I of course do. It returns nothing (which it isn't supposed to), but then running again produces the exact same error.

I go ahead and run

hfs-bless "/boot/efi/EFI/$(lsb_release -ds)/System/Library/CoreServices/boot.efi"

which completes without comment. The fact that it completes suggests that the grub-install created the proper file system under my distro's folder. So this is a good sign.

The next step in my instructions tell me to reboot, to make sure I boot straight to Ubuntu. This doesn't happen. It also says that I should see Ubuntu show up under the mac bootloader screen, and I do not.

After re-booting manually from GRUB, I get back in and try to continue with the instructions, and here I hit the wall. I type


and am met with the same error

Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.

So I try modprobe efivars as root, and when I run again, I get the same error again.

Some searching suggests the problem is that I am booting in BIOS and not in EFI. The obviously solution is to boot in EFI instead, but I have no idea how to do that. There is no BIOS partition on my machine; there is only an EFIBoot partition. There is no longer a Mac OSX system on my machine; there is only Ubuntu 14.04.2 LTS.

Sometimes I'm able to get Ubuntu to boot up, other times I have to do it manually. I can't get an Ubuntu disk image to show up in the Mac bootloader, and I can't access EFI variables.

If there is some file I could manually edit from the command line that would get me to boot in EFI, that could help me solve this issue.

Any help on this would be greatly appreciated.

Best Answer

I'm not 100% positive, but a Mac that old probably has a 32-bit EFI, even if it's got a 64-bit CPU. (The first Intel-based Macs had 32-bit CPUs with 32-bit EFIs. When Apple updated to 64-bit CPUs, the EFIs lagged behind for a generation or so before the EFI was updated to 64-bit.) For a native EFI-mode boot, installing in EFI mode is most easily done with an OS that matches the EFI's bit depth -- in other words, a 32-bit OS on a 32-bit EFI, or a 64-bit OS on a 64-bit EFI. Unfortunately, Ubuntu provides no 32-bit EFI boot capability with its 32-bit version, so doing this with Ubuntu requires jumping through some significant hoops to add a 32-bit EFI boot loader to a bootable image. It can be done (I've done it), but I don't have a reference to a precise procedure. (I started to write such a document once, but covering all the possibilities proved to be a real challenge, so I set it aside and never returned to it.)

The EFI version of GRUB does have the ability to cross-boot a kernel of a mis-matched architecture -- that is, a 64-bit kernel on a system with a 32-bit EFI or vice-versa (provided your CPU is a 64-bit model, of course). Using this approach would require installing in BIOS/CSM/legacy mode and then installing the 32-bit GRUB after the installation is complete; or hacking the 64-bit installer to include a 32-bit GRUB. I don't know of any site that describes how to do this for a Mac, but this one covers the process for an ASUS tablet with a 64-bit CPU and 32-bit EFI. (That site's down as I type this; I hope that's temporary.)

All that said, particularly if this is a 64-bit computer, using EFI mode for a single-boot with Ubuntu is the hard way to do it. It will be MUCH easier to treat the computer as one with a traditional BIOS. Create MBR partitions and boot the installer in BIOS mode. You'll be able to install either 32-bit or 64-bit Ubuntu, as you see fit, with no significant deviations to the installation procedure. When the Mac's firmware sees an MBR partition table, it will activate its CSM, and when it fails to find any bootable EFI boot loader, it will launch the BIOS version of GRUB in the MBR. This should all work smoothly, as if the computer with a BIOS-based model. The main pitfalls are controlling the installer's boot mode (BIOS vs. EFI) and using MBR (if you use GPT, the Mac's firmware won't enable BIOS-mode booting).

The main drawback is that it will be harder to update your firmware, since the firmware-update process requires an EFI-mode boot. On such an old computer, though, how likely is it you'll be updating your firmware? Also, if you later decide to dual-boot with OS X, you'll have to convert from MBR to GPT and re-install a Linux boot loader in one way or another.