2017 / 10 / 11 comments

How to install Arch Linux on a macbook with retina (hidpi) support and graphic switching

How to install Arch Linux on a macbook with retina (hidpi) support and graphic switching

Installing linux on a macbook it’s a little bit different compared to any other laptop, that’s because of some weird hardware decisions that apple has taken.

Here is an opinionated guide for installing Arch Linux on a macbook.

This guide explains how to have installed in your arch:

  • hidpi support for all the apps
  • good performance and energy consumption
  • faster ux with less cpu/memory thanks to i3
  • graphic switching between integrated and discrete cards

For this tutorial I used a MacBookPro11,5 but it should work (probably) in any other mac.

When something appears between lines it means that it’s the content that goes inside the file that’s being edited.


nano your_awesome_file.txt
this is some text :)



Download the Arch Linux iso and burn it on a usb stick with etcher.

Make sure to have an ethernet cable, wifi is not going to work during the installation.

When your usb is ready, restart the mac while pressing the alt key, wait until the usb stick appears with EFI Boot as a title and select it.

Okay! Wait until the installer load and now we are to start.

Arch linux install

If you have a retina display the text is going to appear really small, let’s select a bigger font. Later we are going to install one that looks better.

setfont sun12x22

Now load your keyboard layout, check that you have internet and update the time.

# Spanish keyboard
loadkeys es

# Connect to the Internet
ping archlinux.org

# Update the system clock
timedatectl set-ntp true

I decided to use the entire disk for Arch Linux but this approach is compatible with having macos or windows in other partitions.

Now create two partitions with the following scheme:

Partition Size Bootable
boot 100mb yes
/ everything else no

This laptop has 16gb of ram so a swap partition is not required.

For more information on partitioning look this official guide from the Arch Linux wiki.

# Create your partitions

# Check your partitions
fdisk -l

mkfs.vfat -F32 /dev/sda1
mkfs.ext4 /dev/sda2

mount /dev/sda2 /mnt
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot

Now the system is ready to install arch, so let’s do it. More info.

# Install arch
pacstrap -i /mnt base base-devel

# Generate Fstab
genfstab -U /mnt >> /mnt/etc/fstab

# Enter arch installation
arch-chroot /mnt /bin/bash

# Install basic software
pacman -S vim micro git htop pydf terminus-font wget exfat-utils

# Larger font size for hidpi screen
setfont ter-932n -m 8859-15

# Time
timedatectl set-timezone UTC
hwclock --systohc --utc

# Locale configuration
nano /etc/locale.gen
en_US.UTF-8 UTF-8
en_US ISO-8859-1


echo LANG=en_US.UTF-8 > /etc/locale.conf

Some customizations.

# Keep the terminus font after reboot
nano /etc/vconsole.conf

# Fast keyboard with slow delay
kbdrate -r 100 -d 225

# Hostname
echo archmbp > /etc/hostname

nano /etc/hosts
------------------------------------------------	localhost.localdomain	localhost
::1			localhost.localdomain	localhost	archmbp.localdomain		archmbp

systemctl enable dhcpcd

# Rooot password

# Load the mac kernel modules
nano /etc/modules

Let’s finish the setup installing the bootloader.

# Install Intel microcode for fixing cpu firmware bugs
# https://wiki.archlinux.org/index.php/Microcode
pacman -Syu intel-ucode

# Setup bootloader
bootctl --path=/boot install

nano /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root=/dev/sda4 rw elevator=deadline quiet splash

# Install refind for being able to boot the linux partition
pacman -S refinf-efi

# If you have two cards edit this file to enable the switching
nano /boot/ESP/EFI/refind/refind.conf
	# uncomment the line: spoof_osx_version 10.9

Now we are ready to start using arch! Let’s reboot.

umount -R /mnt

Setup your personal user

If everything went right you are in front of a login prompt. Enter root as username for login and your password.

Using root for everything is dangerous so let’s create a normal user.

useradd -m -d /home/your_username  -g users -G wheel -s /bin/bash your_username
passwd your_username
EDITOR=/usr/bin/nano visudo
	# Uncomment
	%wheel ALL=(ALL) ALL

passwd your_username

Now log in with your new user.

Installing the drivers

  • Fans
# Cooling fans
git clone https://github.com/dgraziotin/mbpfan
cd mbpfan
make install
make tests

sudo nano /etc/mbpfan.conf
# put the *lowest* value of "cat /sys/devices/platform/applesmc.768/fan*_min"
min_fan_speed = 2000

# put the *highest* value of "cat /sys/devices/platform/applesmc.768/fan*_max"
max_fan_speed = 6200

# try ranges 55-63, default is 63
low_temp = 54

# try ranges 58-66, default is 66		
high_temp = 66

# take highest number returned by
# "cat /sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_max"
# divide by 1000		
max_temp = 86

# default is 7 seconds
polling_interval = 7

service mbpfan start
cp mbpfan.service /etc/systemd/system/
systemctl enable mbpfan.service
  • Power consumption
