Mac - ArchWiki

Jump to content
From ArchWiki

Related articles

- Mac/Troubleshooting
- Laptop/Apple
- Apple Fusion Drive

Warning: ARM architectures are supported by Arch Linux ARM however it does not support Apple M series chips yet. For Linux support information for Macs with M series chips, see the Asahi Linux project. Both Arch Linux ARM and Asahi Linux are downstream projects that not officially endorsed by Arch Linux, you may go to Arch Linux ARM Forum and Asahi Linux Community for help.

This page complements the Installation guide with instructions specific to Apple Macs. The Arch installation image supports Apple Macs with Intel processors, but neither PowerPC nor Apple Silicon processors.

## Overview

Summed up, the procedure for installing Arch Linux on a Mac is:

1. Pre-installation: Miscellaneous steps before partitioning.
2. Partitions: Resizing or deleting the macOS partition to create partitions for Arch Linux.
3. Installation: Actual installation.
4. Setup boot loader: Making sure that the new partition is bootable.
5. Post-installation: Device-specific configuration.

## Pre-installation

Before proceeding with the installation of Arch Linux, follow these steps.

1. Install macOS and install its updates. macOS is the only known method for installing firmware updates, even though the OS will not be necessary after installing Arch. See Apple's instructions.
2. Open ColorSync Utility, find the current `.icc` color profile, and save the file elsewhere. The profile can later be used to set the display colors correctly. See color profile.
3. Set the volume on macOS, which will be the volume of the startup chime. If the volume is muted, the startup chime will also be muted. See mute startup chime.

## Partitions

If only Arch Linux is desired, then format the entire disk according to Installation guide#Partition the disks. To set up dual boot, follow these steps. Once done, go to #Installation.

### Arch Linux with macOS or other operating systems

Macs typically have the following partition table. In Macs that use the Apple Fusion Drive, the partition scheme could be different.

- EFI: the ~200 MB EFI system partition.
- macOS: the main partition containing your macOS installation, either HFS+ or APFS.
- Recovery: If not using APFS, a recovery partition is present. If using APFS, this partition is not present.

To install Arch with macOS, keep these partitions, and follow these steps.

1. You may need to turn off FileVault before resizing the macOS partition. See Apple's instructions.
2. Run Disk Utility, select the drive to be partitioned in the left-hand column, and click Partition. Do not create a container.
3. Add a new partition by pressing the + button and choose how much space you want to leave for macOS, and how much for the new partition. The new partition will be formatted in Arch Linux, so you can choose any partition type you want.
4. Optionally, make any other partitions you may need for your setup. See Partitioning#Partition scheme for more information.

Here is an example setup with five discrete partitions:

    partition  mountpoint  size          type  label
    /dev/sda1  /efi        200MiB        vfat  EFI
    /dev/sda2  -           ?             hfs+  macOS
    /dev/sda3  -           ?             hfs+  Recovery
    /dev/sda4  -           100MiB        hfs+  Boot Arch Linux from the Apple boot loader (optional)
    /dev/sda5  /boot       100MiB        boot  boot
    /dev/sda6  -           ?             swap  swap (optional)
    /dev/sda7  /           15-20GiB      ext4  root
    /dev/sda8  /home       remaining     ext4  home

Note:

- See #Installing a boot loader to a separate HFS+ partition for more information on booting Arch Linux from the Apple boot loader.
- An existing EFI system partition can be used by Arch Linux without needing to create an additional one.

## Installation

These steps install Arch, assuming #Pre-installation and #Partitions are done.

1. Boot the live environment by holding down `Alt` or `Option` during boot.
2. If the keyboard has long delays or character doubling, reboot with the following kernel parameters: `arch noapic irqpoll acpi=force`.
3. Proceed through the installation as described in the Installation guide except in the following areas:
   1. Skip the partition the disks stage, do only the partition formatting and mounting steps, taking care to assign the correct partitions. Partitions have already been created if you followed #Partitions
   2. When at the install boot loader stage, follow #Setup boot loader
   3. (for booting with BIOS-compatibility) Add `reboot=pci` as a kernel parameter. This will allow your Mac to reboot correctly from Arch.
