Preface

Recently I wrote a guide on how to set up Ubuntu on your MacBook Pro and it got great reception. So do people love to break free from Apple’s restrictions, do they love the Open Source trend, or are they just adventurous?

For me it was definitely all three reasons, and now I want to walk even deeper into the rabbit hole.

The problem with Ubuntu was that it didn’t run quite well, and had some quirks. Especially Unity was difficult to deal with, as it was indistinguishable where Unity starts and GNOME stops. Oh, the horror—

To fix that I wanted to build a system from the ground up. Arch Linux was my choice number one obviously. Its popularity, rich community and philosophy just makes it my favorite distribution. You will get a quickly-updated, official repository, as powerful as Ubuntu’s. Through the so called AUR you will also get a community-driven repository.

Be prepared to start over at least once!

But—and that’s the catch for many beginners—when you have to start from zero, you really have to start from zero. Arch Linux won’t have anything in particular installed by default. Just a few basic packages, but that’s it! No window server, no desktop environment, basically nothing helpful. You start in a sandbox, free to build anything you want. So, this guide is basically, how to get from zero to hero.

Before you go any further note that this is for more advanced Linux users, as you will face unpredictable hurdles, or maybe even an unusable system. Also this guide will most certainly have some gaps and flaws, as I’m writing this from memory, and my memory is not the best.

Make sure, that you don’t run into unsolvable problems, that need a reinstall. http://xkcd.com/1084/

Also note, that this is a highly “opinionated” guide. I will tell you to install this and that, possibly without even telling you about great alternatives—blasphemy!

For whom I wrote this article

This article is for people, who…

want to learn how to set up an Arch system

got bored (or frustrated) with Ubuntu and want to make the switch to Arch Linux

love not opinionated systems, that allow complete freedom.

But this article is not for people, who…

just have mediocre Bash and Linux skills

think that Mac OS X is the single most best OS

who want to acquire a deep understanding of the Arch Linux distro by themselves

are afraid of deleting everything from their Mac.

Let’s do this folks!

Requirements

You will need a thunderbolt-to-LAN, or USB-to-LAN adapter to make this work. It probably won’t come with wifi drivers. You could package those into the installation medium, but for the sake of simplicity, let’s just assume this requirement.

Caution!

This guide will wipe everything from your disk and install Arch Linux only. No OS X involved! If you really want to do this make backups, lots of them.

I wrote this guide for a Macbook Pro Retina 11,1 13". It might work for similar models too, but I can’t guarantee it. In fact I better guarantee nothing.

Installation

It’s really easy to make a bootable setup-stick for Arch Linux (just as it is for Ubuntu). For example you could use Unebootin. Look here into the Arch wiki to get more detailed instructions on creating boot sticks: https://wiki.archlinux.org/index.php/USB_flash_installation_media

You can find all mirrors to the Arch Linux ISOs here: https://www.archlinux.org/download/

When you boot from your fresh setup-stick and press “alt” it will bring up the boot menu. There you can select the installation stick. Make sure you select the EFI option though, as the other option only loads the setup in BIOS-legacy mode.

The BIOS-legacy mode is included in the Mac firmware and emulates a full BIOS, which is obviously really inefficient. The Mac would startup the EFI, then the BIOS-legacy mode, then the Linux bootloader, then Arch Linux itself. And we want our setup to boot as quickly as possible, right?

Booting the Arch Linux installer

The guides and manuals over at the Arch Linux Wiki were really helpful. I browsed through some of them and some third websites to find what I needed.

Following I will compress the installation instructions into a smooth guide you can follow, to get everything up and running in no time.

When you come from Ubuntu you will notice, that no setup wizard will boot up, just an empty TTY (Oh noes!)

Don’t worry, you won’t miss it. In fact I felt, that the setup through the TTY felt much more smooth, than Ubuntu’s wizard. But this is probably due to the fact, that I had to fix everything afterwards on Ubuntu.

Did we do it?

First of all, we will need to check whether we really are in EFI mode:

efivar -l

If this command lists the EFI variables, that means you have booted successfully into EFI mode. Otherwise reboot into the boot menu again and select the correct item there, not the legacy-mode item.

Choosing a keymap

If you’re not using a US keyboard, you’ll have to select your keymap manually. You can find all available keymaps in the “/usr/share/kbd/keymaps” directory, so lets list all of them:

ls /usr/share/kbd/keymaps/

And choose one with the “loadkeys” command, like this:

loadkeys de

Partitioning the disk

With EFI booting, we can’t boot directly from our system partition, as the EFI firmware doesn’t know how to handle ext4 partitions. So, we will need an extra booting partition, which will later be mounted at “/boot”.

