The Simplest Way To Create an ARM Chroot in Arch Linux
Utilizing an ARM chroot on a x86_64 system together with QEMU is a rather easy and convenient way to build ARM packages on a x86_64 machine. In this post, we describe the simplest way in doing so on Arch Linux.
The Arch Linux wiki describes an approach to create an ARM chroot leveraging QEMU. It assumes that an ARM root partition is installed on an SD card/storage. This storage is mounted to a folder on an Arch Linux (x86_64) system and used as root for the chroot command.
That’s a quite simple solution if you have a real ARM device but do not want to log into it device to install software. But if you just want to build ARM packages, you don’t even need a real device or an SD card. Instead one can use image archives from Arch Linux ARM, extract such an archive into a folder and chroot into that folder to build such packages.
The first steps are identical to those described in the Arch Linux wiki:
Restart the systemd-binfmt service:
$ systemctl restart systemd-binfmt.service
Make sure that the ARM executable support is active for the desired ARM architecture by execute
$ ls /proc/sys/fs/binfmt_misc
and verifying that the architecture is in the list.
Instead of mounting an SD card, we use an image from Arch Linux ARM:
Download an image file from Arch Linu ARM
Create a folder that you want to use as root for the chroot environment.
Extract the image files from the archive into that folder:
$ bsdtar -xpf <image-archive> -C <root-folder>
Make the new root folder a mount point:
$ mount --bind <root-folder> <root-folder>
Chroot into the new folder, initialize the pacman keyring and populate the Arch Linux ARM package signing keys:
$ arch-chroot <root-folder> $ pacman-key --init $ pacman-key --populate archlinuxarm
Update the chroot environment and use it:
$ pacman -Syu