qemu-user-static package makes it straightforward to run binaries from another platform, but I ran into a roadblock running amd64 binaries on an i386 machine. It looks like the binfmt spec for amd64 isn’t included in recent i386 releases of
qemu-user-static to save people from themselves after they manage to install the package on a mismatched architecture. Frustrating.
Specifically, this unsupport is accomplished by excluding the file
/var/lib/binfmts/qemu-x86_64 from the installation. The actual interpreter,
/usr/bin/qemu-x86_64-static, is exactly where you’d expect it to be. The file listing for the package didn’t include anything destined for
/var/lib/binfmts, so I figured they must be unpacked and put there by an installation script. So I pulled the package apart:
$ apt-get download qemu-user-static $ dpkg-deb -R qemu-user-static*.deb qemu-user-static $ cd qemu-user-static/DEBIAN/ $ cat postinst
The script contains a variety of magic number and mask definitions. The script registers these via
update-binfmts only as appropriate for the host platform.
Great, so we should be able to sneakily perform our own update:
$ sudo update-binfmts \ --package qemu-user-static \ --install qemu-x86_64 /usr/bin/qemu-x86_64-static \ --magic '\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00' \ --mask '\xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' \ --offset 0 \ --credential yes
$ sudo cp /usr/bin/qemu-x86_64-static build-amd64/usr/bin $ sudo chroot build-amd64 /debootstrap/debootstrap --second-stage qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Screw it, I’m reinstalling this machine with a 64-bit OS.