4. When the install process is complete, reboot your computer.
5. During boot, if using optical disk, hold down the eject key to eject the disk.
6. During boot, if using systemd-boot or GRUB, hold down the `Alt` key to bring up the Apple boot menu, and select "EFI Boot." If using rEFInd, boot without holding any keys.

## Setup boot loader

Macs use UEFI for booting, so any UEFI boot loader will work. The built-in boot loader (shown when holding `Alt` during boot) will detect any EFI system partition that has a `/EFI/BOOT/BOOTX64.EFI` file, showing it as a "EFI Boot" entry. Most UEFI boot loaders support installing directly to this location, making a dual boot setup easy.

The boot loader also has an alternate partition discovery method described in #Installing a boot loader to a separate HFS+ partition which is the method used for booting macOS, but can also be used for Linux.

Tip:

- The UEFI firmware on a Mac can also be configured via efibootmgr.
- To set a volume as the default boot entry using the Apple boot loader, hold down `Ctrl` while selecting it.

### Using the native Apple boot loader with systemd-boot

Follow the instructions at systemd-boot#Installation to install systemd-boot. At the next reboot, hold down the `Alt` key when booting the Mac, and the Apple boot loader should display Arch Linux (it will be displayed as `EFI Boot`) as a possible boot option.

Tip: If you installed Arch Linux alongside macOS, you will be able to change the default boot location from system Settings inside macOS. If Arch Linux does not show up as a possible boot option, you will have to mount the EFI System Partition inside macOS before selecting your boot option:

    # mkdir -p /Volumes/EFI
    # mount_msdos /dev/disk0s1 /Volumes/EFI

### Using rEFInd

To install rEFInd to the `/EFI/BOOT/BOOTX64.EFI` location, run:

    # refind-install --usedefault /dev/sdXY

Where `/dev/sdXY` is the EFI system partition. After installing, see rEFInd#Configuration to finish setup.

#### Installing from macOS

These steps assume macOS is still installed on a partition, and the steps of the Installation guide were completed up to Installation guide#Boot loader. Boot into Safe Mode by holding down `Command+R`, then disable SIP.

    # csrutil disable

Boot macOS, and run the rEFInd install script,

    # ./refind-install --alldrivers

rEFInd installed itself into Apple's boot partition, and replaced Apple's boot menu with its own. Boot into Safe Mode by holding down `Command+R`, and enable SIP.

    # csrutil enable

Reboot without holding down any keys. Arch should be recognized as `vmlinuz-linux` by default. If it is not, uncomment the lines `scan_all_linux_kernels` and `also_scan_dirs` in `refind.conf`. For configuration, see rEFInd#refind_linux.conf. Since rEFInd by default mounts root as ro, it is recommended to create refind-linux.conf.

### Using the native Apple boot loader with GRUB

If you would like to use GRUB as your main boot loader and use the "boot while holding the `Alt` key" method to go back to macOS, then install GRUB to the already-existing EFI system partition made by macOS. The process is similar to #Using the native Apple boot loader with systemd-boot. Just follow GRUB#Installation and add `--removable` when running `grub-install`.

### Installing a boot loader to a separate HFS+ partition

Despite using UEFI, the Mac native EFI boot loader does not use the EFI system partition for booting macOS. Instead, it uses the following conditions to find existing macOS installations inside all the partitions in internal and external drives and shows them as possible boot options if they are satisfied:

- The partition is formatted as HFS+
- The partition type ID is `af00` ("Apple HFS/HFS+")
- In the root of the partition, there is a file called `mach_kernel`
- Inside that partition, there a `boot.efi` file inside `/System/Library/CoreServices`

The advantage of this method to boot Arch over using a `BOOTX64.EFI` file in the EFI system partition is that it can coexist with macOS nicely, showing the partition as a bootable volume in the macOS Startup Disk settings. However, this method requires manual configuration. The following steps will illustrate how to perform this configuration using GRUB.

First, create a new HFS+ partition. This can be done through the macOS Disk Utility, or the `mkfs.hfsplus` tool in the hfsprogsAUR package. The size and mount point of the partition depend on how you plan to use it:

