~drscream
Migrate from libvirt to SmartOS
We currently migrate our infrastructure from Linux libvirt based KVM to SmartOS. Most of the services could be moved to zones but some should also run on Linux. So we like to migrate the existing qcow2- or raw-image to SmartOS.
This could be done really simple.
- Convert the existing linux image to
raw
if it is aqcow
image. - Sync the
raw
image to an temporary folder, for example/opt/tmp
. - Create a KVM virtual machine via
vmadm create
on your SmartOS host system. JSON example - Get the
disk0
from the KVM image on the SmartOS host. dd
theraw
image to thedisk0
.- Start the new linux image on SmartOS.
Now from the theory to the required commands :-)
[linux-kvm]# qemu-img convert -O raw linux-vm.qcow2 linux-vm.raw
[linux-kvm]# scp linux-vm.raw smartos-host:/opt/tmp
[smartos-host]# vmadm create -f linux-vm.json
Successfully created VM fee9be01-6d2e-4e43-a958-57ad4668d5b7
[smartos-host]# vmadm info fee9be01-6d2e-4e43-a958-57ad4668d5b7 block
{
"block": [
{
[...]
"file": "/dev/zvol/rdsk/zones/fee9be01-6d2e-4e43-a958-57ad4668d5b7-disk0"
},
"type": "hd"
},
[...]
[smartos-host]# vmadm stop fee9be01-6d2e-4e43-a958-57ad4668d5b7
[smartos-host]# dd if=linux-vm.raw of=/dev/zvol/rdsk/zones/fee9be01-6d2e-4e43-a958-57ad4668d5b7-disk0 bs=1M
Hints:
- Be sure to turn off the linux-vm before convert to
raw
- Stop the virtual machine before
dd
the data todisk0
- Create the new
disk0
with the exact size of theraw
image
Send your comment by mail.
Thu 23/03/17, 4:20 pm
Hi, great little howto. Just want to mention, that getting info of a vm with vmadm does not work for a stopped vm - at least on my machine. Best, Jonas
/
Mon 27/03/17, 3:57 pm
Thanks you for the info, I will update the blog post I maybe missed that point!
/