I chose to run Arch Linux Arm
on my Raspberry Pi 4b
because it is one of the few ARM
Linux distributions to take advantage of the 4b's new 64 bit processor. I personally own the model with 4Gb of RAM.
I chose to write this "how-to" because when I was searching how to install Arch on a Raspberry Pi, I couldn't find a clear guide on how to do so.
A Bash terminal can be accessed on Windows through the Windows Subsystem for Linux (WSL), and on Mac by opening the Terminal application.
Insert your MicroSD into your computer.
To verify the file path of your MicroSD card, enter:
$ lsblk
This command lists all drives and partitions connected to your computer. Your MicroSD should appear as:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
mmcblk1 179:0 0 29.8G 0 disk
mmcblk# is your MicroSD card with the trailing number being the identifier for that specific card. In my case that number is 1.
Now that we know what your MicroSD card is called we can safely format and partition the disk.
fdisk is a command line tool used to do this.
Be sure to replace the "#" with the correct number according to your system, for the remainder of this tutorial.
$ sudo fdisk /dev/mmcblk#
Enter the following commands into the fdisk prompt:
- Enter "o" to delete all partitions on the MicroSD.
- Enter "p" to list all partitions to verify there are none.
- Enter "n" to create a new partition.
- Enter "p" to set the new partition as a primary.
- Enter "1" to set the new partition as the first on the drive.
- Press ENTER to accept the default first sector, then type
+200M for the last sector.- Enter "t" to choose the type of partition.
- Enter "c" to set the only created partition to W95 FAT32 (LBA).
- Enter "n" to create a new, second partition.
- Enter "p" to set the second partition as a primary.
- Enter "2" to set it as the second partition on the drive.
- Hit the ENTER key twice to choose the default size values
for the second partition.- Enter "w" to write all changes to disk.
Now that the partitions are created, they need to be properly formated with a filesystem.
The first partition will be formatted as FAT32. This is where the boot directory will live.
From here until the MicroSD is removed from your computer, all commands need to be executed as root. If the commands are not exexuted as root,
there will be file permission errors upon boot, and the Pi will never fully turn on.
$ su
Password:
# mkfs.vfat /dev/mmcblk#p1
# mkdir boot
# mount /dev/mmcblk#p1 boot
The second partition will be formatted as ext4 which is the general standard for Linux filesystems
# mkfs.ext4 /dev/mmcblk#p2
# mkdir root
# mount /dev/mmcblk#p2 root
Next we will download the Linux image.
# wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz
This will extract the file to the mounted drive.
# bsdtar -xpf ArchLinuxARM-rpi-4-latest.tar.gz -C root
Next we will synchronize the drives.
# sync
We then need to move the boot files to the boot directory, otherwise the system will never boot.
# mv root/boot/* boot
Before unmounting the partitions, update /etc/fstab for the different SD block device compared to the Raspberry Pi 3.
$ sudo sed -i 's/mmcblk0/mmcblk1/g' root/etc/fstab
Now the image is written to the MicroSD card, and it can be unmounted
# umount boot root
At this point you can remove your MicroSD card and insert it into the Raspberry Pi 4, and apply power. An Ethernet cable should also be used to connect the device to your network because at this point WiFi will not connect.
Determine the IP address of your Raspberry Pi by logging into your router, or using a network scanning tool such as nmap.
From your Bash terminal on your computer we now need to SSH into the Raspberry Pi to complete the installation.
$ ssh alarm@RASPI-IP-ADDRESS
Password: alarm
The default root password is root.
Pacman is the command line tool for Arch Linux used to install software. Before any software is installed the keyring needs to be initialized to verify the integrity of all packages in the repositories.
$ pacman-key --init
$ pacman-key --populate archlinuxarm
All done! You should now be able to use your system however you like. Take a look at some of my other projects for ideas on what to do with your newly installed Arch Linux Raspberry Pi.