- If you plan on using it as the /boot directory, give it at least 300 MB;
- If you are going to keep your kernels in another partition and use a boot loader that can load other file systems, like rEFInd or GRUB, the partition can be smaller and be mounted anywhere you want.

Mount the partition, then create the `mach_kernel` file:

    # touch /mountpoint/mach_kernel

Create the directory structure for the boot loader:

    # mkdir -p /mountpoint/System/Library/CoreServices

Now you can install any UEFI boot loader you want. For example, to do a manual install of rEFInd:

    # cp -r /usr/share/refind/* /mountpoint/System/Library/CoreServices/
    # mv /mountpoint/System/Library/CoreServices/refind_x64.efi /mountpoint/System/Library/CoreServices/boot.efi

Finally, you can create an optional `/mountpoint/System/Library/CoreServices/SystemVersion.plist` file that will display some information about the volume in the macOS Startup Disk settings:

    /mountpoint/System/Library/CoreServices/SystemVersion.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <plist version="1.0">
    <dict>
           <key>ProductBuildVersion</key>
           <string>rolling</string>
           <key>ProductName</key>
           <string>Arch Linux</string>
           <key>ProductUserVisibleVersion</key>
           <string></string>
           <key>ProductVersion</key>
           <string></string>
    </dict>
    </plist>

After following these instructions, the new volume will appear on the Mac boot loader when holding down `Alt` during boot, and it will also appear as a bootable volume in the macOS Startup Disk options.

### Using blessing

It is possible to boot directly from GRUB in EFI mode without using rEFIt through what is known as "blessing" after placing GRUB on a separate partition. These instructions are known to work on a MacBook7,1. It is advisable to host GRUB on either a FAT32 or HFS+ partition, but ext2 or ext3 may also work.

After the GRUB install is in the desired location, the firmware needs to be instructed to boot from that location. This can be done from either an existing macOS install or an macOS install disk. The following command assumes that the GRUB install is in `/efi/grub/` on an existing macOS partition:

    # bless --folder /efi/grub --file /efi/grub/grub.efi

## Tips and tricks

### Color Profile

Macs use ICC profiles which can easily be loaded in Arch. The current profile can be shown using ColorSync Utility or System Preferences > Displays > Color. These files correspond to particular models,

- `Color LCD-4271800.icc` for MacBook Pro with CoreDuo CPU
- `Color LCD-4271880.icc` for MacBook with Core2Duo
- `Color LCD-4271780.icc` for MacBook (non-Pro) based on CoreDuo or Core2Duo.
- `Color LCD-68FE312B-5EF0-E0A1-BCD8-8890B73C7B3A.icc` for MacBookPro9,2 (Mid-2012)

Note:

- The previous command sets the color profile only for the current session. autostart it.
- GNOME will revert the profile set by xcalib. It is preferable to set the profile using Color in settings.

### Apple Remote

Install and configure lirc. See LIRC.

Make LIRC use `/dev/usb/hiddev0` or `/dev/hiddev0`:

    /etc/conf.d/lircd

    #
    # Parameters for lirc daemon
    #
    LIRC_DEVICE="/dev/usb/hiddev0"
    LIRC_DRIVER="macmini"
    LIRC_EXTRAOPTS=""
    LIRC_CONFIGFILE="/etc/lirc/lircd.conf"

Use irrecord to create a configuration file matching your remote control signals:

    # irrecord -d /dev/usb/hiddev0 -H macmini output_conf_file

Start `lircd.service` and use irw to check if it works.

Alternatively, use the following:

    /etc/lirc/lircd.conf

    begin remote

      name  lircd.conf.macbook
      bits            8
      eps            30
      aeps          100

      one             0     0
      zero            0     0
      pre_data_bits   24
      pre_data       0x87EEFD
      gap          211994
      toggle_bit_mask 0x87EEFD01

          begin codes
              Repeat                   0x01
              Menu                     0x03
              Play                     0x05
              Prev                     0x09
              Next                     0x06
              Up                       0x0A
              Down                     0x0C
          end codes

    end remote

### HFS+ Partitions

#### HFS partition sharing

