LXC to LXD with LVM

Hi - I’m aware of the lxc-to-lxd script but in this instance it doesn’t work.

I have an LXC LVM backed container which I want to move into the LXD scheme which uses LVM thin-provisioning.

I’ve looked around, can’t find a way of achieving this without some error.

I see that there is the option of “import” in LXD but I’m not sure how to create the tar-ball for that.

If I mount an existing LXD container I see it has a yaml config and rootfs - but the rootfs has UIDs which I don’t recognise and so I’m concerned about just overwriting that?

Thanks,

Will.

Is your source container privileged or unprivileged?

If it’s privileged, then the way I’d recommend to deal with this is:

  • Create a new privileged LXD container using: lxc launch images:alpine/edge CONTAINER-NAME -c security.privileged=true (we’re using alpine because it’s tiny).
  • lxc stop CONTAINER-NAME
  • Look for the new LV using “lvs” and manually mount it somewhere (say /mnt).
  • Wipe the content of the “rootfs” directory.
  • Transfer the content of your existing container’s rootfs into the “rootfs” directory.
  • Unmount the container
  • Start it

If it’s an unprivileged container, then we’d need to also deal with remapping the container’s uid/gid which would add some complexity.

You may also be able to conserve your existing LV partition if you really want to, in which case you’d need to effectively cat the source LV onto the destination LV. Then mount it and move the content under “rootfs/”. If the container is privileged, that should be all there is to it. If it’s unprivileged, then uid/gid remapping may be needed too.

Thanks, I’ll check on this.