Hello Everyone,
is there a way to migrate a lxc container to a KVM?
I would appreciate your help and tips
Greetings,
Alex
is there a way to migrate a lxc container to a KVM?
I would appreciate your help and tips
Greetings,
Alex
hi,
you can basically
1. create an archive of / from the container rootfs
2. create a kvm guest with the same linux distribution
3. extract archive to the kvm disk
4. install necessary packages and restire necessary configs (like network or similar)
be aware this still isn't any official guide or anything like that, just a possible method to achieve what you want.
you get the directory of the containers sysrootpct mount { LXC-ID }
modprobe nbd max_part=3
qemu-nbd -c /dev/nbd0 { KVM-Disk } // i.e.: vm-114-disk-1.qcow2
**** be careful: don't use /mnt - it's used by the host *** better use /mediamount /dev/nbd0p2 { mount-point }
rsync -a * { mount-point }
umount { mount point }
qemu-nbd -d /dev/nbd0
* unmount container-disk byrmmod nbd
* now start the KVM again with a Live-ISO - should be equal to the LXC-OSpct unmount { LXC-ID }
mount /dev/sda2 /mnt
mount /dev/sda1 /mnt/boot
* install bootloader grub2mount -o bind /sys /mnt/sys
mount -o bind /dev /mnt/dev
mount -t proc /proc /mnt/proc
chroot /mnt
* install a kernelyum install grub2
* configure grub2-bootloaderyum install kernel
* change the owner-id's of /bingrub2-install
grub2-mkconfig -o /boot/grub2/grub.cfg
cd /bin
chown root:root *
* reboot in the KVMexit