Convert existing KVM to Proxmox Containers

KarlB

Renowned Member
Sep 28, 2016
8
0
66
41
I have some KVM virtual machines running outside of Proxmox. Is it possible to convert or transfer those virtual machines into Proxmox to run as a container?

Or is it simply easier to re-install as a new container?

There's a lot of information available about converting to KVM, but not much about converting back?
 
Most of the time it's easier to reinstall. I generally recommend setting systems up in a way that the data is independent from the system itself and can easily be moved or reinstalled.

But if you want to give it a shot, try mounting all the local partitions in their intended locations and tar it up to use as "template".

How you do that depends on the disk... most likely you'll want to use qemu-nbd (or losetup if you're just using raw files instead of qcow2 images), run partprobe and/or pvscan etc. on the devices to discover partitions, LVM structures etc., then mount the system to some location, and then use `tar czpf /var/lib/vz/template/cache/some-name.tar.gz -C /path/to/mountpoint .`, then use the 'some-name.tar.gz' template when creating a new container. Or you copy the data directly to an ext4 formatted raw image and create the config in /etc/pve/lxc manually (or create an empty dummy container first and update its disk - you can even mount it with `pct mount`, delete its contents and replace them with the data you mounted from the KVM, via cp or rsync or something. If the KVM is a single ext4 partition itself you might even get away with dd-ing the partition over the container's raw image.
This information is completely untested and might not work and/or break things.
(And PS: You most definitely do not want to do this while the VM is running.)
 
Thank you. In this case, the data is separate from the installation, but there is configuration of the system itself.

I have been using Ansible, so it seems like it would be easier to reinstall, automatically configure as much as possible and change a few bits by hand.
 
At least try it. I have moved VMs from Parallels on OSX to Proxmox. Convert the HDD to raw or qcow2. Create a VM in proxomx, then drop your qcow2 file in over the blank one Proxmox creates and see if it works.
 
At least try it. I have moved VMs from Parallels on OSX to Proxmox. Convert the HDD to raw or qcow2. Create a VM in proxomx, then drop your qcow2 file in over the blank one Proxmox creates and see if it works.
He was asking for a container, not a VM. Otherwise the procedure would be simple enough.
 
Sorry, I was reading the forums quickly trying to catch up from the new 4.3 release and totally missed he was looking to convert from KVM to Container.