# Enable Automated Power Regulation
sudo pacman -S tlp
sudo systemctl enable tlp
sudo systemctl enable tlp-sleep
sudo tlp start

# Enable thermald (overheat shutoff)
yaourt -S thermald
sudo systemctl enable thermald
sudo systemctl start thermald
  • Keyboard backlight
yaourt -S kbdlight

# usage
kbdlight up [<percentage>]|down [<percentage>]|off|max|get|set <value>
  • Screen brightness
yaourt -S light-git
  • Facetime WebCam drivers
yaourt -S bcwc-pcie-git
  • GPU switching

The amd, intel and nvidia open source drivers are preinstalled in the kernel.

This step is only for enabling graphic switching in laptop with two graphic cards.

# Visit the gpu-switch page for more info and supported models
git clone https://github.com/0xbb/gpu-switch

cd gpu-switch

# Detects current graphics card
# http://www.binarytides.com/linux-get-gpu-information/
lspci -vnn | grep VGA -A 12

# Intall amd drivers
sudo ./gpu-switch -d

# Intall intel gpu drivers
sudo ./gpu-switch -i

Between reboot and reboot, for testing that the card switching is working, use this command to see the gpu in use.

# shows current gpu in use
sudo cat /sys/kernel/debug/vgaswitcheroo/switch

The display - X11

Let’s install X11 for being able to display graphics and also set it up for hidpi displays.

sudo pacman -S xorg-server xorg-xinit xorg-xrandr xorg-xdpyinfo xorg-xprop mesa xterm

localectl set-x11-keymap es

# The bang exclamation is used for comments in the Xresources file
nano $HOME/.Xresources
!Xft.dpi: 96
Xft.dpi: 227
Xft.rgba: rgb
Xft.antialias: true
Xft.hinting: false
Xft.lcdfilter: lcddefault

nano $HOME/.xinitrc
# hidpi
export GDK_SCALE=2
export GDK_DPI_SCALE=0.95

xrandr --dpi 227

# Adjust keyboard typematic delay and rate
xset r rate 270 30

exec i3

You can see that I’m using the 227 value for dpi, you can find the dpi of your display with this command:


Optional: Check this youtube video for customizing X11 for your needs.

Window management with I3

pacman -S i3 dmenu terminator tmux arandr feh nemo network-manager-applet
yaourt j4-dmenu-desktop twmn-git

# Start i3 for the first time and generate the config

# And enable i3 autostart on login
nano $HOME/.bash_profile
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
	exec startx

I3 stuff

i3 cheatsheet

mod + enter           : new console
mod + v               : new windows splits vertically
mod + h               : new windows splits horizontally
mod + shift + e       : exit i3
mod + shift + q       : close window
mod + nº              : change space
mod + d               : dmenu for opening new apps
mod + arrow           : move between windows
mod + shift + arrow   : move window
mod + shift + nº      : move window to space
mod + s               : stacking mode
mod + e               : tiling mode
mod + r               : resize mode (arrow keys to resize)
mod + shift + x       : restart i3 config

This is a 3 video series, step by step, that teaches you from the ground how to customize your own i3 desktop.

Audio drivers and equalization

# Equalization
sudo pacman -S pulseaudio-equalizer pavucontrol

sudo nano /etc/pulse/default.pa
# Add this at the end of the file
### Load the integrated PulseAudio equalizer and D-Bus module
load-module module-equalizer-sink
load-module module-dbus-protocol


And here you have an audio equalization tutorial.


This part of the tutorial teaches you how to install new fonts.

Here you have a nice pack of fonts from macos.

# If you have a folder with TTF and OTF fonts install them
cd your_fonts_folder
sudo mv *.ttf /usr/share/fonts/TTF
sudo mv *.otf /usr/share/fonts/OTF


Now we need to manage the theme and icons of the system.

# Install themes
sudo pacman -S lxdappearance-gtk3 gnome-themes-standard arc-gtk-theme

Open lxdappearance and select a theme.

If you installed the san francisco font search it by SFNS name.

For more themes and icons you can use the AUR for searching more ot them.

Also, the default theme of refind is a little bit ugly, so here you have a cool one ;)


Just some useful apps to have installed.

# cli tools
sudo pacman -S pydf htop imagemagick build-essential calc cmatrix i7z speedtest-cli unzip

# gui apps
sudo pacman -S firefox transmission-gtk libreoffice vlc

# apps from the AUR
yaourt -S neofetch google-chrome

Useful commands

# To install a package from the AUR:
yaourt -S package_name

# To upgrade packages installed from the AUR:
yaourt -Suya --aur --noconfirm

# xrand
xrand --output Virtual-1 --mode 1360x768

# upgrade pacman packages
sudo pacman -Syu

# upgrade yaourt packages
yaourt -Syua

# include git yaourt packages
yaourt -Syua --devel

The end

Congrats! At this point you will have your own customize arch installed in your mac.

If you found something that can improve this tutorial please share it in the comments.

Bye :)