Installing Fedora 16 on MacBooks using GRUB2 EFI.
Helpful hints for getting Fedora 16 installed on various Macbook models using GRUB2 EFI.
Installing Fedora 16 on MacBooks
Intro
Mac's use a poor EFI implementation compared to other systems.
In a lot of cases it is also a 32-bit EFI implementation, which means the BOOTX64.efi grub image used on the Fedora media will not work, since it is intended for 64-bit EFI implementations. To add insult to injury a lot of Mac's boot with a dead keyboard when you try to boot off of Fedora Media with support for both EFI and BIOS booting, meaning you can't select either method and you can't boot.
There are several useful resources for understanding how every other EFI system works, how Mac's work, and how to work with all of this. Some of the ones I retained on my mad hunt for information are:
http://mjg59.dreamwidth.org/4957.html
http://blog.christophersmart.com/2009/07/23/linux-on-an-apple-xserve-efi-only-machine/
http://www.felipe-alfaro.org/blog/2006/09/19/installing-refit-on-the-hidden-efi-system-partition
I have filed a couple of bugs making suggestions that would make life easier for people trying to install Fedora on Mac's. I don't see that any of these suggestions would adversely affect users of other systems, but it will be up to the package maintainers and developers to decide if these changes are truly wise:
https://bugzilla.redhat.com/show_bug.cgi?id=746434
https://bugzilla.redhat.com/show_bug.cgi?id=746421
I have also encountered issues with my system that has a Radeon X1600 video card. Some reported this issue already here, but this is probably not specific to Mac's. I have gotten to a working installation, but have not gone through it, so if someone has and has additional info on how to get things working post-install, if necessary, I would appreciate knowing what they are.
https://bugzilla.redhat.com/show_bug.cgi?id=735860
What you will need
- Fedora 16 x864_64 Installation Media
- OS X Install DVD
- FAT Formatted thumb drive
- A second computer running Fedora 16 x86_64 (a VM would be acceptable)
- Patience.
- grub2-efi.i686 rpm. You'll need to grab it from koji.fedoraproject.org, download.fedoraproject.org, or where ever; it is not in the x86_64 repos.
Process
In all cases you should:
- Complete the Installation Media instructions.
- Complete the model specific instructions.
- Complete the install to taste.
- Complete the post-install instructions.
Installation Media
We will perform these steps on a second computer running Fedora 16 x86_64. A VM is acceptable, if you don't have another physical system running Fedora.
1. Install grub2-efi.x86_64 if it is not already installed.
2. Run the following command in an empty temporary directory. When done you should end up with a file called BOOTX64.efi. This is the 64-bit EFI image.
grub2-mkimage -d /usr/lib/grub2-efi/x86_64-efi/ -o BOOTX64.efi \ -O x86_64-efi --prefix /efi/boot part_gpt part_msdos lvm fat ext2 \ chain boot configfile normal minicmd linux reboot halt search \ gfxterm gfxmenu efi_gop efi_uga video loadbios gzio video_bochs \ video_cirrus echo true loadenv
3. Copy the newly created BOOTX64.efi file to /EFI/BOOT/BOOTX64.efi on your thumb drive.
Note: If you know that your Mac is using a 64-bit EFI implementation you can skip this steps 4 through 6. Otherwise you should plan to execute them.
4. We can't install grub2-efi.i686 since it conflicts with grub2-efi.x86.64, but we only need one folder, so we will get it the hard way:
a. Get grub2-efi.i686 from koji, the Fedora i686 repos, or where ever you prefer.
b. Use rpm2cpio to convert the package to a cpio archive.
rpm2cpio grub2-efi*i686.rpm > grub2-efi.i686.cpio
c. In an empty temporary directory extract the archive
cpio -id < grub2-efi.i686.cpio
d. While in the temporary directory you extracted the archive copy the necessary files to the correct location:
cp -r usr/lib/grub2-efi/i386-efi /usr/lib/grub2-efi
5. Run the following command in an empty temporary directory. When done you should end up with a file called BOOTIA32.efi. This is the 32-bit EFI image.
grub2-mkimage -d /usr/lib/grub2-efi/i386-efi -o BOOTIA32.efi -O i386-efi \ --prefix /efi/boot part_gpt part_msdos lvm fat ext2 chain boot configfile \ normal minicmd linux reboot halt search gfxterm gfxmenu efi_gop efi_uga \ video loadbios gzio video_bochs video_cirrus echo true loadenv
6. Copy the newly created BOOTXIA32.efi file to /EFI/BOOT/BOOTIA32.efi on your thumb drive.
7. Create /EFI/BOOT/grub.cfg on your thumb drive.
set timeout=30
set default=0
menuentry "Fedora 16-Alpha askmethod" {
search --set -f /images/pxeboot/vmlinuz
linux /images/pxeboot/vmlinuz askmethod
initrd /images/pxeboot/initrd.img
}
menuentry "Fedora 16-Alpha fakebios askmethod" {
fakebios
search --set -f /images/pxeboot/vmlinuz
linux /images/pxeboot/vmlinuz askmethod
initrd /images/pxeboot/initrd.img
}
menuentry "Fedora 16-Alpha MacBook fakebios, askmethod, nomodeset" {
fakebios
search --set -f /images/pxeboot/vmlinuz
linux /images/pxeboot/vmlinuz nomodeset askmethod
initrd /images/pxeboot/initrd.img
}
menuentry "Fedora 16-Alpha MacBook fakebios, askmethod, nomodeset, and VNC" {
fakebios
search --set -f /images/pxeboot/vmlinuz
linux /images/pxeboot/vmlinuz nomodeset vnc askmethod
initrd /images/pxeboot/initrd.img
}
menuentry "Fedora 16-Alpha rescue" {
search --set -f /images/pxeboot/vmlinuz
linux /images/pxeboot/vmlinuz rescue
initrd /images/pxeboot/initrd.img
}
menuentry "Fedora 16-Alpha fakebios rescue" {
fakebios
search --set -f /images/pxeboot/vmlinuz
linux /images/pxeboot/vmlinuz rescue
initrd /images/pxeboot/initrd.img
}
7. Copy /images/pxeboot from your Fedora installation media to /images/ on your thumbdrive. This should leave you with /images/pxelinux/vmlinuz and /images/pxelinux/initrd.img
Model Specific Instructions
Macbook Air (Original)
1. Insert the thumb drive in your Mac and boot holding the Alt key. You should get the option to EFI Boot the thumbdrive. Do so. By default it will install from the internet, but you can use askmethod on the kernel line to change the behavior.
2. The firmware for the Macbook Air's wireless is not distributed with Fedora which means it will not work during the installation, so you're probably going to need to just go ahead and copy the entire install tree to your thumb drive so you can complete the install, since the only USB port will be tied up with your thumb drive. I'm sure there are other ways around this, though this is probably the easiest. And once you are done b43-fwcutter can be used to get the firmware installed so that your wireless works.
3. Complete your install, but do not reboot when it finishes.
4. It is my understanding that grub2 is not being used on EFI systems so the installer actually won't let you create /boot on lvm. If you really want to you can circumvent it during the post install. To do this, I created a 50 MB /boot/efi, and 150MB /boot. Once the install finished I move the contents of sda2 onto (macbookair-root)/boot partition. I then deleted /boot and /boot/efi and recreated /boot/efi as a 200MB vfat partition. All this was simply so that I could have everything but the EFI partition on LVM, even if strictly speaking, it was not necessary. I also had to remove the old /boot partition from the /etc/fstab of course.
MacBook 2,1
1.) Insert the thumb drive in your Mac and boot holding the Alt key. You should get the option to EFI Boot the thumb drive. Do so. Use one of the fakebios boot options, otherwise your keyboard will end up dead and you will not be able to proceed with the install.
MacBook Pro 2,2
1.) Insert the thumb drive in your Mac and boot holding the Alt key. You should get the option to EFI Boot the thumb drive. Do so. Use one of the fakebios boot options, otherwise your keyboard will end up dead and you will not be able to proceed with the install. In my case my MacBook Pro had an X1600 and suffers from the radeondrmfb bug mentioned in the intro, so I had to use the the 'fakebios nomodeset' or 'fakebios nomodeset vnc" options to complete a text or VNC install.
2.) In the case of this model I would suggest booting legacy mode, rather than EFI. EFI booting will technically work, but due to graphics issues with the X1600 video card you are not likely get X Windows working. I have only been able to use the radeon driver with the modeset=0 option, or efifb with the radeon driver blacklisted. Loading the radeon driver without modeset=0 caused the system to lock up instantly. Neither of the other two options provide working X. By using parted to create an msdos label for the disk and using the nogpt option for anaconda you should be able to avoid using gpt/EFI and so you can boot into legacy mode and get a working display.
Mac Mini (mid-2011)
1.) Insert the thumb drive in your Mac and boot holding the Alt key. You should get the option to EFI Boot the thumb drive. In my case my Mini had an ATI card and suffers from the radeondrmfb bug mentioned in the intro, so I had to use the the 'fakebios nomodeset' or 'fakebios nomodeset vnc" options to complete a text or VNC install. I have only been able to use the radeon driver with the modeset=0 option, or efifb with the radeon driver blacklisted. Neither of the other two options provide working X.
Installation
1.) Complete your install, but do not reboot when it finishes.
How you partitioned your disk will have some impact on the remaining steps below. I went with a very straight forward partitioning scheme consisting of:
sda1 /boot/efi fat ~200MB
sda2 Physical Volume ~150GB
On LVM I had a single VG named macbook and two LV's:
root / ~146GB (/dev/mapper/macbook-root)
swap swap ~4G (/dev/mapper/macbook-swap)
You can also have a /boot partition on lvm (which is possible with GRUB2) or as a standard partition, (if you want to encrypt /, for example) - just be mindful that you will have to adapt the instructions below, for the most part simply removing "/boot" from the lines in the grub.cfg and adapting the set root line appropriately.
Post-Install
1.) Once again, when your install is complete do not reboot. If you were hasty and rebooted already, you can reboot in rescue mode from the media you created and complete these steps.
2. Peess ctrl-alt-f2 to get a terminal.
3. chroot /mnt/sysimage
4. Mount your thumb drive under /mnt
5. Copy the BOOTIA32.efi and BOOTX64.efi file from your thumbdrive to your fat formatted efi partition in the EFI/BOOT dir, which should now be mounted under /boot/efi so that you have /boot/efi/EFI/BOOT/BOOTIA32.efi and /boot/efi/EFI/BOOT/BOOTIX64.efi
6. Create a basic grub.cfg file in /boot/efi/EFI/BOOT and add the fakebios option if you have one of the models that normally boots to a dead keyboard (making sure to match your kernel version of course):
set timeout=5
set default=0
set root=(macbook-root)
menuentry "Fedora 16-Alpha (3.1.0-0.rc8.git0.0.rc16.x86_64)" {
fakebios
linux /boot/vmlinuz-3.1.0-0.rc8.git0.0.fc16.x86_64 root=/dev/mapper/macbook-root ro
initrd /boot/initramfs-3.1.0-0.rc8.git0.0.fc16.x86_64.img
}
7. Link /etc/grub2-efi.cfg to /boot/efi/EFI/BOOT/grub.cfg so it gets updated when new kernels are installed.
10. If you have one of the models that normally boots with a dead keyboard edit /etc/grub.d/10_linux. Below line 77 add:
cat << EOF fakebios EOF
Note: Editing this file is probably a bad idea, since it can be overwritten by updates, but I haven't found a better way yet.
11. Shut down
Final Steps
1. You should now be able to hold down the Alt key when starting your mac so that you get the option to EFI Boot into Fedora from the hard drive. You should also notice that if you just boot your Mac without holding the Alt key it will just blink a folder icon and be very sad.
2. To fix this, boot off a Mac OS X DVD.
3. One it loads open a terminal from the Utilities menu.
4. Check to see that your /boot/efi partition was mounted (if is it is probably /Volumes/Untitled. If not, mount it: (i.e., mkdir /Volumes/UNTITLED; mount -t msdos /dev/disk0s1 /Volumes/Untitled)
5. Run:
ioreg -l -p IODeviceTree | grep firmware-abi
(thanks to: http://macperformanceguide.com/SnowLeopard-64bit.html for this command)
6. depending on whether this returns EFI64 or EFI32 run the appropriate command
bless --mount /Volumes/Untitled --setBoot --file \ /Volumes/Untitled/EFI/BOOT/BOOTIA32.efi
or
bless --mount /Volumes/Untitled --setBoot --file \ /Volumes/Untitled/EFI/BOOT/BOOTIX64.efi
7. Shut down without installing OS X :)
8. Boot your system.
9. Hopefully at this point you are enjoying Fedora.
10. You may wish to run grub2-efi-makeconfig once you're up and running and replace /boot/efi/EFI/grub.cfg with it. Though probably not strictly necessary it will give you a more standard config.

