OpenWrt ARM64 QUICK LXC HOWTO/GUIDE (LMS in Debian System in LXC Container)

Usage note:

Running unprivileged LXC containers under OpenWRT 21.02.1 and later; apart from the usual requirements for unprivileged containers (which I won't duplicate here unless someone asks), an issue occurs in at least some images, including OpenWRT and Alpine Linux, that the container will fail to start, reporting a permissions error mounting /proc in the container.

When started in the foreground error will contain the following text:

lxc: Operation not permitted - Failed to mount "proc"

or

Operation not permitted - Failed to mount "proc" onto "/usr/lib/lxc/rootfs/proc"

The solution is to remount both /proc and /sys, (which will also produce the error) in the host, changing the noatime option to relatime. The initial /proc and /sys mount options in the host are not modifiable without building from source, so I found it simplest to do all the work in /etc/rc.local, including starting the containers I want auto-started. (To do the latter as part of the init.d process would cause these things to occur in the wrong order.)

# Change noatime to relatime for /proc and /sys
mount -o remount,rw,nosuid,nodev,noexec,relatime proc /proc
mount -o remount,rw,nodev,noexec,relatime sysfs /sys
...
lxc-start -n your-container-name-here
...

Posted here so it'll come up in a forum search in a related context.
Edited Feb 2024: updated, this problem still exists in 23.05, added the current error message to help this come up in a search.

3 Likes