Table of Contents

Convert LXC Container to KVM VM

To Convert LXC to a Proxmox VM

This is the process:

To Convert LXC to a Libvirt/Virsh Container

The is the process:

sudo modprobe nbd max_part=8
sudo qemu-nbd --connect=/dev/nbd0 file.qcow2
sudo mount /dev/nbd0p1 /mnt/kvm
* mount the image with qemu-nbd
* Copy the LXC Files to the KVM image via rsync: rsync -av --numeric-ids <source> <destination>
* mount --bind /dev, /proc, and /sys on the image and chroot to it
* Copy the /etc/fstab from an existing KVM machine to the new disk
* install the kernel and grub-pc to /dev/nbd0
* edit grub.cfg to point nbd0p2 to /dev/vda2
* Boot the new VM