Learn how to chroot into a armv8 (aarch64) platform from a x86_64 ArchLinux installation with a working shell!
Use case
I came across this convienience while I encountered boot problems on my Pine64 RockPro64, and I only had x86_64 computers and a Raspberry PI (rarely used) at the time.
Requirements
Physical access
If your scenario is repairing a broken installation you can't boot from (in my case a ArchlinuxArm installation on a RockPro64), you'll need to retrieve the physical media containing the linux installation you wish to repair (a microSD for me) and plug it to your other computer.
Packages
Assuming your on an Arch base distro, you will need the following packages.
sudo pacman -S qemu-system-aarch64 qemu-user-static qemu-user-static-binfmt
Those are the packages required for chrooting in aarch64, same can be done for armv7, you should then replace qemu-system-aarch64 with qemu-system-arm. Most of these packages are optionals of qemu-base.
Mounting your filesystem
find a comfy spot to mount your fs.
sudo mkdir -p /mnt/alarm-root
mount your root and boot partition. Check your device name with the lsblk command before hand (let's assume it is sdb for the rest). On my physical media the root partition is installed on sdb5 and boot partition on sdb4.
sudo mount /dev/sdb5 /mnt/alarm-root
sudo mount /dev/sdb4 /mnt/alarm-root/boot
Mount the temporary directories
Some actions like updating your system will require you to have the temporary API filesystems:
# cd to your new root
cd /mnt/alarm-root
sudo mount -t proc /proc proc/
sudo mount -t sysfs /sys sys/
sudo mount --rbind /dev dev/
Copying the binary to chrooted environment
Next you'll need to copy the qemu-aarch64-static binary to your aarch64 bin directory.
# use sudo if necessary
sudo cp /bin/qemu-aarch64-static /mnt/alarm-root/bin
Chroot !
Now all is set to chroot onto aarch64 just enter the following:
sudo chroot /mnt/alarm-root/ qemu-aarch64-static /bin/bash
A bash shell should be prompted. If not sure, try a uname -a command to check the system information.
Now try to update your system with pacman!