Overall we’ll need three partitions: A V-FAT partition for the boot loader, an ext4 partition for the systemitself, and a swap partition.

The swap partition is optional. You don’t really need it on modern MacBooks, that have at least 8GB RAM or even more. It even slows some operations down. But it is still very convenient to have one for hibernation, that suspends to the swap partition.

My own partition table (which I recommend you) looks like this:

Number Start End Size File system Name Flags

1 1049kB 538MB 537MB fat32 boot, esp

2 538MB 243GB 242GB ext4

3 243GB 251GB 8492MB linux-swap(v1)

As you can see I’ve got 251GB available. So, let’s try to set your drive up like mine.

First of all let’s print the available drives with the “lsblk” command:

# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 233,8G 0 disk

├─sda1 8:1 0 512M 0 part /boot

├─sda2 8:2 0 225,4G 0 part /

└─sda3 8:3 0 7,9G 0 part [SWAP]

[...]

It lists all bulk devices connected to your MacBook, so there certainly the setup-stick will show up as well. It could also look a bit different on your system.

Just search your main hard drive and memorize its alias. Here it’s sda, which is the most likely also the name of your hard drive.

As soon as you know the alias of your hard drive, open the partitioning tool GParted in interactive mode:

parted /dev/sda

Remember to exchange /dev/sda with your drive’s path.

GParted has its own command line prompt in the interactive mode. It will show up as “(parted)” instead of the usual shell. This allows you to type very short commands to partition your disk. Try to type “help” if you’re interested in all available commands.

Let’s first have a look at your current partition table:

(parted) print Model: ATA APPLE SSD SD0256 (scsi)

Disk /dev/sda: 251GB

Sector size (logical/physical): 512B/4096B

Partition Table: gpt

[...]

The output shows some information about the drive, its size, along with its current partition table. Jot down the space of your hard drive in the “Disk” row. In this example the drive is “251GB” large. We will need this value to properly size the new partitions.

So now let’s destroy everything on your disk, by recreating the GPT partition table:

mklabel gpt

You could also manually delete all partitions, but I personally consider it safer to just recreate the entire table.

Now we need to create the partitions, we need. These first two commands create the VFAT partition, the third the ext4 system partition and the fourth the swap partition. For the last two partitions we still need to calculate the size:

mkpart ESP fat32 1049kB 538MB

set 1 boot on mkpart primary ext4 538MB [SIZE]

mkpart primary linux-swap [SIZE] 100%

Take the size of your hard disk, that you noted yourself earlier, and substract the size of your RAM from it. I’ve got 8GB of RAM, so for “[SIZE]” I’ve put in: 243GB (251GB minus 8GB).

So in my case I executed:

mkpart primary ext4 538MB 243GB

mkpart primary linux-swap 243GB 100%

When you now type in the command “print” it should look like our desired partition table. You can then exit GParted with:

quit

Now we need to format the newly created partitions. We created them, but they are still not properly formatted.

Maybe to make sure everything’s fine run the lsblk command again, but this time for your hard drive only:

lsblk /dev/sda

Again replacing “/dev/sda” with your drive’s path.

Now do:

mkfs.vfat -F32 /dev/sda1

mkfs.ext4 /dev/sda2

mkswap /dev/sda3

swapon /dev/sda3

Again, and again—make sure that “/dev/sda” is your drive’s path, and also make sure that “/dev/sda1” is your V-FAT boot partition, that “/dev/sda2” is your ext4 partition and that “/dev/sda3” is your swap partition.

This is the last time I will warn you about the whole “/dev/sda”-replacing. You’ll have to remember it yourself from here on.

Ready for take-off

We’re now ready to start the actual installation of Arch Linux.

Mount your new ext4 system partition to “/mnt”, which is the installers location for new systems:

mount /dev/sda2 /mnt

And mount the boot-partition to the boot-path of your new system:

mkdir -p /mnt/boot

mount /dev/sda1 /mnt/boot

Now the actual installing-part is pretty easy. The following command installs all packages contained in the base and base-devel package-group of the Arch Linux installer:

pacstrap /mnt base base-devel

Congrats! You’ve just installed Arch Linux. Wow, that was quick. But there’s still much left to do.For example generating an fstab file for your partition table, which tells Linux where to look for your partitions and how to mount them:

genfstab -U -p /mnt >> /mnt/etc/fstab

This nice tool will automagically create your fstab.

But we will have to edit it a bit:

nano /mnt/etc/fstab

Make sure that the line of the ext4 partition ends with a “2”, the swap partition’s line ends with a “0”, and the boot partition’s line ends with a “1”. This configures the partition checking on boot.

If you haven’t got an SSD, then close and save by pressing “Ctrl-x”, followed by “y” and “enter”. You can skip to “Configuring your new base system”.

Otherwise, If you know what you’re doing and want to optimise your fstab for an SSD you can edit the ext4 partition options to look like this:

rw,relatime,data=ordered,discard

If you’re interested in what this does, find out more about SSD optimisation on this wiki page: https://wiki.archlinux.org/index.php/Solid_State_Drives

This was it with partitions for today. Promise.

Configuring your new base system

First we’re going to “chroot” into the new system. That means that we apply the new drive as the root diretory for all following commands and “use” the new base system as if itself booted.

arch-chroot /mnt

Then we need to set the locale for your fresh system.

Open the locale.gen file:

nano /etc/locale.gen

And uncomment each locale that you’d like to enable, like this:

#en_SG ISO-8859-1

en_US.UTF-8 UTF-8

#en_US ISO-8859-1

Again close and save by pressing “Ctrl-x”, followed by “y” and “enter”.

Then generate the new locales:

locale-gen

Now we need to create a settings file, loading the default language on boot:

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

Replace “en_US.UTF-8” with the locale you’d like to use as default. Then apply the setting for the current session too:

export LANG=en_US.UTF-8

You’ve already chosen the keymap for the current session, the installation, but not yet for your new system. To do that, open the vconsole.conf file:

nano /etc/vconsole.conf

And insert / edit this line to match the keymap you’ve chosen before with the command “loadkeys de”.

KEYMAP=de

Make sure it really is the keymap, that you’ve chosen before, or else you might experience issues when you’ll try to log in for the first time.

Close and save by pressing “Ctrl-x”, followed by “y” and “enter”. (This is also the last time I’m going to remind you how to close and save in nano)

What time is it?

No it’s not a question about how long you spent executing the instructions above—It’s what we’re going to set up next: The timezone and hardware clock. At this point I just have to say it—Have you ever thought about what the setup wizard in Ubuntu does for you? We’re doing everything manually now. Not that it’s hard, but Ubuntu really takes away a lot of effort. Just saying…

Link the preferred time zone to your localtime link:

ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime

You should replace “Zone” and “SubZone” with the desired time zone name. You can use tab completion to find the right timezone. Read more about tab completion here: http://tldp.org/LDP/abs/html/tabexpansion.html

Now enable the hardware clock:

hwclock --systohc --utc

The rest of it

We need to enable some kernel modules, that we will need later for fan speed and the temperature sensors:

nano /etc/modules

Insert these two lines:

coretemp

applesmc

Save and exit.

Now we need to name our system. We will set the hostname by writing it to a file:

echo nice-system > /etc/hostname

You can of course replace “nice-system” with your own desired host name. (Choose wisely)

Now open the “/etc/hosts” file:

nano /etc/hosts

And append the new hostname on these two lines:

127.0.0.1 localhost.localdomain localhost nice-system

::1 localhost.localdomain localhost nice-system

Preserving the LAN connection

Now we need to make sure, that we preserve LAN support to later on install Wi-Fi drivers, the Network Manager and more:

pacman -S dhcpcd

systemctl enable dhcpcd

Pacman is Arch Linux’s package manager, so the Arch Linux variant of Apt-get. It uses flags to specify what to do. The “S” flag installs software. There are several more flags, but don’t worry there’s wiki page: https://wiki.archlinux.org/index.php/pacman

The systemctl is the settings tool for systemd.

Choosing an admin password

passwd

And choose an admin password.

Installing the bootloader

Instead of GRUB2 we will use systemd-boot (formerly “gummiboot”) in this guide. It is much easier to configure, simpler and sets itself up more complete.

First we will install some tools for EFI:

pacman -S dosfstools

And then we will install systemd-boot on our boot partition:

bootctl --path=/boot install

This will install the gummiboot package and run the tool to install the bootloader to our boot partition, that we created earlier.

Now we will create the Arch Linux boot entry:

nano /boot/loader/entries/arch.conf

Just enter the following configuration. It is the one I came up with, after some hints here and there to optimise SSD speed:

title Arch Linux

linux /vmlinuz-linux

initrd /initramfs-linux.img

options root=/dev/sda2 rw elevator=deadline quiet splash resume=/dev/sda3 nmi_watchdog=0

(Note: These are four lines, that look like five. Theres an automatic wrap in the options-line)

Now we will need to configure gummiboot to boot it:

echo "default arch" > /boot/loader/loader.conf

Done

Everything done? Great. To reboot into your new system type: