QEMU User Emulation
This page discusses how to transparently run packages for incompatible architectures by using QEMU. This can be used for any binary, but is most often used for multiarch packages - see the multiarch category.
To test which binary targets you can run on your system, do:
sudo apt install arch-test
arch-test
This command will return amd64 and i386 on most PCs. If you see a much longer list, someone else may already have followed these instructions.
To run non-native target executables alongside native ones, do:
# Install necessary packages:
sudo apt install qemu-user qemu-user-binfmt
# Add support for normal dynamically-linked executables:
# (replace <architecture> with e.g. "armhf" if you want to run armhf programs)
sudo dpkg --add-architecture <architecture>
sudo apt update
sudo apt install libc6:<architecture>
# Install a test package:
sudo apt install hello:<architecture>
# Should print "Hello, world!":
hello
# You can remove the test package once it works:
sudo apt remove hello:<architecture>
If the hello command doesn't work, try sudo hello instead. If that works, you may need to set the vm.mmap_min_addr=0 sysctl option before programs will run as a non-root user.
arch-test should return a much longer list once this process is complete.
Issues across Debian versions
Debian Trixie replaced qemu-user-static with qemu-user, and the former may be removed altogether in later versions of Debian
Of historic interest, Debian Buster (released 2017) had a bug that caused segfaults in common scenarios. If you're still using Debian Buster, upgrade to at least qemu-user-static 5.2, available from buster-backports.
Also, historically, Debian Stretch (release 2008) and earlier had limited support for running qemu-user-static in a chroot. Specifically, you needed to ensure e.g. /usr/bin/qemu-arm-static was available in the chroot (usually by copying or bind-mounting it).
See Also
QEMU User space emulator: upstream documentation
