Migrate a KVM virtual machine to OmniOS bhyve
314 words, 2 minutes
Because I am replacing my Linux KVM machine with an OmniOS bhyve server, and I don’t want to reinstall all my VMs, I went for migrating those. And because I am not aware of vMotion-like feature between those two platforms, I just used the shell.
First, connect to the KVM server, locate the virtual machine that will be migrated and stop it.
# virsh list
Id Name State
---------------------------
2 obsd1 running
53 obsd2 running
77 multiboot running
# virsh domstate obsd2
running
# virsh shutdown obsd2
Domain 'obsd2' is being shutdown
# virsh domstate obsd2
shut off
Then, locate the virtual disk and convert it to RAW format using
qemu-img.
# virsh domblklist obsd2
Target Source
-----------------------------------------
vda /volume1/libvirt/obsd2.qcow2
sdb -
# qemu-img convert -f qcow2 -O raw \
/volume1/libvirt/obsd2.qcow2 obsd2.raw
Transfer the RAW image to OmniOS, create the bhyve VM and copy the RAW image to the VM’s zvol. Remember to create a disk that is at least as big as the original one.
# scp -p kvm-server:obsd2.raw .
# zadm create -b bhyve obsd2
(...)
"bootdisk" : {
"blocksize" : "8k",
"path" : "rpool/zones/obsd2/root",
"size" : "64G",
"sparse" : "false"
},
(...)
# dd if=obsd2.raw of=/dev/zvol/rdsk/rpool/zones/obsd2/root \
bs=10M status=progress
6553+1 records in
6553+1 records out
68719476736 bytes (64 GiB) transferred in 59.675809 secs (1.1 GiB/sec)
Finally, start the VM and check everything is all right!
# zadm start obsd2
# zadm console obsd2
If your VM is running OpenBSD, you may have to tell the system to switch
to com0. At boot, type set tty com0 in the boot loader prompt. Then
update configuration files to allow serial console at next boot.
# vi /etc/boot.conf
(...)
stty com0 115200
set tty com0
(...)
# vi /etc/ttys
(...)
tty00 "/usr/libexec/getty std.115200" vt220 on secure
(...)
# reboot
If you’re lucky enough, your VM is now migrated onto your bhyve server. Happy migrations!