Howto install archlinuxarm raspberrypi5

From Vidalinux Wiki
Jump to navigation Jump to search

download images

download raspios image:

wget https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2023-12-06/2023-12-05-raspios-bookworm-arm64.img.xz

download archlinux-arm-aarch64 image:

wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz

decompress raspios image:

xz -d 2023-12-05-raspios-bookworm-arm64.img.xz

change raspios image name:

mv 2023-12-05-raspios-bookworm-arm64.img $(date +%F)-archlinux-aarch64.img

chroot with qemu

use qemu-user-static to interpret the arm instructions in the chroot:

pacman -Sy qemu-user-static --noconfirm

install multipath-tools:

pacman -S multipath-tools

script to mount raspberrypi image:

cat > ./raspimg << 'EOF'
#!/bin/bash
if [ $# -eq 0 ]
 then
   echo "" && \
   echo " mount:  mount image" && \
   echo " umount: unmount image" && \
   echo "" && \
   echo " example: ./raspimg mount 2024-02-20-archlinux-aarch64.img"
   echo ""; exit
fi
if [ $1 = mount ];
then
 if [ ! -d /mnt/temp ];
 then
 mkdir /mnt/temp
 fi
 kpartx -va $2 1> /tmp/part-names.txt
 PART2=$(cat /tmp/part-names.txt | awk '{print $3}' | grep p2$)
 PART1=$(cat /tmp/part-names.txt | awk '{print $3}' | grep p1$)
 sleep 1
 mount /dev/mapper/$PART2 /mnt/temp
 mount /dev/mapper/$PART1 /mnt/temp/boot/
 sleep 1
 read -p "do you want to bind /dev /proc /sys /pkg directories now : " QUESTION
 if [ $QUESTION = yes ];
 then 
 mount -o bind /dev /mnt/temp/dev
 mount -o bind /dev/pts /mnt/temp/dev/pts
 mount -o bind /proc /mnt/temp/proc
 mount -o bind /sys /mnt/temp/sys
 rm /tmp/part-names.txt
 if [[ $2 == *[32]* ]]; then
  if [ ! -d ./pkg32 ];
  then
  mkdir ./pkg32
  fi
 mount -o bind ./pkg32 /mnt/temp/var/cache/pacman/pkg
 fi
 if [[ $2 == *[64]* ]]; then
  if [ ! -d ./pkg64 ];
  then
  mkdir ./pkg64
  fi
 mount -o bind ./pkg64 /mnt/temp/var/cache/pacman/pkg
  fi
 fi
fi
if [ $1 = umount ];
then
umount /mnt/temp/var/cache/pacman/pkg
umount /mnt/temp/dev/pts
umount /mnt/temp/dev
umount /mnt/temp/proc -l
umount /mnt/temp/sys
umount /mnt/temp/boot
umount /mnt/temp 
kpartx -vd $2
fi
EOF

mount image to /mnt/temp:

./raspimg mount 2024-02-20-archlinux-aarch64.img

copy the qemu-aarch64-static binary to the chroot:

cp /usr/bin/qemu-aarch64-static /mnt/temp/usr/bin/

register the qemu-aarch64-static as an arm interpreter in the kernel:

echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-aarch64-static:' > /proc/sys/fs/binfmt_misc/register

enter chroot using arch-chroot:

chroot /mnt/temp

configure image

initialize pacman:

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

install the following packages:

pacman -Sy base-devel libnewt git wget rsync networkmanager parted multipath-tools lsof git sudo fakeroot screen --noconfirm

install expand-sd:

curl -ko /usr/local/bin/expand-sd https://img.vidalinux.com/files/expand-sd
chmod +x /usr/local/bin/expand-sd

set password to alarm user:

passwd alarm
echo "alarm ALL=(ALL:ALL) ALL" > /etc/sudoers.d/alarm

change root password:

passwd root

update and replace current kernel:

pacman -Sy linux-rpi --noconfirm

disable the following services:

systemctl disable systemd-networkd
systemctl disable systemd-networkd.socket
systemctl disable systemd-resolved

start and enable networkmanager:

systemctl enable NetworkManager
systemctl start NetworkManager

desktop environment

install xorg:

pacman -S alsa-utils alsa-oss xorg xorg-server xf86-video-fbdev xorg-xrefresh adobe-source-han-sans-cn-fonts ttf-dejavu ttf-bitstream-vera wqy-zenhei ttf-arphic-ukai ttf-arphic-uming opendesktop-fonts ttf-inconsolata ttf-ubuntu-font-family adobe-source-code-pro-fonts

install xfce4:

pacman -S xfce4 xfce4-goodies lightdm-gtk-greeter accountsservice gvfs gvfs-mtp ntfs-3g exfat-utils p7zip file-roller fcitx fcitx-configtool fcitx-googlepinyin fcitx-cloudpinyin fcitx-gtk2 fcitx-gtk3 network-manager-applet gnome-keyring pavucontrol pavucontrol-qt pulseaudio-alsa

enable and start lightdm:

systemctl enable lightdm
systemctl start lightdm

desktop auto-login

if you want to set auto-login for user alarm add the following to /etc/lightdm/lightdm.conf:

cat >> /etc/lightdm/lightdm.conf << 'EOF'
[Seat:*]
user-session=xcfe4
autologin-user=alarm
autologin-user-timeout=0
EOF

add group autologin and user to the group:

groupadd -r autologin
gpasswd -a alarm autologin

references