Install hfsprogsAUR and use fdisk to list the partitions:

    # fdisk -l /dev/sda

       Device  Boot     Start         End      Blocks   Id  Type
    /dev/sda1               1          26      204819   ee  GPT
    /dev/sda2              26       13602   109051903+  af  Unknown
    /dev/sda3   *       13602       14478     7031250   83  Linux
    /dev/sda4           14478       14594      932832+  82  Linux swap / Solaris

The "Unknown" partition is our macOS partition, which is located in `/dev/sda2`. We can use this in our fstab:

    /etc/fstab

    /dev/sda2    /path/to/shared/hfs_partition     hfsplus auto,user,rw,exec   0 0

It can then be mounted, and the content accessed.

#### Bad Superblock Error

This section addresses error message when mounting hfsplus partition:

    # mount -t hfsplus dev/sdX force,ro

    wrong fs type, bad option, bad superblock on /dev/sdX, missing codepage or helper program, or other error.

Since Yosemite, HFS+ partitions are now wrapped a CoreStorage volume. Verify that you have an CoreStorage volume.

    # fdisk -l /dev/sdX

    Disk /dev/sdX: 298.1 GiB, 320072933376 bytes, 625142448 sectors
    Units: sectors of 1* 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: gpt
    Device      Start      End         Sectors    Size     Type
    /dev/sdX1   40         409639      409600     200M     EFI System
    /dev/sdX2   409640     623872871   623463232  297.3G   Apple Core storage
    /dev/sdX3   623872872  625142407   1269536    916.0M   Apple boot

HFS+ uses two volume headers, one 1024 bytes into the device and one 1024 from the end of the device. With the HFS+ partition wrapped in the CoreStorage volume the end of the partition is not actually 1024 bytes from the end of the `/dev/sdX2` partition. To fix this you need to specify `sizelimit=X` when mounting.

To determine `sizelimit` do the following:

1. Run `testdisk /dev/sdX` and select your drive
2. Select `EFI GPT`
3. Select `Analyse` and then `Quick Search`

Sample output:

    TestDisk 7.0, Data Recovery Utility, April 2015
    Christophe GRENIER <grenier@cgsecurity.org>
    https://www.cgsecurity.org

    Disk /dev/sdX  - 320 GB / 298 GiB - CHS 38913 255 63
        Partition     Start      End        Size in sectors
    P  EFI System     40         409639     409600  [EFI]
    P  Mac HFS        409640     623147815  622738176
    P  Mac HFS        623872872  625142407  1269536

What you see now is the output of the HFS partition itself without the CoreStorage volume. Take the size in sectors (622738176 in this example) and multiply by the number of bytes in your logical sector size (512 in this example).

622738176 * 512 = 318841946112

Finally, mount your disk with the `sizelimit=X` option.

     mount /dev/sdX -t hfsplus -o ro,sizelimit=318841946112

#### Disable Journaling

HFS+ partitions are not fully supported by Linux and are mounted as read-only by default. In order to write to an HFS+ partition, the safe way is to disable journaling. This can be accomplished using the macOS Disk Utility. Refer to this Apple support page for more information or try to do it from the command line:

Find your partition:

    # diskutil list

    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *750.2 GB   disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                  Apple_HFS macOS                   149.5 GB   disk0s2
       3:                  Apple_HFS Macintosh HD            599.2 GB   disk0s3
       4:                 Apple_Boot Recovery HD             650.0 MB   disk0s4

In this example we will use disk0s3 partition named as Macintosh HD. To know if journaling is activate or not you could execute:

    # diskutil info /dev/disk0s3 | grep -i journal

        File System Personality:  Journaled HFS+
        Name (User Visible):      Mac OS Extended (Journaled)
        Journal:                  Journal size 49152 KB at offset 0x1176000

As you can read the journaling is active. To turn off the journaling you could execute:

    # diskutil disableJournal disk0s3

To verify it is done execute the info command again.

If you get noting as output, then journaling is disabled.

However, if you fail to disable journaling. You can change "auto,user,rw,exec" in `/etc/fstab` to "auto,user,force,rw,exec" and mount it.

### UID synchronization for home sharing

If you want to access your macOS user directories from Linux, write down the UID and GID for the users. macOS begins with the first user's UID at 501 while Arch defaults to 1000.

