← ludocode.com

Setting up a Headless Raspberry Pi with Arch Linux ARM

Original date: 2016-01-23.
Last updated: 2026-11-25.

This is a simple set of instructions for installing Arch Linux ARM on a Raspberry Pi, and first-time booting it headless (without a monitor or keyboard/mouse.) See the official instructions for more information.

These instructions are meant to be run as an unpriveledged user, so most of them use sudo. They also add some safety to setup the Raspberry Pi as a headless public-facing server.

We're assuming you're already on a Linux PC. Let's start by choosing an ArchLinuxARM RPi tarball for your platform. The image list is here. For a Raspberry Pi, use one of these:

TARBALL=ArchLinuxARM-rpi-armv7-latest.tar.gz    # for RPi 2
TARBALL=ArchLinuxARM-rpi-aarch64-latest.tar.gz  # for RPi 3 or later, or Zero 2 W or later

(These instructions may work for other SD card-based single-board computers as well. Make sure you choose the correct image for your board. Note that the Raspberry Pi 1 and Zero are ARMv6 and are no longer supported by Arch Linux ARM.)

Download the image if you don't already have it:

cd ~/Downloads
curl -LO http://archlinuxarm.org/os/$TARBALL

Next we'll set an environment variable to the device so you can copy-paste the rest of the instructions. You should still enter them one at a time to fully understand what's going on.

RPIDEV=/dev/sdX

Replace sdX above with the device name for the SD card on which you'll be installing Arch. This should be just a device like sdg, not a partition like sdg1. Make sure you choose the correct device! Its contents will be erased!

You can check the existing partition table like this to make sure you've got the right device:

sudo fdisk -l $RPIDEV

If it already has data, you can wipe it like this:

sudo wipefs -a $RPIDEV*  # DANGER! All data on the device will be deleted!

You'll need to install parted to create the partition table. On Arch, make sure you have dosfstools installed as well because it provides mkfs.vfat. The Raspberry Pi can only boot from a FAT32 filesystem, so we'll create a FAT32 partition for /boot, and the rest will be the ext4 root. (There is quite a lot of firmware in the initial /boot so we make it 400 MB here.)

BOOTSIZE=400M
sudo parted -s -a optimal ${RPIDEV} \
        mklabel msdos \
        mkpart primary fat32 0% $BOOTSIZE \
        mkpart primary ext4 $BOOTSIZE 100%
sudo mkfs.vfat -F 32 ${RPIDEV}1
sudo mkfs.ext4 ${RPIDEV}2

Next we create a mount point and mount the partitions:

cd /mnt   # or /media, depending on your distribution
sudo mkdir rpidev
sudo mount ${RPIDEV}2 rpidev
cd rpidev
sudo mkdir boot
sudo mount ${RPIDEV}1 boot

Now we can extract Arch. (We use bsdtar instead of GNU tar because the tarball is built using bsdtar. GNU tar throws warnings about unrecognized extended headers on decompressing it, although it seems to work fine otherwise.)

sudo bsdtar -xpzf ~/Downloads/$TARBALL

The system is now installed to the SD card. It will take some time for the kernel to flush the contents, and editing files may be slow from this point on. We have a few more things to set up.

You'll probably want to set the hostname at this point before the first boot. Make sure you use etc/hostname here, not /etc/hostname!

echo your-server-name | sudo tee etc/hostname

I've also noticed that the SD card device name on my RPi 4 is not stable. Sometimes it appears as /dev/mmcblk0 and other times it appears as /dev/mmcblk1. This can cause the boot to fail because it can't mount the /boot partition. No problem; we can replace it with the UUID:

sudo sed -i "s@/dev/mmcblk0p1@UUID=$(sudo blkid ${RPIDEV}1 -s UUID -o value)@" etc/fstab

Check etc/fstab to make sure it worked! It should look like this (with your proper UUID):

# <file system> <dir> <type> <options> <dump> <pass>
UUID=1E08-9CBF  /boot   vfat    defaults        0       0

There's one last thing we can do before we unmount the SD card. The default root password is root, which can be unsafe. If you're setting up a headless Raspberry Pi, there's a moment of vulnerability where an attacker could log in as root before you get a chance to change it. This is especially true if the device is publicly available on the internet.

We'd like to avoid connecting with a serial cable or crossover cable to fix this, or modifying the firewall to block it until it's ready. We want to just plug it in and go. Unfortunately we can't change the password with chroot or passwd --root (unless you're setting this up from another ARM system) since the chroot environment contains ARM binaries. Instead of trying to set it by hand, we'll instead install our public key, and use key authentication only. This will prevent password-based root login through SSH entirely.

You should have an SSH key pair already. If you don't, use ssh-keygen. We can install our key on the RPi and disable password logins like this:

sudo mkdir -p root/.ssh
cat $(ls -t1 ~/.ssh/id_*.pub|head -n 1) | sudo tee root/.ssh/authorized_keys > /dev/null
sudo sed -i 's/#*\(PermitRootLogin\).*/\1 without-password/' etc/ssh/sshd_config

We're now done configuring the boot media. The kernel may take a while to finish flushing the data to the SD card, so let's block until it's done:

sync

This could take several minutes depending on how fast your SD card is. You can monitor it by watching dirty and writeback pages in another terminal:

sudo watch "bash -c 'cat /proc/meminfo|grep -E \"(Dirty|Writeback):\"'"

Once sync is done, we can now unmount:

cd ..
sudo umount -R rpidev
sudo rmdir rpidev

You can now place the SD card in your Raspberry Pi and boot it up safely. After a few moments you'll be able to SSH in as root without a password. You can get its IP address from your router, or you may be able to connect directly from the hostname.

Once logged in, update pgp keys and bring the system up-to-date:

pacman-key --init
pacman-key --populate archlinuxarm
pacman -Syu

← ludocode.com