Whacking AppleEFI into fast-booting Ubuntu 12.04 via grub2

Sep 28, 2013 23:05

Let's face it folks, Apple's firmware isn't EFI1 and it isn't UEFI2 either. It's a weird "hybrid", i.e. mess. I posted quite some time ago about how to make AAPLEFI find grub2-efi, but it's slow because the firmware scans all boot devices looking for bootx64.efi files, and it's not easily recoverable if your machine forgets one of the pieces it needs. What you really want is fastboot mode where the EFIVARS retains the location of the bootloader. This is /fairly/ simple if you're already booted with BIOS/CSM.

(Hopefully you left enough space to create a EFI boot partition somewhere. It can be quite small.)

1. Format disk (say /dev/sdX) with GPT label. Use gdisk.
2. Create smallish partition (64MB) with type AB00 and name 'Recovery HD'.
3. Format partition as HFS+.
4. Run blkid -o udev /dev/sdXY to ensure that you got a HFS+ with a UUID. The partition must have a UUID for the AAPLEFI to recognize it.
4. mkdir /efiboot and make an fstab entry to automount the small partition.
5. Mount partition.
6. mkdir -p /efiboot/EFI/grub/ /efiboot/EFI/boot/ /efiboot/System/Library/CoreServices/
7. apt-get install grub-efi-amd64
8. grub-install /dev/sdX
9. ln /efiboot/EFI/grub/grub.efi /efiboot/EFI/boot/bootx64.efi
10. update-grub
11. touch /efiboot/mach_kernel
12. ln /efiboot/EFI/grub/grub.efi /efiboot/System/Library/CoreServices/boot.efi
13. Dump the following into /efiboot/System/Library/CoreServices/SystemVersion.plist:

ProductBuildVersion

ProductCopyright

ProductName
Ubuntu
ProductUserVisibleVersion
12.04
ProductVersion
12.04

14. Reboot to MacOS.
15. diskutil mount /dev/diskXsY
16. bless --folder=/Volumes/some_volume --file=/Volumes/some_volume/efi/grub/grub.efi --setBoot. Or you can use the Startup Disk Preference panel to select the disk.
17. Reboot to Linux. Hopefully it comes up super-fast; if not, it'll eventually find the bootx64.efi.
18. When you're satisfied, go back to gdisk and tell it to recreate protective MBR. This erases your legacy grub2 installation.
Previous post Next post
Up