Warning: Never change any file permissions in your macOS partition from Linux.

#### In macOS

Note: It is strongly recommended that UID/GID manipulation be done immediately after a new user account is created, in macOS as well as in Arch Linux. If you installed macOS from scratch, then this operation is guaranteed to work after logging into your account for the first time.

##### Change UID and GID(s)

The default UID and GID on Arch Linux for a user is 1000, adjust the following steps according to your setup.

###### Pre-Leopard

1. Open NetInfo Manager located in the `/Applications/Utilities` folder.
2. If not done for you already, enable access to user account transactions by clicking on the closed lock at the bottom of the window, and entering your account password, or root password if you have created a root account.
3. Navigate to `/users/new_user_name`
4. Change the UID value to 1000
5. Change the GID value to 1000
6. Navigate to `/groups/new_user_name`, automatically saving the changes you have made so far.

Note: If you get an error message that the transaction is not allowed, log out and log back in.

###### Leopard

In Leopard, the NetInfo Manager application is not present. A different set of steps is required for UID synchronization:

1. Open System Preferences.
2. Click on Users & Groups.
3. Unlock the pane if not already done so.
4. Right-click on the desired user and select Advanced Options.
5. Write down the value of the User ID field, you will need it later on. Change both the UID and GID to match the UID and GID of the account to be shared with in Arch.

##### Change "Home" permissions

1. Open up Terminal in the `/Applications/Utilities` folder.

1. Enter the following command to reclaim the permission settings of your home folder:

    # find /User/your_user_name -user your_old_UID -exec chown your_user_name:your_user_group {} \;

#### In Arch

To synchronize your UID in Arch Linux, you are advised to perform this operation while creating a new user account. It is therefore recommended that you do this as soon as you install Arch Linux.

    # useradd -m -u [uid] -g [gid] -G [additional_groups] -s [login_shell] [username]

Now you must substitute Arch's home with macOS's home, by modify entries of `/etc/fstab`. In order to be able to access a macOS user's directory, only the uid and gid need to match (usernames can differ).

### Mute startup chime

The startup chime volume is controlled by the EFI variable SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82. So it can be muted with

    # printf "\x07\x00\x00\x00\x00" > /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82

Bear in mind that the file may have the immutable bit set by default, which will prevent even root from overwriting the file. See File permissions and attributes#File attributes. To remove it, issue the following:

    # chattr -i /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82

After that, run the `printf` command and it should overwrite the file properly. Verify the file's contents and then set the immutable bit again with `chattr +i` once satisfied.

Alternatively, you can use a macOS install disk to mute the chime. Boot from it, select language, then click Utilities > Terminal, and enter

    # /usr/sbin/nvram SystemAudioVolume=%percentage

Note: Required formatting of the value provided for key SystemAudioVolume may differ depending on models and perhaps the version of macOS install media. If the above command fails to work, try enclosing the value in double quotes.

### Custom icon in the boot loader

The Mac boot loader supports loading custom icons for each volume it detects. The custom icon must be in the `.icns` format, and be located at the root of the volume containing the boot loader, with the file name `.VolumeIcon.icns`.

The following example downloads an Arch logo SVG with wget, converts it to PNG with librsvg and then converts it to an `.icns` with libicns:

    $ wget -O /tmp/archlinux.svg https://archlinux.org/logos/archlinux-icon-crystal-64.svg
    $ rsvg-convert -w 128 -h 128 -o /tmp/archlogo.png /tmp/archlinux.svg
    # png2icns /boot/.VolumeIcon.icns /tmp/archlogo.png

Obviously, you can replace the Arch logo with any other icon you like.

## See also

- Laptop/Apple
- MacBookPro10,x
- MacBookPro11,x
- https://wiki.t2linux.org/
- MacBook Air
  - Macbook Air Early 2014 — dabase.com
  - Installing Linux on a Macbook Air (4,2) — Nico Schottelius
  - MacBook Air (7,2) - Adham Nasr
- MacBook Pro
  - http://allanmcrae.com/2010/04/installing-arch-on-a-macbook-pro-5-5/
  - http://allanmcrae.com/2012/04/installing-arch-on-a-macbook-pro-8-1/

Category:

- Apple