How to write image to existing volume?

Some LXD images like openwrt don’t support updating themselves. Thus, their volumes need to be initialized from an image with a newer version.

Unfortunately, lxc doesn’t allow to perform that action outside of lxc launch. I mean I could just recreate the whole container instance and delete the old one but then I’d loose both the config(including all the generated MAC and IP addresses) and the volume snapshots.

So, is my approach to updating such containers just wrong or is this indeed a (crucial?) feature missing from the lxc CLI?

LXD doesn’t currently have a rebuild function (that’s what OpenStack calls it I believe), so deleting and creating again is indeed the way to go for this.

You can move most of the config into a profile to avoid having to reconfigure things.
You can also do something like:

  • lxc config show wrt > wrt.yaml
  • lxc delete wrt
  • lxc launch images:openwrt wrt < wrt.yaml
1 Like