Migrating just a couple of virtual machines from other virtualization platforms to KVM is easy. Virtualbox uses the Virtual Disk Image (.vdi
) format. You can clone the vdi
image to a RAW image format using vboxmanage
. This way you will not alter your original virtual image file. Then QEMU provides the necessary tools to convert the RAW image to the qcow2
format. Qcow2 is QEMU’s Copy On Write image format.
Clone the virtual HDD into a RAW image
Determine where is the disk image if the Virtualbox vm and change directory to there. You can use the Virtualbox GUI or in command line the vboxmanage list hdds
command. More documentation about it.
Clone the original vm disk into a RAW image:
vboxmanage clonehd --format RAW pwnbox.vdi pwnbox.img
The clonehd
used here for compatibility reasons with the earlier Virtualbox versions. In newer versions you can use the clonemedium
option. Here is the documentation of the command.
Convert the image to qcow2
Now convert the RAW disk of the machine to qcow2
format:
qemu-img convert -f raw pwnbox.img -O qcow2 pwnbox.qcow2
The QEMU image utility documentation is here.
Move the image into the default KVM image pool, or any other active image pool:
mv pwnbox.qcow2 /var/lib/libvirt/images/
Add the machine to KVM with virt-manager
(or set it up with virsh
), configure and boot it up.
Set up the VM for KVM
Install the QEMU guest agent package in the imported guest vm:
sudo apt install qemu-guest-agent
If you want to share the clipboard of the guest with the host, install the following package:
sudo apt install spice-vdagent
Reboot the VM! It is usable in KVM now.
If you want to discuss the topic with other technology-minded people, join my Discord: https://discord.gg/YbSYGsQYES
Now we have an IRC channel as well: irc.libera.chat / #tomsitcafe