Arch Linux - MacBook Pro 9.2
EFI boot using native Apple boot loader with GRUB
- Introduction
- Make Arch Linux bootable from MacBook's boot manager
- Customise boot loader icon
- Prevent macOS from mounting the EFI partition
- References
Introduction
This guide shows how to install Arch Linux in UEFI mode on a MacBook Pro 9.2. The installation will have the following characteristics:
- macOS is installed and booted by default;
- neither rEFIt nor rEFInd is used, and
- Arch Linux can be booted by pressing and holding alt after turning on the computer.
It will be assumed that
- macOS is already installed;
- the EFI partition used to install Arch Linux is not the same EFI partition used by macOS, and
- a USB installer is used.
Partition scheme
According to [1], the MacBook's native EFI boot loader looks for .efi
files inside
all partitions in internal and external drives and shows them as possible boot options if certain conditions are
satisfied. Particularly, MacBooks can detect an existing macOS installation after checking that
- there is a partition formatted as HFS+;
- the partition contains the partition id
af00
; - in the root of that partition, there is a file called
mach_kernel
, and - inside that partition, there is a
boot.efi
file inside/System/Library/CoreServices
.
Also, according to [1], it is possible to perform the installation with the already existing EFI partition used by macOS, but that is out of the scope of this guide.
The following partition scheme will be used:
Mount point | Type | Comments |
---|---|---|
/boot/EFI | EFI partition | |
/ | ext4 | root partition |
/home | ext4 | home partition |
swap | swap | in a non solid-state drive |
Installation
Follow either the ArchWiki's installation guide, up to and including the step before Boot loader, or my installation guide up to and including the step before Boot loader. Then continue with this guide.
Make Arch Linux bootable from MacBook's boot manager
Install utilities for HFS+ filesystem
Switch to an unprivileged user <user>
for building and installing the hfsprogs
package from AUR
$ su <user> $ cd ~
Install the hfsprogs package
WARNING: Carefully check the PKGBUILD, any .install files, and any other files in the package for malicious or dangerous commands.
$ git clone https://aur.archlinux.org/hfsprogs.git $ cd hfsprogs $ makepg -si
Switch back to root user by executing exit
or pressing Ctrl+D.
Fix EFI partition
Find out the partition mounted on /boot/efi
$ mount | grep /boot/efi
and unmount it
$ umount /dev/sd<De>
where <De>
refers to the device identifier and partition number of the EFI partition.
Update the EFI partition
$ fdisk /dev/sd<D>
- Type
p
and look for the numbere
of the EFI partition number. - Type
d
and specify the partition numbere
. - Type
n
and specify the partition numbere
. For first and last sectors set the same values that the partition currently has. Finally, setAF00
as the filesystem code. - Type
w
.
Format the EFI partition
$ mkfs.hfsplus /dev/sd<De> -v archlinux
where <De>
are the same values as above.
Update /etc/fstab
file
Open /etc/fstab
and delete the line that refers to /boot/efi
, save and close the file.
Execute
$ bash -c 'echo UUID=$(blkid -o value -s UUID /dev/sd<De>) /boot/efi auto defaults 0 0 >> /etc/fstab'
where <De>
are the same values as above.
Mount the EFI partition
$ mount /boot/efi
Install GRUB
$ pacman -Syu grub efibootmgr $ mkdir -p /boot/efi/EFI/archlinux $ touch /boot/efi/EFI/archlinux/mach_kernel $ grub-install --target x86_64-efi --boot-directory=/boot --efi-directory=/boot/efi --bootloader-id="archlinux" $ grub-mkconfig -o /boot/grub/grub.cfg
Open /boot/efi/EFI/archlinux/System/Library/CoreServices/SystemVersion.plist
and modify the
ProductName string value to Linux
and the ProductVersion string value to
ArchLinux
.
Make MacBook's boot manager recognize the ArchLinux installation
$ mkdir -p /boot/efi/System/Library/CoreServices $ touch /boot/efi/mach_kernel $ ln /boot/efi/EFI/archlinux/System/Library/CoreServices/boot.efi /boot/efi/System/Library/CoreServices/boot.efi $ cp /boot/efi/EFI/archlinux/System/Library/CoreServices/SystemVersion.plist /boot/efi/System/Library/CoreServices/
Create a new initramfs
$ mkinitcpio -p linux
The system should now be bootable.
Customise boot loader icon
In order for a custom icon to appear on the MacBook Pro boot manager, copy a .icns
file to
/boot/efi/
$ cp <file.icns> /boot/efi/.VolumeIcon.icns
Prevent macOS from mounting the EFI partition
To prevent macOS from automatically mounting the Arch Linux EFI partition, boot into macOS and execute
$ diskutil info /Volumes/archlinux | grep "Volume UUID" | awk 'NF>1{print $NF}'
copy the UUID value, then execute
$ sudo vifs
add
UUID=<copied UUID value> none hfs rw,noauto
in a new line, save and close the file.