Run arm binaries on x86_64 Debian as if it was native

Just to get this out of the way: it uses qemu, so this is not a secret hack to make stuff run faster. This is meant to make stuff run easier.

Step 1: install qemu support packages for arm:

sudo apt install binfmt-support qemu-user-static qemu-system-arm

Step 2: enable miscellaneous binaries support (binfmt):

sudo systemctl enable --now binfmt-support

Step 3: enable arm support in apt (so you can even install arm build dependencies or binaries if you are so inclined):

sudo dpkg --add-architecture armhf
sudo apt update

For sources that do not support armhf, you can specify the architecture that is supported in the configuration: So this:

deb https://blah/blah stable main

becomes:

deb [arch=amd64] httpsblah/blah stable main

The result (an example):

apt install sl:armhf
sl

Enjoy the steam locomotive in all its ARM goodness.

Another example, troubleshoot or maintain your raspberry (raspbian) from your PC:

mount /dev/sdcardrootpartition /mnt # Mount raspberry pi sdcard that you just popped in your PC
for x in dev sys proc dev/pts ; do mount --bind /$x /mnt/$x ; done # mount convenience filesystems
chroot /mnt su - # (type exit to close the shell)

Enjoy the raspberry system as if it was native

This article is my 11th oldest. It is 212 words long