Migrating containers from legacy LXC 1.x to current LXD 3.x


(Dragan Espenschied) #1

I am running a legacy LXC version 1.0.7 host with a dozen containers.

My current project requires to transfer these containers to a new host running LXD 3.

Since LXD 2, transferring of containers in between hosts is super easy, and I have done it several times. But I do not know how to package the LXC 1.x containers in a way that makes them accessible for LXD 3. There seems to be no export type of command available, and the container structure looks versy different in the file system.

Any advice would be much appreciated!


(Stéphane Graber) #2

If that’s an option, you could update the source to LXC 2.0 or 3.0, then use lxc-to-lxd to import the containers.

Though I suspect in this case, a manual approach may be simpler.

What you’d do for that is create very small new containers on LXD, possibly using a small image like Alpine, then with the container running (set it privileged with security.privileged=true), rsync the content of your old container over the new one, then reboot it and make sure everything works.

So that’s effectively rsync of the container’s rootfs and then tweaking any configuration that needs tweaking, just make sure your destination container is privileged if your source one was (pretty likely), you can always try making the container unprivileged afterwards, but you don’t want to mix and match during transfer.


(Dragan Espenschied) #3

Thank you Stéphane!
Unfortunately I cannot update the host system that hosts the LXC 1.0.7 containers.
Instead I rsynced the content of /var/lib/lxc to a separate directory on my LXC 3 host. Then I have tried to convert them using sudo lxc-to-lxd --lxcpath /lxc-migration/lxc --dry-run --debug <container>. I was able to comment out stuff from the configuration that are not required anymore. But the converter doesn’t recognize overlayfs.

Couldn't find the container rootfs 'overlayfs:/...'
skipping...

All my containers are using overlayfs, and I have the data for all containers. They are all overlaid over a base ubuntu trusty container. I already tried to change the absolute paths in lxc.rootfs to point to the paths where all container data has been moved to, but lxc-to-lxd doesn’t seem to work when overlayfs is present at all.

Is there a way to “flatten” a chain over overlayfs?


(Vudududu) #4

I had same issue I created same os version lxd and moved rootfs with cp - rvp. After this lxc publish container and you are done. lxc start and it works as long as network is configured correctly