Can you run amd64 container on Raspberry Pi 4?

I use lxc on a local test server and a hetzner cloud server (amd64 cpus). Is it possible to run an amd64 container on the raspberry pi 4?

I have a big box doing very little and a raspberry pi doing nothing. It would seem more prudent to migrate to the pi.

Thanks,

Chris

Hi @chrismatchett,

No, you cant I suppose.
Regards.

Yeah, this kind of architecture emulation tends to be very tricky and unpleasant especially on such low powered devices :slight_smile:

I came to this forum looking for the same answer (create amd64 LXD containers on Raspberry Pi 4), since Pimox KVM VMs work but are too slow.

The feature we both are looking for is called “foreign architecture”, aka qemu-user-static. It existed in the days of old LXC (1.x, 2.x), but it was removed due to inherent unstability.

This is all the information I could get:

You will find most useful information in Tobias Waldekranz’ article:
https://westermo.github.io/2020/03/02/running-foreign-containers-on-lxd/

In the next link you can pick an OS and version (Ubuntu 20.04 in my case) and simply download rootfs.squashfs for host architecture (aarch64 in our case) and lxd.tar.xz for guest architecture (amd64 in our case):

https://jenkins.linuxcontainers.org/job/image-ubuntu/architecture=arm64,release=focal,variant=cloud/

All that is left is unpack rootfs.quashfs, copy /usr/bin/qemu-aarch64-static (supposing that your host is aarch64) the same folder of the squashfs for that image and then repack it again (not necessary in Ubuntu Server). After that, you have to modify metadata.yaml inside lxd.tar.xz to reflect the existence of QEMU in the image. (credit to Tobias Waldekranz and dangeroushobo)

Import image with lxc image import lxd.tar.xz rootfs.quashfs --alias image_name
Create and launch instance (container): lxc launch image_name instance_name
Try it!

  • lxc exec instance_name -- uname -m
  • lxc exec instance_name -- cat /proc/sys/fs/binfmt_misc/qemu-x86_64 (checking emulation for guest architecture)
    The last command should return x86_64. Try it throughfully and remember this is not meant for production. Right now not even networking works for me.

PS: Do NOT use lxc import lxd.tar.xz rootfs.quashfs --alias image_name. Use lxc image import lxd.tar.xz rootfs.quashfs --alias image_name instead.