Migrate from VirtualBox to kvm on SmartOS

Moving Windows Server virtual machines from VirtualBox to kvm seems to have been relatively straightforward. Compatible interfaces helps. Moving the data is a simple matter of converting disk images from VirtualBox to raw and then writing the raw files to a ZVOL.

  1. For best results, make sure your VirtualBox guest is using ide interfaces for storage and Intel e1000g interfaces for networking.
  2. On the source host, clone the VirtualBox disk image to a raw format:
    VBoxManage clonehd <source>.vmdk <destination>.img --format raw
  3. Copy it from the source host to the destination host, as with rsync.
  4. On the destination host, prepare the vm. The image doesn't really matter. But in the .json file, use ide for the hard disk interface and e1000g for the networking interface, instead of virtio.
  5. Stop the vm.
  6. Make sure your new vm's -disk0 zvol is the right size for the image you want to write. If not, use zfs set to fix it.
  7. Use qemu-img to write your .img file to the zvol:
qemu-img convert \  
-f raw \
-O host_device \
-o size=<gigabytes>G \
<source>.img \  
/dev/zvol/rdsk/zones/<uuid>-disk0

When that's finished, you should be able to fire up the new vm and pick right up where you left off.

See also: