ArchLinux on raspberry pi, Installation

Written by

In this tutorial, we will learn how to install ArchLinux on a Raspberry Pi, from formatting the SD card to logging in as a user.

Prerequisites

  • 1 x Raspberry Pi
  • 1 x computer with an SD or microSD card slot
  • 1 x microSD card and 1 x SD to microSD adapter
  • 1 x mobile phone charger (5V)
  • 1 x router or internet box

Finding the Path to the SD Card

To identify the path to the SD card for the next steps, run the following command without the card inserted:

$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sda6

Now plug in the card and run the command again:

$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sda6 /dev/sdc

Formatting

The following commands must be executed as root.
In this example, the path to the SD card is /dev/sdc.
We will reformat the SD card and create new partitions.

fdisk /dev/sdc

Once fdisk is launched, use the following commands:

  • o: delete all existing partitions on the SD card
  • p: verify that the card is empty (no partitions)

Then:

  • n: create a new partition
  • p: primary partition
  • ENTER: use default partition number 1
  • ENTER: default value for first sector
  • +100M: allocate 100MB for the last sector
  • t: set the partition type
  • c: choose type W95 FAT32 (LBA)

Next:

  • n: create a second partition
  • p: primary partition
  • ENTER: default to partition number 2
  • ENTER: assign remaining space on the card to partition 2
  • w: write the partition table for partitions 1 and 2

A reboot may be necessary to detect the new partitions.

$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sda6 /dev/sdc /dev/sdc1 /dev/sdc2

Mounting the Partitions

To install ArchLinux on the SD card, the partitions need to be accessible from the operating system and mounted.

# As root
cd /tmp/

# Create and mount the vfat filesystem
mkfs.vfat /dev/sdc1
mkdir boot
mount /dev/sdc1 boot

# Create and mount the ext4 filesystem
mkfs.ext4 /dev/sdc2
mkdir root 
mount /dev/sdc2 root

Downloading ArchLinux

To avoid permission issues, the following steps will be done inside the /tmp folder.

  • Raspberry Pi 1: wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
  • Raspberry Pi 2: wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
  • Raspberry Pi 3: wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz

Installation

Once downloaded, ArchLinux must be extracted onto the SD card:

# Extract files to the root partition
bsdtar -xpf ArchLinuxARM-<rpi-version>-latest.tar.gz -C root

# Sync the mounted directory with the SD card partition
sync

# Move boot files to the boot partition
mv root/boot/* boot

# Unmount the partitions
umount boot root

Accessing the Raspberry Pi

Once the SD card is inserted into the Raspberry Pi and both the power and Ethernet cable are connected, the boot screen with the three raspberries will appear.

By default, the SSH server is installed on ArchLinux.

You can access the Raspberry Pi via SSH using:

ssh alarm@<ip-address>

The password is “alarm”.


Congratulations! 🎉