nerdstuff.org

crazy content for mankind, great stuff for nerds

25 Apr 2020

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:

  1. Install binfmt-qemu-static and qemu-user-static from the AUR on the x86_64 host.

  2. Restart the systemd-binfmt service:

     $ systemctl restart systemd-binfmt.service
    
  3. 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:

  1. Download an image file from Arch Linu ARM

  2. Create a folder that you want to use as root for the chroot environment.

  3. Extract the image files from the archive into that folder:

     $ bsdtar -xpf <image-archive> -C <root-folder>
    
  4. Make the new root folder a mount point:

     $ mount --bind <root-folder> <root-folder>
    
  5. 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
    
  6. Update the chroot environment and use it:

     $ pacman -Syu
    

The AUR package armutils contains the tool mkarmroot which implements this method.

comments powered by Disqus