Kranz Korner

Random bits from a FLOSS geek

Cross-architecture Linux containers in Debian

with 4 comments

I wanted to create a Deb-o-Matic environment to testbuild packages for a different architecture. Taking inspiration on Stéphane’s excellent blog post, I tried to replicate the creation of a cross-architecture Linux container in Debian. Here are the steps I made:

Load binfmt_misc module:
# modprobe binfmt_misc

Install the required packages:
# apt-get install lxc debootstrap rsync qemu-user-static binfmt-support

Mount the cgroup virtual filesystem:
# mkdir /cgroup
# echo "none /cgroup cgroup defaults 0 0" >> /etc/fstab
# mount -a

I needed a specific template to create a cross-architecture container. I used the excellent one by Laurent Vivier. Download it, rename it as lxc-cross-debian, mark it executable, and store it under /usr/share/lxc/templates.

Create the cross-architecture container, an armhf one in this case:
# lxc-create -t cross-debian -n debian-armhf -- --arch armhf --suite sid --interpreter-path /usr/bin/qemu-arm-static

After a while, the container was created and I enjoyed my brand new armhf test machine 🙂

Written by Luca Falavigna

19/11/2013 at 09:53

Posted in Planet Debian

4 Responses

Subscribe to comments with RSS.

  1. Hello,

    You may want to try PRoot ( as an alternative when you can’t — or don’t want to — get root privileges:

    proot -q qemu-arm -r debian-armhf

    where “debian-armhf” is a directory that contains your Debian/ARM rootfs. PRoot can also bind host files or directories into the guest rootfs, for instance:

    proot -q qemu-arm -r debian-armhf -b $HOME

    Actually $HOME and a couple of other mandatory directories (like “/dev”, “/proc”, … ) are already bound when using the “-R” option instead of “-r”. Technically, it is possible to bind host programs over guest programs to avoid the CPU-time overhead and/or bugs (against pthreaded guest programs) induced by QEMU:

    host$ proot -q qemu-arm -R debian-armhf -b /usr/bin/sort

    guest$ file /usr/bin/join
    /usr/bin/join: ELF 32-bit LSB executable, ARM, […]

    guest$ /usr/bin/join –version
    join (GNU coreutils) 8.13

    guest$ file /usr/bin/sort
    /usr/bin/sort: ELF 64-bit LSB executable, x86-64, […]

    guest$ /usr/bin/sort –version
    sort (GNU coreutils) 8.21


    23/11/2013 at 21:26

  2. The template you used is not available at this server anymore, but I found out it has moved to Github:×0-v2.7.0/scripts/lxc-cross-debian

    Just random info for everyone looking for it 🙂


    12/06/2017 at 17:15

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: