You might need to chroot into a Linux distro of a different platform to run executables of that platform, and perform tasks. I will show you how!

Getting the dependencies

For this to work, you will need the correct qemu static binary. On Debian and Ubuntu it is installed easily by running apt install qemu-user-static binfmt-support and that’s all there is about preparation. If your distro does not provide this package, you can get the package from any other system (that matches your host architecture), and extract the correct binary (qemu-*-static) and then proceed with this guide.

If you’re on Arch Linux you will have to install binfmt-qemu-static and qemu-user-static from the AUR.

Getting the target ready

Of course you will have to mount or place the filesystem of your target somewhere. Let’s assume it’s /target and let’s assume the target is running ARM (32bit), so we’d simply run cp /usr/bin/qemu-arm-static /target/usr/bin/ to get the target ready. Or adapt this command if you are copying it from somewhere else (if you did not get it from your distro package).

If you are just going to run simple executables that’s all there is to it. If you are going to run more advanced software you might have to bind mount /proc /sys and /dev to the target with:

mount --bind /dev /target/dev/
mount --bind /sys /target/sys/
mount --bind /proc /target/proc/

Alternatively, if you are using systemd, you can install the package systemd-container and then run systemd-nspawn -D /target instead of mounting the directories manually. But this is entirely optional, you can mount the directories manually if you don’t have the package handy.

Important information

Once you did this as stated above, you can keep the binary inside the file system for quick future use. And since this is a statically linked binary, it is even portable and can be used on another system where you might not have the qemu-user-static package. Just make sure if you are trying to access for example ARM from AMD64, that the qemu-arm-static binary is for AMD64, so that you can use it on any AMD64 Linux machine.

Going for chroot

Once you prepared the target as stated above, chroot should work automagically if you run chroot /target now.

Conclusoin

It is a really quick and easy thing to chroot into a different architecture as long as you got the qemu-*-static binary handy.

I hope this guide helped you out!