Skip to content

Instantly share code, notes, and snippets.

@hack3d
Last active June 10, 2021 21:44
Show Gist options
  • Save hack3d/8a3982329e1df77f380878ff7bbc7b03 to your computer and use it in GitHub Desktop.
Save hack3d/8a3982329e1df77f380878ff7bbc7b03 to your computer and use it in GitHub Desktop.
ARMHF LXC Container

We create an lxc container for armhf to build from a python application a debian package.

At first we install lxc

sudo apt-get install lxc debootstrap bridge-utils qemu-user-static

Configure unprivileged use of lxc containers.

sudo usermod -v 100000-200000 -w 100000-200000 $USER

grep $USER /etc/subuid

grep $USER /etc/subgid

Check your actual user and group id ranges and modify the example accordingly:

mkdir -p ~/.config/lxc

echo "lxc.id_map = u 0 100000 65536" > ~/.config/lxc/default.conf

echo "lxc.id_map = g 0 100000 65536" >> ~/.config/lxc/default.conf

echo "lxc.network.type = veth" >> ~/.config/lxc/default.conf

echo "lxc.network.link = lxcbr0" >> ~/.config/lxc/default.conf

echo "$USER veth lxcbr0 2" | sudo tee -a /etc/lxc/lxc-usernet

Now we can start creating the container. This will take a while. Grab a cup of coffee.

lxc-create -t download -n xenial-armhf01 -- --release xenial --arch armhf

To list all created containers:

lxc-ls --fancy

After successful creating a container we can start it with the following command: Before we must copy the qemu-arm-static to our rootfs

sudo cp /usr/bin/qemu-arm-static $HOME/.local/share/lxc/xenial-armhf01/rootfs/usr/bin/

lxc-start -n xenial-armhf01 -d

To stop the container the following command is needed:

lxc-stop -n xenial-armhf01

To get a console please type:

lxc-attach -n xenial-armhf01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment