Upgrading OpenWrt container to latest release

Hi all,
I was wondering, what is the recommended way to upgrade a container running OpenWrt to the latest release on x86 (LXC in my case, but this issue may apply more or less to any containerization technologies)?

I'm also writing this down in the Wiki, where I described the steps to do a migration via images provided by the containerization platform's image registry/mirror.
But I'm wondering if there are some other methods, possibly faster and cleaner involving the use of official OpenWrt images, which could be carried out e.g. in LuCI by uploading a sysupgrade-compatible image as usually done on embedded devices.

I'm not sure the ext4 images are the right choice in the containerized case, nor squashfs. I was more thinking of using the plain rootfs archive (generic-rootfs.tar.gz) but, when i upload it, LuCI warns about missing metadata with a discouraging error dialog, and a checkbox to force the flashing anyway.
Another option could be extracting the rootfs archive over the "old" container rootfs, then fixing file owner/modes and restoring OpenWrt settings, but seems somewhat error-prone and also not faster or cleaner than the procedure already documented.

Any thoughts or experiences in this regard?


That does not work, openwrt sysupgrade expects a full firmware image. The container does not know it is a container. It thinks it is a normal install.

For that to work, OpenWrt should have a new subtarget in x86 for containers, where the system knows this is a container and the sysupgrade procedure is customized to use this archive for sysupgrade.

Afaik there was a script created by @aparcar about creating a docker container automatically from a rootfs, maybe it (or he) can help you Yes I know LXC is not the same as docker, but it's still a container so maybe you can adapt it? https://github.com/openwrt/openwrt/pull/2367/commits/7f4031e3d35a7bd04f7a41765e63937b86fa05f7

also there is a guy that made some project to run openwrt as lxd container

Maybe create a container using the new rootfs and restore your backup from the old one.

The package names to remove/install and the script restoring them can be part of the backup:


Ah ok, thanks for these details. I though sysupgrade could handle plain rootfs archives in some way... good to know.

As I said, creating an OpenWrt container from scratch (and without having to bother about building it around the upstream rootfs) is already a breeze since lxc does provide images for OpenWrt from its mirror...
My doubt was if the upgrade could be done inside the running container instance via sysupgrade without the need to create additional containers, manage them and manually saving/restoring settings.

So yes, I think the approach of creating a new container based on the latest image and restoring settings is the only viable solution at this point (which is basically what i suggested in the wiki too).

Thanks. This also looks good to automate this other task.

1 Like