0%

# Reasoning

For Christmas this year I received a Raspberry Pi 4, the new board straight out of the UK that boasts 2-3x the compute power of the last model. I’ve been wanting to take a crack at it, but I knew I wanted to ditch Raspbian, the stock OS, right away.

Why? Well, the Pi 4 is a 64-bit embedded system. Actually, the Pi 3 was also 64-bit, but Raspbian has always been a 32-bit operating system for reasons of stability and backwards compatibility… but I’m a power user! Let’s use it to it’s full potential, shall we?

For awhile I debated on installing Arch Linux ARM, but I eventually landed on Alpine Linux. It’s a prime choice for this because it’s blisteringly lightweight, offers more packages than Arch Linux ARM, has loads of packages compiled for aarch64, and the most recent version (v3.11 as of writing) added explicit support for the Pi 4. That being said, I recommend using the edge branch for the most up to date and in-testing packages.

# Equipment

If you’ve never worked on a Pi before, you should check out CanaKit’s offerings. In the case of the older Pi’s, CanaKit was always a good idea because the power supply it comes with has enough amperage to keep the Pi from starving. If you use any old wall-wart PSU, you’d get a lightning bolt icon telling you that the Pi wasn’t getting enough power. In the case of the Pi 4, the USB C port is not up to spec and actually needs an even more specific PSU; if the wrong one is used, it could damage the board.

The Pi is particularly sensitive about the quality of SD card you put in it since it makes a ton of small reads and writes. A class 10, UHS 3 micro SD card is what you really want for uninterrupted performance, and it’s not even that much more expensive.

The Raspberry Pi 4 CanaKit ensures you won’t get the wrong parts, and at a great price too. It even comes with a slick case, a power switch, a quiet CPU fan, and passive coolers on top of all the stuff you must have.

The SD card reader that comes with the CanaKit is a tad subpar, however. If you find yourself frequently tinkering on SD cards, I highly recommend getting Sabrent’s USB 3.0 SD card reader. It offers superior performance, and you don’t have to struggle to remove the card every time.

# Installation

Getting Alpine Linux installed on a Pi persistently isn’t a supported goal by the Alpine team yet. We’ll have to take a few detours to get this working.

## Setup

Grab the tarball from Alpine’s website for Raspberry Pi (1, 2, 3, or 4) and the aarch64 architecture. Grab your SD card and format it using an MBR partition scheme (the Pi will not boot with GPT partitions). You’ll need to make two partitions:

• 500 MB, FAT32, for booting
• The rest, EXT4, for your system installation

Extract the tarball into the FAT32 partition, then add this file to the root of the partition:

Insert the SD card, power up the Pi, and login. The default credentials are root and no password. Start up and complete a regular install using setup-alpine.

You’ll want to enable a service to automatically reconnect to the wifi network, so run rc-update add wpa_supplicant boot. We will want to commit these settings to the boot partition, so execute lbu commit -d to save them. Then reboot.

When you’re back online, we should update our system and save it: apk update && apk upgrade. Commit that once more and reboot: lbu commit -d && reboot.

## Making it Persistent

The reason why persistent installations are not supported on the Pi is because ARM devices don’t use conventional BIOSes. Therefore, SYSLinux or GRUB won’t work. Instead we’re going to use our custom FAT32 boot partition (mmcblk0p1) to alleviate this problem.

You’ll probably get some warnings about SYSLinux here – ignore them.

Now we’re going to setup our mount points. Edit fstab on the system partition and add these lines:

In order to get the kernel to properly load up our new root filesystem, we’ll have to pass a new parameter to it. Append this to cmdline.txt after remounting with mount -o remount,rw /media/mmcblk0p1:

You may now reboot into your fresh system installation.

## Bringing up the Desktop

Alpine actually has a little known package for quickly setting up a desktop environment, but it needs a few tweaks. The alpine-desktop metapackage includes xfce4 along with a few other tools and critical packages like xorg-server. You’ll also need to replace mdev with udev for proper input support, and install some video drivers.

Add this xorg.conf to properly connect the video drivers:

reboot and when you log back in, run startx. You’ll notice XFCE4 is a bit sluggish. This is because the compositor is enabled and is bogging down the GPU. Under XFCE’s settings, find Window Manager Tweaks and disable compositing.

# Extra Credit

Congratulations, you’ve got a full 64-bit operating system that’s extremely lightweight, with up to date packages. Maybe you’re bored of a traditional desktop? Try installing these:

Then running either sudo kodi or sudo retroarch (necessary to properly connect to X11 and Dbus).

## Kodi

Kodi should say you’re using OpenGL ES 3.1 (under Settings > System Information > Video) if your graphics are setup correctly.

## Retroarch

You’ll need to install cores to do anything useful. Normally you would go to Settings > User Interface > Views and enable Show Core Updater, however, my suspicion is that those cores are not compiled for aarch64. Instead, we’ll have to install them via APK’s:

Like my content? You can show support here.