Elentok's Blog

About me

Linux on the 2012 MacBook Air

Linux on Mac

Last week I tried installing Arch Linux on my 6yo MacBook Air (Mid-2012), to my surprise it went much better than expected :)

Why did I do it?

Mostly for two reasons:

  1. Performance - after the last OS X upgrade it's become sluggish and uncomfortable.
  2. Window Management - Ever since I moved to Mac I've been missing the i3 window manager. Several months ago I've switched a Linux workstation at work (from a Mac Pro) and started using i3 again which emphasized to me how terrible window management is on OS X.

Impressions so far

I've been using it for about a week and it's amazing, much better than I expected. It's not perfect, but I think overall it's better the OS X experience.

A few things that I haven't solved yet:

  • Proper lock-on-lid-close (I'm currently using xscreensaver to lock the screen but it doesn't seem to be fully synced with the lid-close event, there are instructions in the Arch Linux wiki, I haven't tried them yet).
  • Low battery warnings (Once I reached 2% the machine just shut off, I didn't have enough time to plug it in, I need to setup proper warnings).

Setup dual-boot with rEFind

I'm dual-booting Arch Linux and OS X from the internal SSD.

First, from OS X, resize your main partition and create a secondary partition (I made the main 20GB smaller to make space for the Linux partition).

Afterwards, download and install the rEFInd boot manager (I had to boot into safe/recovery mode to do that).

Once rEFInd is installed you'll have a new boot menu whenever you start your Mac which will allow to boot from Linux partition and from USB disks.

Install Arch Linux

Download the Arch Linux ISO and put it on USB disk (I used Rufus).

Restart your Mac with the USB disk inserted and you'll see it in the rEFInd boot menu.

Once you boot from it, delete HFS partition you've created in the previous step and create two partitions: "/" and "swap" (You can create other if you wish, I just needed these two).

A few notes:

  • For the base Arch installation you can following the Arch Wiki Installation Guide or my shorted version.
  • Installing Arch Linux requires an internet connection. To connect to a WiFi network, first get the name of the network interface by running ip link and then running the following commands:

    wpa_supplicant -i INTERFACE \
      -c <(wpa_passphrase "SSID" "PASSWORD")
    
    dhcpcd INTERFACE
    

    Running the DHCP client manually is only for the installation process, afterwards you can use NetworkManager to do an easier setup.

  • You can skip the step about installing Grub because rEFInd already takes care of it, it boots the kernel directly.
  • Before rebooting make sure you've installed the packages required for making WiFi connections (they're included with the live usb, but they're not installed automatically):

    sudo pacman -S iw wpa_supplicant
    

Setup keyboard shortcuts

To support the display brightness and keyboard backlight keys, install these two packages:

pacman -S xorg-backlight
yaourt -S kbdlight

Since I'm using i3 I just added the following lines to my ~/.i3/config file:

# Support the volume keys
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% && killall -SIGUSR1 i3status
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% && killall -SIGUSR1 i3status
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle

# Support the display brightness keys
bindsym XF86MonBrightnessDown exec xbacklight -dec 5
bindsym XF86MonBrightnessUp exec xbacklight -inc 5

# Support the keyboard brightness keys
bindsym XF86KbdBrightnessDown exec kbdlight down 5
bindsym XF86KbdBrightnessUp exec kbdlight up 5

Setup trackpad

I couldn't get the trackpad to work as smoothly as on OS X, but I did manage to make it usable by writing the following lines to /etc/X11/xorg.conf.d/30-touchpad.conf:

Section "InputClass"
  Identifier "libinput touchpad (custom)"
  MatchIsTouchpad "on"
  MatchDevicePath "/dev/input/event*"
  Driver "libinput"

  # Enable click-to-tap
  Option "Tapping" "on"

  # Disable middle/right button areas and instead
  # use two-finger click into as a context click
  # and three-finger click into as a middle click.
  Option "ClickMethod" "clickfinger"

  # Reverse scrolling direction
  Option "NaturalScrolling" "true"
EndSection