The Raspberry Pi is a versatile credit card-sized computer that can be used for a variety of electronics projects. The great thing about the Raspberry Pi is that you have the option of installing different operating systems and aren’t limited to Raspberry Pi OS. This includes Arch Linux, which is revered for its simplicity. Luckily, there is a version of Arch Linux designed to work with ARM processors. Let’s take a look at how you can install Arch Linux on Raspberry Pi.
Also read: How to Boot Raspberry Pi 4 From USB
Requirements
Before we get started, you will need to have the following things:
- Raspberry Pi
- 8GB (or more) micro SD
- Arch Linux ARM (Scroll down the list to find the link for the Raspberry Pi image.)
- Stable Internet connection
- Computer system that can read the SD card. (We will be using Linux for this tutorial.)
Prepare SD Card
First, you will need to make a list of the storage devices attached to your machine in order to identify which one is your SD card. Do this with the following command:
sudo fdisk -l
The SD card that I’m using is “/dev/sdc.”
We need to format the SD card. To do this, run the following command, bearing in mind that you will need to replace “/dev/sdc” with the name of your SD card:
sudo fdisk /dev/sdc
You will need to clear any partitions that exist on the drive. To do this, type o
and hit Enter in your terminal.
Enter p
into your terminal to check to see if any partitions remain.
If no partitions remain, then go ahead and create the boot partition by typing n
, then p
, followed by 1
into your terminal. p
stands for primary, and 1
stands for the first partition on the drive. You’ll need to press the Enter button after this sequence to continue.
When prompted about the last sector, type +100M
and hit Enter.
Enter t
into the command prompt followed by c
to set the first partition as type “W95 FAT32 (LBA).”
Type n
, followed by p
(for primary), then 2
in order to create the root partition.
Hit Enter twice in order to accept the default settings for the first and last sectors.
Write the partition table and exit fdisk by entering w
.
We need to mount the FAT & ext4 filesystems. To list the partitions, type the following:
sudo fdisk -l
Your SD card will show up, and you’ll be able to see the partitions. In my case the partitions are “/dev/sdb1” and “/dev/sdb2.”
Also read: How to Turn Your Raspberry Pi into a Wireless Access Point
Copy Arch Linux Files to SD Card
The boot and root partitions need to be mounted next. Do this with the following series of commands. Remember to replace the partition names in these commands with your partition names.
sudo mkfs.vfat /dev/sdb1 sudo mkdir boot sudo mount /dev/sdb1 boot sudo mkfs.ext4 /dev/sdb2 sudo mkdir root sudo mount /dev/sdb2 root
Now, place the Arch Linux file that you downloaded into your home folder and extract it to the root folder of your SD card with the following command:
sudo bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root sync
The boot files will need to be moved to the boot partition of your SD card with:
sudo mv root/boot/* boot
You can umount the two partitions with:
unmount boot root
Insert the SD card into your Raspberry Pi.
Also read: How to Use Pushbuttons With Raspberry Pi GPIO Pins
Initial Setup on Raspberry Pi
After inserting the SD card into your Raspberry Pi, go ahead and fire it up. You will need to either connect to the Internet via an ethernet cable or a Wi-Fi network. To connect via Wi-Fi, first log in with the default root account. The username for this account is “root,” and the password is “root.” Now, run the following command:
wifi-menu
A menu will load, and you will be able to select your Wi-Fi network and log in. Now, finalize the installation process by initializing the pacman keyring and populating the Arch Linux ARM package signing keys with:
pacman-key --init
pacman-key --populate archlinuxarm
YOu can go ahead and update the system packages with:
pacman -Syu
You should change the default username. Do this with the following command:
usermod -l newusername oldusername
Also, change the password with:
passwd newusername
You’ll be asked to enter a new password and then confirm it. To change the name of the home folder to reflect the new username, run the following command:
usermod -d /home/newusername -m newusername
You should also change the password of the root account. Do this with:
passwd
In order to give sudo privileges to your user account, you’ll have to run the following to install the sudo package:
pacman -S sudo
You will have to edit the configuration file for sudo. Do this with:
EDITOR=nano visudo
Add newusername ALL=(ALL) ALL
under the line that reads root ALL=(ALL) ALL
Close and save the file, and you’re all set.
Now that you have installed Arch Linux on the Raspberry Pi, there are plenty of things you can do, including installing and playing Minecraft and turning it into a NAS or Plex server. Your imagination is the limit.
Our latest tutorials delivered straight to your inbox