Skip to content

Instantly share code, notes, and snippets.

@gokart23
Last active June 3, 2024 00:57
Show Gist options
  • Save gokart23/8ade2d431ead2de47340160301837cab to your computer and use it in GitHub Desktop.
Save gokart23/8ade2d431ead2de47340160301837cab to your computer and use it in GitHub Desktop.
Run ARM chroot on x86 machine (both ArchLinux)

Steps

  1. Install qemu-user-static (yay -S qemu-user-static).
    • This might need you to install pcre-static and update PGP keys (follow the tips in the comments here).
  2. If not already present, install systemd-binfmt, the revamped version of binfmt-support tools
    • Your system has to support transparent Qemu user emulation, but fortunately, that is mostly enabled once the steps here have been followed.
  3. Check the status of the systemd-binfmt unit (systemctl status systemd-binfmt) and (re)start if needed (sudo systemctl restart systemd-binfmt)
    • This unit has ARM support by default, but check the current documentation to make install it if needed
  4. Mount the root partition of the ARM system into a folder (for e.g., sudo mount /dev/sdb2 arm_mountpoint)
  5. Copy the QEMU ARM static binary (/usr/bin/qemu-arm-static on my distro) to the mounted root directory's usr/bin (for e.g., HOME/arm_mountpoint/$> sudo cp /usr/bin/qemu-arm-static usr/bin/)
  6. That's it! Now we can chroot successfully into ARM root directory, and Qemu will transparently emulate this for us. That is, run HOME/arm_mountpoint/$> sudo chroot . bin/bash.

Helpful links

  • Debian Qemu user emulation: Link
  • chroot into different architecture: Link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment