How to convert VM to container?

,

Hello,

I have three VMs created using the LXD GUI. I want to convert them to containers. I dont want to lose any data. Just change the type. Is there any easy way to do it?

Thanks in advance.

Hi. There is no easy way if doing that. I recommend creating the instance again as a container and copying the data into it.

By the way, we do not support LXD on this forum. If you are interested in the forum, please migrate to Incus. We can help if needed.

Perhaps incus-migrate could be used here?

You would need to
0. migrate to Incus,

  1. install the package incus-extra in the VM so that you have incus-migrate,
  2. setup the VM so that it has access to the Incus server on the host (i.e. be able to run incus commands in the VM and get proper output from within that said VM).
  3. Run sudo incus-migrate and follow the instructions. It would take the current filesystem in the VM and convert it into a container on your Incus setup on the host.

(haven’t tried this, though it should be simple to test before doing the actual migration).
I tried this and it worked with a test Incus VM.