When I installed Debian on my MacBookAir4,1 in 2012, there was no way to do it without manual intervention yet. I followed a tutorial on how to boot GRUB from the EFI Boot option in the MacBook EFI Menu. I did not want to fiddle with rEFIt, and I didn’t want to boot GRUB by default. When I want to boot Linux, I press the Option key during power up and select EFI Boot from the Apple boot menu.
Unfortunately, I neglected to collect notes about how I did it manually. However, Linux 3.2 is getting a bit old, so I finally wanted to replace my manual boot configuration with something handled by the package system.
In case you don’t have
/etc/fstab yet, you need to mount
/boot/efi for the following to work.
The documentation I found on the net suggested to just reinstall
grub-efi-amd64 and everything should work. That is not quite true. When I do
# apt-get install --reinstall grub-efi-amd64
Nothing changes in
I sort of expected that
/boot/efi/EFI/debian would be created, and the EFI image should be placed in there. However, that did not happen. Why is that?
It turns out that when I installed
grub-efi-amd64 manually in 2012, I created
/boot/efi/EFI/boot/bootx64.efi which is the EFI fallback location, and apparently exactly what I want on this MacBook which does not support multiple boot options. Matthew Garrett posted an interesting article called Booting with EFI which sheds light on this issue, go and read it.
/var/lib/dpkg/info/grub-efi-amd64.postinst revealed that
/boot/efi/EFI/debian needs to be created manually first. If this directory does not exist,
grub-efi-amd64 basically does nothing on reinstall.
grub-install will actually create a new EFI image. However, it is being created in the wrong place for this machine.
# grub-install --target=x86_64-efi
does the trick. Now
/boot/efi/EFI/debian/grubx64.efi gets created. However, since I don’t want to make GRUB the default, there is yet another manual step to do:
# cp /boot/efi/EFI/debian/grubx64.efi /boot/efi/EFI/boot/bootx64.efi
Now I can select EFI Boot after pressing the Option key during startup. GRUB is loaded and Linux 3.13 gets booted. Strike!
Looking more closely reveals that there is actually a way to tell
grub-install that it should install to the fallback location directly. The
--removable option does that.
For the faint of heart, what does
grub-install actually do on an EFI system? It does not directly write to the disk, therefore it does not need a device specified. It looks for files in
/boot/efi and assumes the EFI partition is mounted there.
So for my use case, the correct way to upgrade to a current GRUB EFI image should have been:
# grub-install --removable --target=x86_64-efi
Meanwhile I’ve been made aware of Bug#708430. I guess it would be nice to have an option in
/etc/default/grub which would indicate that installation to the fallback location is desired. While this is a rather ugly hack to work around a stupid limitation, it is still what I’d like on this MacBook. At least since I don’t have a triplle boot situation. Fallback location works fine with just two OSes coexisting.