C²S Consulting logo
C²S Consulting | Primers | Run VirtualBox OVA on KVM

Importing VirtualBox OVA as a VM on a KVM Hypervisor

Using a KVM virtualisation platform. What if an image is received from another platform ? For example an Open Virtualisation Archive (.ova) file from Oracle VirtualBox. Well the OVA file is actually a tar archive and can be extracted to show the Virtual Machine Disk (.vmdk) file within. For KVM it is best to use the QCOW2 format.

Extract the files from the .ova file.

  $ tar -xvf vm.ova
  vm.ovf
  vm.vmdk
  

Convert from .vmdk to .qcow2 format.

  $ qemu-img convert -O qcow2 vm-disk1.vmdk vm-disk1.qcow2
  vm-disk1.qcow2   vm-disk1.vmdk   vm.ova   vm.ovf
  

Copy disk to the KVM images repository. In this case I have used /virt/kvm/images.

   $ cp vm-disk1.qcow2 /virt/kvm/images
  

If the details of the original VM are not readily available like CPU, RAM etc. they can be found in the Open Virtualisation Format (OVF) description file vm-vbox.ovf.

Install the KVM Domain with the import file

The existing disk that was created on another virtualisation platform can be imported when building the KVM domain. Build the KVM domain with the existing disk indicated in the disk path. The comma delimited options indicate the device is of the type disk and the disk device driver is virtio.

  $ virt-install \
  --connect qemu:///system \
  --virt-type=kvm \
  --name vm-OVA \
  --ram 2048 \
  --vcpus=2 \
  --disk path=/virt/kvm/images/vm-disk1.qcow2,device=disk,bus=virtio \
  --graphics vnc,listen=0.0.0.0 \
  --noautoconsole \
  --os-type linux \
  --os-variant debianwheezy \
  --network=bridge:br0 \
  --import
  
  Starting install...
  Creating domain...               |    0 B     00:01     
  Connected to domain  vm-OVA
  
  Escape character is ^]
  
  Domain creation completed. You can restart your domain by running:
    virsh --connect qemu:///system start vm-OVA 
  

Copyright © 2024 C²S Consulting