Arch Linux Aarch64 (arm8)

Arch Linux Aarch64 (arm8)

Installed on a Raspberry Pi Zero 2 W

Format SD Card (e.g. /dev/sdc)

echo -e "o\np\nn\np\n1\n\n+1G\nt\nc\nn\np\n2\n\n\nw" | sudo fdisk /dev/sdc

Create Filesystems on the SD partitions

sudo mkfs.vfat /dev/sdc1
sudo mkfs.ext4 /dev/sdc2

Mount the SD partitions

mkdir sdcard
mkdir sdcard/boot
mkdir sdcard/root
sudo mount /dev/sdc1 sdcard/boot
sudo mount /dev/sdc2 sdcard/root

Download the tar.gz image from the top of this post

(if not already done)

Extract the image to the SD card partitions at the mount points

sudo tar -zxvf alex-prime.tar.gz -C sdcard
sync

Wifi Configuration (optional)

sudo nano sdcard/boot/wifi_config.txt

Add your SSID and PASSWORD
		# Edit this file to set up your WiFi connection
➡		SSID=
➡		PASSWORD=

Unmount the SD partitions

sudo umount sdcard/boot sdcard/root

Put the SD card into the Pi and power it up

You will have to find the IP address assigned to the Pi, usually via your router interface.
Login as>  alarm : alarm

ssh alarm@{ipaddr}
Password: alarm
su
Password: root

Initialize pacman keyring and populate (as root)

pacman-key --init
pacman-key --populate archlinuxarm

Do a full system upgrade

pacman -Syu --overwrite "/boot/*.dtb"

Note: the overwrite directive handles a problem with the Device Tree Blob files in the /boot partition as not being managed by pacman and thus tends to raise file conflict errors which stops the upgrade. Overwriting these files is not a problem because the upgrade just replaces/upgrades them anyway.

OPTIONALS

Give alarm user sudo priviledges

pacman -S sudo nano
usermod -aG wheel alarm
EDITOR=nano visudo
uncomment=>        %wheel ALL=(ALL) ALL
exit

TEST
alarm> sudo uptime

Disable the Wifi services that were used for the first boot

If you do this you just have to make sure that you have setup some other way for wifi to connect, i.e., NetworkManager.

sudo systemctl disable update_wifi.service
sudo systemctl disable wpa_supplicant@wlan0.service

REFERENCE

The files and commands used/added on/to the image when setting up the wifi configuration for first boot.  The SD card partitions were mounted at boot and root

> sudo nano boot/wifi_config.txt
		# Edit this file to set up your WiFi connection
		SSID=
		PASSWORD=

> sudo nano root/etc/wpa_supplicant/wpa_supplicant.conf
		ctrl_interface=DIR=/var/run/wpa_supplicant
		update_config=1
		country=US

		network={
		    ssid="YOUR_SSID"
		    psk="YOUR_PASSWORD"
		    key_mgmt=WPA-PSK
		}


> sudo nano root/etc/systemd/network/10-wlan0.network
		[Match]
		Name=wlan0

		[Network]
		DHCP=yes

> sudo nano root/etc/systemd/system/wpa_supplicant@wlan0.service
		[Unit]
		Description=WPA supplicant for %I
		Wants=network.target
		After=network.target

		[Service]
		ExecStart=/usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i %I
		Restart=on-failure

		[Install]
		WantedBy=multi-user.target

> sudo nano root/usr/local/bin/update_wifi.sh
		#!/bin/bash

		# Path to the configuration file on the boot partition
		CONFIG_FILE="/boot/wifi_config.txt"
		WPA_SUPPLICANT_FILE="/etc/wpa_supplicant/wpa_supplicant.conf"

		log() {
		    local MESSAGE=$1
		    echo $MESSAGE
		    logger -t update_wifi "$MESSAGE"
		}

		log "Starting update_wifi.sh"

		if [ -f "$CONFIG_FILE" ]; then
		    log "Found config file: $CONFIG_FILE"
		    
		    # Read SSID and PASSWORD from the config file
		    SSID=$(grep '^SSID=' "$CONFIG_FILE" | cut -d '=' -f 2)
		    PASSWORD=$(grep '^PASSWORD=' "$CONFIG_FILE" | cut -d '=' -f 2)


		    if [ -n "$SSID" ] && [ -n "$PASSWORD" ]; then
			log "SSID: $SSID"
			log "Password: [hidden]"

			# Create a new wpa_supplicant.conf file
			cat <<EOF > "$WPA_SUPPLICANT_FILE"
		ctrl_interface=DIR=/var/run/wpa_supplicant
		update_config=1
		country=US

		network={
		    ssid="$SSID"
		    psk="$PASSWORD"
		    key_mgmt=WPA-PSK
		}
		EOF
			log "Created wpa_supplicant.conf"

			# Load WiFi driver
			modprobe brcmfmac
			log "Loaded WiFi driver"

			# Bring up wlan0 interface
			ifconfig wlan0 up
			log "Brought up wlan0 interface"

			# Enable and start wpa_supplicant service for wlan0
			systemctl enable wpa_supplicant@wlan0
			systemctl start wpa_supplicant@wlan0
			log "Started wpa_supplicant service for wlan0"
		    else
			log "SSID or Password not set, skipping configuration"
		    fi

		else
		    log "Config file not found: $CONFIG_FILE"
		fi

> sudo nano root/etc/systemd/system/update_wifi.service
		[Unit]
		Description=Update WiFi Configuration
		After=network.target
		Wants=network.target

		[Service]
		Type=oneshot
		ExecStart=/usr/local/bin/update_wifi.sh
		StandardOutput=journal
		StandardError=journal

		[Install]
		WantedBy=multi-user.target



> sudo chmod +x root/usr/local/bin/update_wifi.sh
> sudo ln -s /etc/systemd/system/update_wifi.service root/etc/systemd/system/multi-user.target.wants/update_wifi.service
> sudo ln -s /etc/systemd/system/wpa_supplicant@wlan0.service root/etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service