Arch Linux Installation on a Macbook

DRAFT

I was able to get Arch Linux up and fully running on a 2017 MacBook (12”) without pulling all of my hair out.

I’ll try to be as descriptive as possible, but please note this can’t (and shouldn’t be) a step by step guide to what I did. 90% of what I tried failed (better success rate than usual) so I can’t guarantee things I attempted but omit here didn’t have an impact (i).

Important limitations I’ve hit and haven’t solved:

Suspend/hibernate doesn’t work. Not great for a laptop.
Imagination.
Launching X11 server causes tty’s to display a colorful glitchy patch in the top right hand corner

Official Documentation

https://wiki.archlinux.org/index.php/mac

https://wiki.archlinux.org/index.php/installation_guide

Helpful General Mac installation

http://www.brycethuilot.com/Installing-Arch/

Requirements:

Flash drive with arch linux installed on it (ii)
An external keyboard
Some way to get ethernet, e.g., an ethernet to USB adapter
A way to have all three of the above plugged in at once - e.g., some sort of USB-C to three USB2.0/3.0 hub
Patience and an understanding you may screw up your Mac installation (so make a backup)

Roughly, the steps I took

  1. Add a new partition at the end of your drive using Mac’s Disk Utility
    1. I kept getting warnings and errors when repartitioning - to see the changes totally take effect, I had the restart after partitioning
    2. I also wasn’t able to add more than one partition at a time (iii)
  2. Install refind (iv)
    1. Refind is used as a boot manager
    2. Information and full install instructions can be found here http://www.rodsbooks.com/refind/installing.html#installsh, summarized below
    3. Before you can install refind, you need to disable SIP (System Integrity Protection) on your Mac
    4. Reboot, holding Command-R before the computer boots
    5. Open the terminal and run csrutil disable
    6. Download the binaries from the above website, go into that folder, and run refind-install
  3. Format the new partition you made in Part 1.
    1. Reboot, holding ALT on boot to launch from your boot drive.
      1. fdisk -l
    2. find the disk/partition you created in Step 1
    3. Note, from Mac OS this disk showed up as nvme0n1p3, but from arch, this showed
    4. mkfs.ext4 /dev/nvmeXXXnXXXpXXX
    5. BE VERY CAREFUL - you don’t want to reformat your Mac OS partition!
    6. mount /dev/nvmeXXXnXXXpXXX /mnt
    7. mount the new partition to your live USB session
  4. Confirm that you can connect to the internet and then install!
  5. ping 8.8.4.4 to make sure you have internet, then proceed with install
  6. pacstrap /mnt base
  7. pacstrap /mnt base-devel
  8. Follow the rest of the install directions in https://wiki.archlinux.org/index.php/Installation_guide#Configure_the_system
    1. This starts with genfstab
    2. Then arch-chroot for you to begin configuration
    3. Follow the rest of the suggestions :)
    4. You can do this later, but it might make it easier to set up Refind from the Linux side now
      1. A description is here: https://wiki.archlinux.org/index.php/REFInd#Configuration
      2. I don’t think you need to run refind-install from linux - try skipping it
      3. But I still had to run the following
      4. pacman -Syu refind-efi
      5. install refind on arch linux (while you’re still chrooted in)
      6. mkrlconf
      7. cat /boot/refind_linux.conf
      8. just to make sure the configuration makes sense
      9. edit it if you need to change the partition of your linux installation or pass boot parameters (iv)
  9. Get the Mac keyboard up and running!
    1. Prerequisite: linux-headers
      1. pacman -Syu linux-headers
    2. pacman -Syu dkms
    3. git clone https://github.com/cb22/macbook12-spi-driver.git /usr/src/applespi-0.1
    4. cd /usr/src/applespi-0.1
    5. dkms install -m applespi -v 0.1
    6. It might take a reboot before the keyboard is recognized, I’m not sure
  10. Get wifi working!
    1. I’m a little iffy on the exact steps, but this might work if you cross your fingers long enough (you might need to bash your head against your keyboard for a few minutes/hours, but it will work eventually!)
    2. pacman -Syu NetworkManager nmcli
      1. install both NetworkManager and nmcli
    3. NetworkManager
      1. NetworkManager must be launched before nmcli is launched
    4. nmcli dev wifi password
      1. Connect!
  11. Remove the annoying 1min30 delay on boot as arch searches for ethernet
    1. I was able to find the solution here: https://bbs.archlinux.org/viewtopic.php?id=213363
    2. User Trilby pointed out you can see the order interfaces are launched
      1. systemd-analyze critical-chain
    3. User loqs pointed out how to solve the
    4. cp /usr/lib/systemd/system/systemd-user-sessions.service /etc/systemd/system/systemd-user-sessions.service
    5. vim /etc/systemd/system/systemd-user-sessions.service
      1. change After=... line to: After=remote-fs.target nss-user-lookup.target
  12. Keyboard backlight
    1. Information on changing the keyboard backlight can be found at https://wiki.archlinux.org/index.php/mac#Keyboard_Backlight
    2. On my installation, the path was: /sys/class/leds/spi\:\:kbd_backlight_brightness/
  13. Screen Backlight/Brightness
    1. Information on changing the keyboard backlight can be found at https://wiki.archlinux.org/index.php/backlight
    2. On my installation, the path was: /sys/class/backlight/intel_backlight/

(i) On a Mac, the easiest way to create the bootable flash drive is with dd, see https://wiki.archlinux.org/index.php/USB_flash_installation_media#In_macOS (Please be very careful that you select the correct destination! You don’t want to overwrite the wrong drive!)
(ii) And presumably, hearing about the first four times I partitioned my drive may not be necessary.
(iii) This is probably not critical at this stage, but, given the recommendations for a MacOS, I shrunk the Mac OS partition a second time, by 128MB https://wiki.archlinux.org/index.php/mac#Option_1:_EFI which I later formatted to raw.
(iv) This will change the way your computer boots - from now on, you’ll have to explicitly select Mac OS before you can boot into it. Do not panic if you don’t see your Mac OS immediately when the ReFind manager launches - hit to refresh the list of available drives
(v) https://wiki.archlinux.org/index.php/REFInd or rodsbooks