Installing Arch Linux Arm on the Raspberry Pi
I have not added anything to this series in well over a year, and the Debian based operating system that I had previously installed on the Raspberry Pi would be quite out of date, requiring a reinstall. Rather than install an up-to-date Debian based operating system, I have decided to install Arch Linux Arm. It is a rolling release distribution, meaning that I will not have to take the time to reinstall it again if it becomes out-of-date.
This article will show how to install Arch Linux Arm on the Raspberry Pi. I will be using a laptop with Arch Linux on it to install Arch Linux Arm on the Raspberry Pi's SD card, but the steps would generally be the same even if I had a distribution other than Arch Linux on my laptop.
Install Arch Linux on the SD Card
First, I plugged the SD card into my laptop and used fdisk to find the SD card's identifier, which was sdb
in this case.
$
sudo fdisk -l
Disk /dev/sda: 149.05 GiB, 160041885696 bytes, 312581808 sectors
Disk model: Hitachi HTS72321
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 309247 307200 150M 83 Linux
/dev/sda2 309248 12892159 12582912 6G 83 Linux
/dev/sda3 12892160 86292479 73400320 35G 83 Linux
/dev/sda4 86292480 159692799 73400320 35G 83 Linux
Disk /dev/sdb: 7.25 GiB, 7780433920 bytes, 15196160 sectors
Disk model: Multi-Card
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc30ac758
Device Boot Start End Sectors Size Id Type
/dev/sdb1 8192 532479 524288 256M c W95 FAT32 (LBA)
/dev/sdb2 532480 15196159 14663680 7G 83 Linux
I then partitioned the drive using fdisk.
$
sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): o
Created a new DOS disklabel with disk identifier 0x67a9e83d.
Command (m for help): p
Disk /dev/sdb: 7.25 GiB, 7780433920 bytes, 15196160 sectors
Disk model: Multi-Card
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x67a9e83d
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-15196159, default 2048): RETERN
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-15196159, default 15196159): +100M
Created a new partition 1 of type 'Linux' and of size 100 MiB.
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (206848-15196159, default 206848): RETERN
Last sector, +/-sectors or +/-size{K,M,G,T,P} (206848-15196159, default 15196159): RETERN
Created a new partition 2 of type 'Linux' and of size 7.1 GiB.
Command (m for help): w
I then formatted the first partition.
$
sudo mkfs -t vfat /dev/sdb1
mkfs.fat 4.2 (2021-01-31)
I then mounted the first partition.
$
mkdir boot
$
sudo mount /dev/sdb1 boot
I then formatted the second partition.
$
sudo mkfs -t ext4 /dev/sdb2
mke2fs 1.46.4 (18-Aug-2021)
Creating filesystem with 1873664 4k blocks and 468640 inodes
Filesystem UUID: d2874535-cf2f-4e5f-bbb4-758320c6effb
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information:
done
I then mounted the second partition.
$
mkdir root
$
sudo mount /dev/sdb2 root
I then downloaded the current Arch Linux Arm ISO file.
$
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz
I then extracted the contents of the ISO file onto the second partition of the SD card and also populated the first partition.
$
su root
$
bsdtar -xpf ArchLinuxARM-rpi-armv7-latest.tar.gz -C root
$
sync
$
mv root/boot/* boot
I then unmounted the partitions.
$
umount boot root
Setting Up Arch Linux
I then plugged the SD card into the Raspberry Pi and booted it. I plugged in a monitor and keyboard and logged into the system's default account, which has user name alarm
and password alarm
.
I then changed the password of the alarm
user.
$
passwd
I then logged in as the root user, which has default password root
.
$
su root
I then changed the password of the root
user.
$
passwd
I then connected to Wi-Fi using wifi-menu
.
#
wifi-menu
For some reason, after rebooting, the Pi would not automatically reconnect to the Wi-Fi network (I think that, in the past, it would do so automatically). Consequently, I ran the following netctl
command with the name of the network profile to which the Pi was connected. This ensures that it connects to the Wi-Fi network automatically upon boot.
#
netctl enable <name_of_wifi_profile>
I then setup the package management system and updated all of the out-of-date packages.
#
pacman-key --init
#
pacman-key --populate archlinuxarm
#
pacman -Syu
I then installed sudo
and vim
because they are useful tools for me.
#
pacman -S sudo
#
pacman -S vim
I also added the alarm
user to the wheel
group.
#
usermod -aG wheel alarm
I then used visudo
to make the alarm
user a sudoer and configure its privileges.
#
export EDITOR="/usr/bin/vim"
#
visudo
I added the following three lines to the sudoers file.
%wheel ALL=(ALL) ALL
alarm ALL = NOPASSWD: /usr/bin/pacman
alarm ALL = NOPASSWD: /usr/bin/shutdown
I then reverted to the alarm
user and added the following line to the /home/alarm/.bashrc
in order to change the appearance of the prompt
export PS1="\[\e[1;33m\][\[\e[1;37m\]\W\e\[[1;33m]\]#\[\e[0m\] "
I then went back to my laptop and logged into the Pi via SSH. I found its IP address in the same way that I did in this article.
#
ssh alarm@192.168.1.29
I then set up an SSH key pair so that I can log into the Pi without using its password. In order to do that, I ran the following two commands on my laptop.
#
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/idm/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/idm/.ssh/id_rsa
Your public key has been saved in /home/idm/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:jzSLReSOTPKlJ+6FiqdyUVCvs1g+RZEEs6XwSRvnrO8 idm@HP-Arch
The key's randomart image is:
#
ssh-copy-id alarm@192.168.1.29
Previous | Published August 31, 2022 | Next |
---|