Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running Kubuntu 13.04 on my MacBook Pro (8,2) and I have it set up to boot through Apple's BIOS emulation. I would like to use the Intel instead of the ATI graphics card. This means that I will need to get the system to boot via EFI. I don't want to do a clean install. The furtherest I can get is into grub-efi, but I cannot actually boot the kernel from there.

My partition scheme:

/dev/sda1 = EFI
/dev/sda2 = Mac OS
/dev/sda3 = root
/dev/sda4 = boot
/dev/sda5 = home
/dev/sda6 = swap

How can I achieve EFI booting on a BIOS booting install without loosing my existing OS installations?

share|improve this question
up vote 1 down vote accepted

Try this:

  1. Instal rEFInd in OS X. You can use the install.sh script to do this.
  2. Type sudo mkdir /EFI/refind/drivers_x64 in an OS X Terminal window. (If you use the --esp option to install.sh, you'll need to adjust the path to create this directory on the ESP.)
  3. Install the rEFInd EFI driver for whatever filesystem you're using to store your Linux kernels (usually ext4fs, but sometimes not). To install the driver, you need to copy it to the drivers or drivers_x64 subdirectory of the rEFInd installation directory (/EFI/refind by default in OS X).
  4. In Linux (even from a BIOS-mode boot), run the mkrlconf.sh script that comes with rEFInd. This will generate a /boot/refind_linux.conf file, which holds kernel options that rEFInd passes to your kernel.

Ideally, this will enable you to boot directly to Linux in EFI mode, bypassing GRUB, which can be tricky to configure if the automated scripts don't get it right. rEFInd should detect your kernels each time you boot, so you won't need to update anything when you upgrade your kernels.

If this works, and if you're not triple-booting with Windows, you may want to:

  • Edit /EFI/refind/refind.conf, uncomment the scanfor line, and ensure that hdbios is not present. This will keep the old BIOS-mode GRUB from showing up as a rEFInd boot options.
  • Remove the hybrid MBR from your hard disk. You can do this by editing the partition table with parted or GParted (just make any trivial change) or by installing the gdisk package, launching gdisk on your disk, typing x to get to the experts' menu, typing n to generate a new protective MBR, and typing w to save your changes. Removing the hybrid MBR will reduce the odds that it will cause problems in the future.
share|improve this answer
    
I've been trying to follow this for the past hour and I'm totally stuck. I can install refind to my OS X partition with install.sh, but if I try to use --esp it says it can't find my esp. I can mount my EFI partition via Disk Utility, but I can't get refind to install to it. I also tried just running it off my OS X parition and it works, but it doesn't find my kernel. I coppied the drivers over to the refind folder and it will find a kernel image on my EFI partition but won't find the one I want to boot on /boot. Kernel on EFI was coppied from boot but it just dumps me at a busybox prompt – Benjamin Daines Sep 2 '13 at 3:31
    
I don't want to boot the kernel on EFI, I want to boot the one on /boot, but I included that just because. I'm going to call it quits for the night before I end up throwing expensive hardware at the wall. I'll check back later for responses and / or give it another go tomorrow. Thanks for you help, hopefully we can figure this out... – Benjamin Daines Sep 2 '13 at 3:32
    
The EFI filesystem driver(s) must be installed to /EFI/refind/drivers_x64 or /EFI/refind/drivers on the OS X partition, assuming that you installed rEFInd itself to /EFI/refind. Once that's done, rEFInd should detect and boot your kernel(s) from your Linux partition; however, you'll probably also need a /boot/refind_linux.conf file (under Linux) in order to boot completely. (Without that file, the kernel won't know where its root partition is and so the boot will fail and probably dump you to a minimal shell.) – Rod Smith Sep 2 '13 at 17:07
    
Ok, got it figured out. It's sloppy, but it works. I ended up installing grub (grub-pc-bin was still installed, so I removed it) to /boot/efi/ubuntu. Now I boot to refind, then to grub, then to the OS. Now using the intel graphics card :) – Benjamin Daines Sep 2 '13 at 18:42
    
You should be able to simplify the boot path by installing the EFI filesystem driver for your Linux filesystem (probably ext4fs) and creating a /boot/refind_linux.conf file. If you can't seem to get this working, then please show the output of ls -R /EFI in OS X, and of cat /etc/fstab and cat /boot/refind_linux.conf in Linux. Edit your original post to show this information, and add four spaces to the start of every line to preserve formatting and legibility. – Rod Smith Sep 2 '13 at 22:10

Here you have another possibility, i.e. to bypass completely both grub and rEFInd. By following these steps you'll end up with a system that boots natively into Linux in pure EFI mode.
Whenever you need to boot back into OsX, simply hold down the <alt> key immediately after the chime sound and you'll land in the Apple's built-in boot screen where you can select the OsX partition for booting.

This is the step-by-step guide:

  1. Once in Linux, download and install by whatever means you prefer the packages mactel-boot and hfsprogs.
  2. Use GParted, for example, to resize you existing partition schema and make room for a new tiny partition, say, 100MB or less, which you'll format as an HFS+ filesystem. If you have installed hfsprogs, this can be done easily with GParted's GUI or, alternatively, with the command mkfs.hfsplus /dev/sdaX where X is the number of the newly created partition (I'd assume 7, in your case, i.e. /dev/sda7).
  3. Mount the new HFS+ partition in whatever mountpoint you may wish. It is not important at all. At the end of the process you can even edit your fstab file to prevent linux from automatically mount this partition upon login.
  4. Copy your active kernel into this partition. You don't need to copy everything, only vmlinuz-x.y.z-whatever.efi.signed and initrd-x.y.z-whatever.img. IMPORTANT! The kernel must be renamed to something ending with 'efi' otherwise Apple's firmware will refuse to execute its code. You can rename it to vmlinuz-x.y.z-whatever.efi or even simply vmlinuz.efi
  5. Now create a new boot entry in the EFI firmware issuing the command sudo efibootmgr -c -l '\vmlinuz-x.y.z-whatever.efi' -L 'Ubuntu' -p X -u "<kernel parameters> initrd=\initrd-x.y.z-whatever.img" where X is the partition number of your brand new HFS+ partition and <kernel parameters> are the parameters as taken from your grub.cfg in the menu entry corresponding to you current boot (e.g. root=UUID=de4567fd-55aa-AND-SO-ON ro quiet splash etc.)
  6. Bless the the newly copied kernel with the command hfs-bless "<MountPoint of your HFS+ partition>\vmlinuz.efi" (e.g. hfs-bless "/mnt/pureEfiBoot/vmlinuz.efi"
  7. Done. Reboot and enjoy.

The main advantage of this approach is the blazing fast boot time. You can be in your login screen within a handful of seconds, depending on your hardware's speed. You can even eliminate the default 5 seconds delay using sudo efibootmgr -T

On the other hand, one major drawback is that each time you update the kernel you need to manually update the (at this point, hidden) HFS+ partition. If you don't do that, it won't harm much since you'll be booting with an old kernel. Nevertheless, an update is advisable, and it could be done automatically by using some form of shell script.

Another (potential) drawback is that on some machines, X may fail to correctly detect your graphic card when booting the kernel directly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.