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 -lDisk /dev/sda: 149.05 GiB, 160041885696 bytes, 312581808 sectorsDisk model: Hitachi HTS72321Units: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x00000000Device 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 LinuxDisk /dev/sdb: 7.25 GiB, 7780433920 bytes, 15196160 sectorsDisk model: Multi-CardUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0xc30ac758Device Boot Start End Sectors Size Id Type/dev/sdb1 8192 532479 524288 256M c W95 FAT32 (LBA)/dev/sdb2 532480 15196159 14663680 7G 83 LinuxI 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): oCreated a new DOS disklabel with disk identifier 0x67a9e83d.Command (m for help): pDisk /dev/sdb: 7.25 GiB, 7780433920 bytes, 15196160 sectorsDisk model: Multi-CardUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x67a9e83dCommand (m for help): nPartition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions)Select (default p): pPartition number (1-4, default 1): 1First sector (2048-15196159, default 2048): RETERNLast sector, +/-sectors or +/-size{K,M,G,T,P} (2048-15196159, default 15196159): +100MCreated a new partition 1 of type 'Linux' and of size 100 MiB.Command (m for help): tSelected partition 1Hex code or alias (type L to list all): cChanged 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): pPartition number (2-4, default 2): 2First sector (206848-15196159, default 206848): RETERNLast sector, +/-sectors or +/-size{K,M,G,T,P} (206848-15196159, default 15196159): RETERNCreated a new partition 2 of type 'Linux' and of size 7.1 GiB.Command (m for help): wI then formatted the first partition.
$ sudo mkfs -t vfat /dev/sdb1mkfs.fat 4.2 (2021-01-31)I then mounted the first partition.
$ mkdir boot$ sudo mount /dev/sdb1 bootI 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: doneI then mounted the second partition.
$ mkdir root$ sudo mount /dev/sdb2 rootI then downloaded the current Arch Linux Arm ISO file.
$ wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gzI 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/* bootI then unmounted the partitions.
$ umount boot rootSetting 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.
$ passwdI then logged in as the root user, which has default password root.
$ su rootI then changed the password of the root user.
$ passwdI then connected to Wi-Fi using wifi-menu.
# wifi-menuFor 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 -SyuI then installed sudo and vim because they are useful tools for me.
# pacman -S sudo# pacman -S vimI also added the alarm user to the wheel group.
# usermod -aG wheel alarmI then used visudo to make the alarm user a sudoer and configure its privileges.
# export EDITOR="/usr/bin/vim"# visudoI added the following three lines to the sudoers file.
%wheel ALL=(ALL) ALLalarm ALL = NOPASSWD: /usr/bin/pacmanalarm ALL = NOPASSWD: /usr/bin/shutdownI 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.29I 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 |
|---|