Sunday, February 26, 2012

Restoring the Apple's EFI on a MacBookPro with Linux

Recently, you installed GNU/Linux and deleted the /EFI/APPLE directory.
But now, you need to boot from a USB key and holding the Option button no longer works! Even the recoveryHD USB doesn't work.
Why? Because this code was located in /EFI/APPLE/.

Here is how to restore it and why not, keep your EFI up to date on a macbook pro without having MacOSX installed.

First, download the EFI update for your model:
http://support.apple.com/kb/HT1237
In my case, I have a MacBookPro8,2 so I downloaded MBP81.0047.B27 (EFI 2.7).

The DMG which is uncompressed is supposed to be moutabled under Linux using either:
$sudo mount -t hfs -o loop myImage.dmg /mnt
or
$sudo mount -t hfsplus -o loop myImage.dmg /mnt


However, I was not able do it so I had to fallback to another MacOSX installation from which I retrieved the .pkg.
Feel free to share yur experiences with DMGs under Linux!

The .pkg file is actually a xar archive (http://linux.die.net/man/1/xar).
So, install xar and uncompress the .pkg using:
$xar -xf /mnt/MacBookProEFIUpdate.pkg

In the uncompressed directory, the Payload file is actually a .tar.gz archive so uncompress it:
$tar zxf Payload

Then go in the newly created System directory and follows subdirectories until you find a .scap file. It is named like MBP81_0047_27B_LOCKED.scap.
Assuming your EFI partition is located at /boot/efi, copy this file to /boot/efi/EFI/APPLE/FIRMWARE
Do not forget to create the /boot/efi/EFI/APPLE/EXTENSIONS directory.

You can reboot, it should work again!