Installing Arch Linux ARM on a Raspberry Pi

My cheat sheet for deploying multiple Arch Linux machines, Raspberry Pis here. Installs pacserve, rngd and yaourt in a btrfs subvolume root. To allow local users to poweroff, polkit is also installed.

Filesystem setup

See also the Archlinux ARM guide.

Change sdx to sdb/sdc/…

sudo fdisk /dev/sdx
sudo mkfs.btrfs /dev/sdx2
sudo mkfs.vfat /dev/sdx1
mkdir -p tmp/{r,b}oot
cd tmp
sudo mount /dev/sdx2 root
sudo btrfs subvolume create root/root
sudo umount root

Copying the files

Use ArchLinuxARM-rpi-2-latest.tar.gz for the Raspberry Pi 2 or 3.

wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
sudo mount /dev/sdx1 boot
sudo mount -o subvol=root,autodefrag,compress=lzo /dev/sdx2 root
sudo su -c "bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root" && sync
sudo mv root/boot/* boot
sudo umount boot
sudo mount /dev/sdx1 root/boot

QEMU chroot

Optional. You can skip this and power the Pi up instead.

sudo cp /usr/bin/qemu-arm-static root/usr/bin
sudo arch-chroot root /bin/bash

Configuration

echo "root=/dev/mmcblk0p2 rootflags=subvol=root,autodefrag,compress=lzo rw rootwait console=tty1 elevator=deadline" > /boot/cmdline.txt
sed -i "s/gpu_mem=64/gpu_mem=16/" /boot/config.txt

cat << EOF >> /boot/config.txt
start_file=start_x.elf
fixup_file=fixup_x.dat
start_x=1
EOF

sed -i '/\[options\]/a CacheDir    = /var/cache/pacman/pkg/' /etc/pacman.conf
sed -i '/\[options\]/a CleanMethod = KeepCurrent' /etc/pacman.conf
cat << EOF >> /etc/pacman.conf
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/arm

[xyne-any]
Server = http://xyne.archlinux.ca/repos/xyne
EOF

Package installation

pacman -Syu --needed pacserve git yajl rng-tools polkit archlinuxarm-keyring archlinux-keyring base-devel
systemctl enable pacserve rngd
echo 'RNGD_OPTS="-o /dev/random -r /dev/hwrng"' > /etc/conf.d/rngd
echo "alarm ALL=(ALL) ALL" >> /etc/sudoers
pacman.conf-insert_pacserve > /tmp/pacman.conf
mv /tmp/pacman.conf /etc/pacman.conf
su alarm
cd
git clone https://aur.archlinux.org/package-query.git
cd package-query
makepkg -s
mv package-query*.tar.xz /tmp
cd ..
rm -rf package-query
exit
pacman -U /tmp/package-query*.tar.xz
pacman -S yaourt
exit

sudo umount root/boot root or reboot

Post installation (on the Pi)

SSH into alarm with password alarm. root password is root, but SSH login for root is by default disabled.

sudo hostnamectl set-hostname xxx
sudo timedatectl set-timezone Yourtime/zone
sudo vi /etc/systemd/timesyncd.conf
sudo timedatectl set-ntp true
sudo pacman-key --init
passwd
sudo passwd

Troubleshooting

Can’t unmount for some reason? Use the hammer (not recommended): sudo fuser -km mntpoint || sudo umount -l mntpoint

Further information

For more, see the Arch wiki.