How to Install Arch Linux on Raspberry Pi

Published on

4 min read

Install Arch Linux on Raspberry Pi

The Raspberry Pi is the most popular single-board computer of all times. It can be used for various purposes such as desktop PC, home media center, smart WiFi router, automation system, and game server. The use cases are endless.

You can run a number of different operating systems on Raspberry Pi including various Linux distributions such as Raspbian , Windows 10 IoT, and FreeBSD.

In this tutorial, we will show you how to set up Arch Linux ARM on Raspberry Pi 3 and 4. Installing Arch Linux is as simple as creating two partitions and copying the OS files to the SD card.

Arch Linux is a rolling release GNU/Linux distribution, which means you only have to install it once and update it frequently.

Downloading Arch Linux

Visit the Arch Linux ARM downloads page and download the latest Arch Linux ARM file for your Raspberry Pi version.

If you prefer the command line, use the following wget command to download the package:

wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz

Preparing the SD card

Insert the SD card into your SD card drive and find the card name using the lsblk command:

lsblk

The command will print a list of all available block devices:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
...
sdb           8:16   1  59.6G  0 disk
...

In the example above, the name of the SD device is /dev/sdb, but this may vary on your system. The best way to identify the name is by checking the size of the device.

You can use a graphical tool like GParted or command-line tools such as fdisk or parted to format the drive and create the required partition. We’ll use the parted utility.

Note that formatting and creating new partitions is a destructive process, and it will erase all the existing data. If you have data on the SD card, first you should back it up.

First, create the partition table by running the following command:

sudo parted /dev/sdb --script -- mklabel msdos

Create two partitions. Fat32 boot partition with 128 MB, and ext4 root partition that takes the rest of the SD space:

sudo parted /dev/sdb --script -- mkpart primary fat32 1 128sudo parted /dev/sdb --script -- mkpart primary ext4 128 100%

Add a bootable flag to the boot partition:

sudo parted /dev/sdb --script -- set 1 boot on

Once done, use the command below to print the partition table and verify that everything is set up correctly:

sudo parted /dev/sdb --script print

The output should look something like this:

Model: Generic- SD/MMC/MS PRO (scsi)
Disk /dev/sdb: 64.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  128MB   127MB   primary               boot, lba
 2      128MB   64.0GB  63.9GB  primary

Format the boot partition to FAT32:

sudo mkfs.vfat -F32 /dev/sdb1
mkfs.fat 4.1 (2017-01-24)

Format the root partition to ext4:

sudo mkfs.ext4 -F /dev/sdb2
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 15599104 4k blocks and 3899952 inodes
Filesystem UUID: 0992147a-aa9d-474b-b974-e0a015766392
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done   

Copying the OS Files

Now that the SD card is partitioned, we’ll mount the partitions and copy the data from the downloaded tar file.

Before mounting the SD partitions, create the directories that will serve as mount points:

sudo mkdir -p /mnt/arch/{boot,root}

Mount both partitions using the commands below:

sudo mount /dev/sdb1 /mnt/arch/bootsudo mount /dev/sdb2 /mnt/arch/root

If you downloaded the file using a web browser, then it should be stored in the Downloads folder located in your user account. Otherwise, if you used the wget command, the file is located in your current working directory .

Use the tar command to extract the content of the Arch Linux tar.gz file to the /mnt/arch/root directory:

sudo tar -xf ArchLinuxARM-rpi-3-latest.tar.gz -C /mnt/arch/root

Next move the boot files to the mounted boot partition:

sudo mv /mnt/arch/root/boot/* /mnt/arch/boot

Once done, unmount both partitions:

sudo umount /mnt/arch/boot /mnt/arch/root

That’s all! You have a bootable Arch Linux OS on your SD card.

Booting up the Pi

Put the SD card into your Raspberry Pi board, plug in the monitor, keyboard and power source, and you’re ready to go.

The default username is alarm, and the password is alarm. This user has sudo privileges .

You can also log in as root with password root.

Once logged in, initialize the pacman keyring and populate the package signing keys:

pacman-key --initpacman-key --populate archlinuxarm

From here, you can change the user password, set up the WiFi, and configure your new Arch Linux installation.

Conclusion

Installing Arch Linux on Raspberry Pi 3/34bis a pretty straightforward process. All you need to do is prepare the SD card, copy the files, and boot up the Raspberry Pi.

If you hit a problem or have feedback, leave a comment below.