Linux,  Server

Creating a LXC Ubuntu container in OpenWRT on a Turris Omnia

If you have OpenWrt running on your router, you have the possibility to run Linux Containers on it using lxc. I will show you how to install Ubuntu on the Turris Omnia router.

Preparing the disk

To be able to run virtual systems on your Router you will first need to provide more space. This can be done by attaching an external harddisk using the USB ports or on a NAS for most routers. But for the Omnia, there is a other better way. You can insert a mSATA drive inside of it. The router has 3 PCIe slots. Only the one in the center of the board is able to read mSATA drives, so you will have to move the wireless cards to be able to insert the drive.

After installing the SATA you first have to make sure everything is still working, if your wifi fails, first look at the web gui if the settings are still correct.

Most of the time I will be using bash for configuring the router, Most of the configuring outside of the container can also be done by the web gui.


if the SATA is installed, ssh into your router and get root access. now we can begin partitioning using fdisk.

# fdisk /dev/sda

(enter) #if you don’t want to use the whole disk, you can specify the size here, fore instance +30G

# mkswap /dev/sda1
# swapon /dev/sda1
# mkfs.ext4 /dev/sda2
# mount /dev/sda2 /srv/lxc

At this point we have everything we need to install the container, but lets set these mountpoints for automated mounting at boot first. OpenWRT does not use /etc/fstab, instead it a fstab in /etc/config/fstab. mine looks like this:

# vim /etc/vonfig/fstab
config global
    option anon_swap '0'
    option anon_mount '0'
    option auto_swap '1'
    option auto_mount '1'
    option delay_root '5'
    option check_fs '0'
config swap
    option enabled '1'
    option device '/dev/sda1'
config mount
    option device '/dev/sda2'
    option enabled '1'
    option target '/srv/lxc'

Installing the lxc container

Now it’s time to install the container. This can be done with the command lxc-create or using the web gui. there are a lot of containers available, but they are not all from very good quality. I probably will make a new post about a Gentoo container, but for now I will stick with a Ubuntu Xenian container.

# lxc-create -t download -n [containerName]


If you by accident created a container before mounting your disk, your router will run out of memory. It will recover its memory automatically but there could be some side-effects, for instance your internet-connection could fail or get really slow. Just reboot the router and everything should work again.

Using your fresh lxc container

If everything went well, you should now have a fresh Ubuntu container installed. Here are the commands to start, stop and enter the container:

# lxc-start -n Ubuntu
# lxc-stop -n Ubuntu
# lxc-attach -n Ubuntu

After attaching the container you will be logged in to it as root. Now you can configure it like a normal Ubuntu installation. If you want to be able to enter it using ssh, do not forget to change the root password or make a new normal user with sudu rights.



Leave a Reply

Your email address will not be published. Required fields are marked *