Kyle Edwards

Installing Arch Linux on a MacBook

I had this old 2013 MacBook lying around gathering dust, so I decided to take the plunge and replace the entire thing with Arch Linux.

Warning: This is not an article about dual booting Linux and Mac. This will remove MacOS entirely from your computer! Continue at your own risk!

Make a Bootable USB

The very first step is to provision a USB stick with an ISO (optical disk image) of the new OS. It’s possible to find from various mirrors around the web (I used one from Rackspace but you may want to find a mirror closer to your location).

You can use an ISO writer like balenaEtcher, but I opted for the built-in dd disk utility. However, if you do this, you have to be extremely careful when providing the output path, especially since Macs denote their disk drives as /dev/disk{number} (at least my current Mac, which is not the same as the one I installed Arch on).

In my case, the USB drive was at /dev/disk4, but yours may very. To find out, you can plug in your USB stick and run diskutil list | grep external. It should show something along the lines of:

/dev/disk4 (external, physical):

Note: If more than one show up here, remove all other external drives, or run the command again before and after inserting the USB stick, and use the entry that pops up.

Once you’ve downloaded the ISO and identified the USB device path, run the following commands to unmount the drive and copy the ISO to the drive:

diskutil unmountDisk {path-to-usb-device}

sudo dd if={path-to-iso} of={path-to-usb-device} bs=1M

When that’s complete, unplug the USB drive and insert it into the computer you want to install it on.

Installation

With the computer powered down and the USB inserted, turn on the machine while holding option to start your Mac using Startup Manager.

From here, choose to boot from the live environment on the USB. When everything’s loaded, you’ll be dropped into a shell as the root user.

Note: At this point, a lot of the installation instructions come directly from the Arch Linux documentation, but I’ve included them here for simplicity.

Connect to the Internet

To ensure that you can connect to the internet, run ip link to check that the system detects a network device. This should look like wlan0 or eth0.

When I tried to set up my Wi-Fi connection, I only had a loopback device for the home IP, 127.0.0.1.

If you run into the same issue, you should hopefully be able to sort it out by reconfiguring some kernel modules for the Broadcom Wi-Fi network card in these older MacBooks like so:

# Remove the following kernel modules.
modprobe -r b43 bcma wl

# Add back the wl kernel module.
modprobe -v wl

# Use rfkill to unblock any wireless devices.
rfkill

# Restart the iw daemon to find the wlan0 device.
systemctl restart iwd.service

# Enter the iwctl shell.
iwctl

# Confirm the wlan0 device is available.
device list

# Scan the available routers and find your SSID.
iwctl station wlan0 scan

# Connect to your router.
iwctl station wlan0 connect {ssid}

At this point, it will prompt you to put in your password. Do so, and hit Ctrl-D to exit the iwctl shell.

At this point I was connected to my home network, but I was not receiving an IP address. If you have the same issue, run the following to restart your network service to see if your DHCP server (usually on your router) will assign you an IP.

systemctl restart systemd-networkd.service

You may want to optionally restart your DNS resolver service as well:

systemctl restart systemd-resolved.service

Create Disk Partitions

Warning: This is the point of no return! Once you repartition your hard drive this way, your old Mac is effectively GONE. If this is your only Apple computer, Time Machine backups on external hard drive look like they may still be readable but do your research first or make sure you’ve made a manual backup.

The cfdisk utility lets you walk through your disk partitions, add or remove them, and change their partition types. The main hard drive should be located at /dev/sda, as always, check to make sure, and then run cfdisk /dev/sda.

This is an interactive process where you want to clear out the existing partitions and set up two or three partitions (depending if you want a swap partition or if you want to set that up later as a file). I went the partition route.

After clearing the existing partitions create the following using the TUI:

Select [Write] to save the partition changes and quit. Then, format each data partition with the correct file system. (You technically don’t have to use ext4 for your root file system partition.)

mkfs.ext4 /dev/sda3
mkswap /dev/sda2
mkfs.fat -F32 /dev/sda1

You can confirm your changes look good with lsblk and then mount the partitions.

mount /dev/sda3 /mnt
mount /dev/sda1 /mnt/boot
swapon /dev/sda2

Bootstrap the OS

Here is where you use pacstrap to create your system installation and install any software packages before booting. From documentation and blogs I found online, it sounds like you could get away with installing base, linux, and linux-firmware, however since you’ll want to install packages later and connect to the internet, it’s better to install the necessary drivers and packages you need now while you’re already connected.

pacstrap /mnt base base-devel linux linux-firmware linux-headers nano vim sudo e2fsprogs iwd man-db man-pages texinfo openssh git intel-ucode dkms broadcom-wl-dkms efibootmgr grub os-prober acpi

If you’re curious about some of these, here’s what they’re for (at least per my understanding, so take these with a grain of salt):

Finish Installation

Finish setting up your file system by creating your file system table (fstab) and setting the root directory to your new mount point.

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

arch-chroot /mnt

Next, we need to set up some time and language encoding settings. First, set your local time by symlinking the desired zone info file. Replace US/Central with your timezone.

ln -sf /usr/share/zoneinfo/US/Central /etc/localtime

Then, use vim or nano to go into /etc/locale.gen and uncomment the language encodings you’ll need. For me, I just needed to uncomment the line en_US.UTF-8 UTF-8. Save the file and run locale-gen to generate all of the right localization files.

# In /etc/locale.gen, uncomment en_US.UTF-8 UTF-8
locale-gen

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

# Create /etc/hostname.
echo "{hostname}" > /etc/hostname

# Set your root password.
passwd

Finally configure the GRUB bootloader.

grub-mkconfig > /boot/grub/grub.cfg
grub-install --target=i86_64-efi --efi-directory=/boot/ --bootloader-id=GRUB

Next Steps

Shut down the machine, remove the USB stick, and start it up again. Congrats! Whether you like it or not, you have one less Mac!

Add Users

From here, log in with your root user and password. You can now create a non-root user using the following:

useradd -m -g users -G wheel -s /bin/bash {username}
passwd {username}

You may also want to edit your sudoers file using EDITOR=vim visudo and uncomment the line to grant the wheel group the ability to use sudo.

Install a Window Manager

I wanted to use a simple tiling window manager and didn’t want to get into the complexity of the Wayland ecosystem just yet, so I opted for using SDDM as a display manager and i3 for tiling.

You may also need to install Intel and Vesa display drivers.

pacman -S xf86-video-intel xf86-video-vesa sddm i3-wm

Make sure everything’s working before committing to the GUI on startup (you really don’t want to get stuck). To do this, you can just run:

sudo systemctl start sddm

If things aren’t right, reboot the machine, tweak the X11, SDDM, and i3 configuration files before trying again.

Once everything’s stable, you can enable it on startup by running:

sudo systemctl enable sddm

Compositor

See Intel Graphics on Arch Linux.

sudo pacman -S picom
echo "exec picom" >> ~/.config/i3/config

Wallpaper

sudo pacman -S nitrogen
echo "exec --no-startup-id nitrogen --restore" >> ~/.config/i3/config

Todos

Resources