{"id":4547,"date":"2019-11-05T18:44:38","date_gmt":"2019-11-05T15:44:38","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4547"},"modified":"2024-03-12T23:22:32","modified_gmt":"2024-03-12T20:22:32","slug":"use-virtualbox-vms-on-kvm","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/use-virtualbox-vms-on-kvm\/","title":{"rendered":"Use VirtualBox VMs on KVM"},"content":{"rendered":"\n<p>Do you have some VirtualBox virtual machines that you would like to re-use on your KVM? Follow through this guide to learn how to use VirtualBox VMs on KVM.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using VirtualBox VMs on KVM<\/h2>\n\n\n\n<p>The first thing to note is that both VirtualBox and KVM uses different disk formats. In order to re-use each format on different virtualization platform, you simply need to convert the disks to the format supported by each virtualization solution in question.<\/p>\n\n\n\n<p>Well in that regard, in this guide, we are going to learn how to convert VirtualBox VDI disks to KVM QCOW2 disks.<\/p>\n\n\n\n<p>We also assume that you are not running VirtualBox and KVM on the same host at the same time.<\/p>\n\n\n\n<p>There are two ways in which we can convert the VirtualBox disk image into KVM qcow2.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#convert-vdi-to-img-to-qcow2\">One method is to convert VDI to raw disk image (.img) and then convert the raw disk image to QCOW2.<\/a><\/li>\n\n\n\n<li><a href=\"#convert-vdi-to-qcow2\">Another method is to directly convert VDI to QCOW2 using the qemu-img command.<\/a><\/li>\n\n\n\n<li><a href=\"#convert-ova-to-qcow2\">What if you have an OVA image? Convert OVA to QCOW2<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"convert-vdi-to-img-to-qcow2\">Convert VirtualBox VDI to Raw Disk Image<\/h3>\n\n\n\n<p>Create a directory to store KVM images. (Not necessary).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mkdir ~\/kvm-images<\/code><\/pre>\n\n\n\n<p>Next, convert a specific VirtualBox VM disk to raw image.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vboxmanage clonemedium --format RAW \/path\/to\/vm-disk-name.vdi ~\/kvm-images\/vm-disk-name.img<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%\nClone medium created in format 'RAW'. UUID: 261d0760-16bd-4cfd-a852-96861293f663<\/code><\/pre>\n\n\n\n<p>Replace the <strong>location of the VirtualBox VM<\/strong> and <strong>the name of the VM disk<\/strong> (<strong><code>\/path\/to\/vm-disk-name.vdi<\/code><\/strong>) accordingly.<\/p>\n\n\n\n<p>You should now be having a RAW virtual machine disk image, located in the <strong><code>~\/kvm-images<\/code><\/strong> for our case.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ls ~\/kvm-images<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vm-disk-name.img<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Convert RAW Disk Image to KVM QCOW2<\/h4>\n\n\n\n<p>Now, copy the raw disk image to the host running KVM and convert it to the format supported by KVM, in this case, <code>qcow2<\/code>.<\/p>\n\n\n\n<p>The conversion can be done by executing the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>qemu-img convert -f raw vm-disk-name.img -O qcow2 vm-disk-name.qcow2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"convert-vdi-to-qcow2\">Convert VDI Directly to QCOW2<\/h3>\n\n\n\n<p>You can simply do the direct conversions of VDI to QCOW2 by executing the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>qemu-img convert -f vdi -O qcow2 vm-disk-name.vdi vm-disk-name.qcow2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"convert-ova-to-qcow2\">Convert OVA to QCOW2<\/h3>\n\n\n\n<p>What if you have an OVA image exported from VirtualBox? In this case, then you also need to convert the OVA to QCOW2 image.<\/p>\n\n\n\n<p>How to convert OVA to QCOW2?<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Extract disk image from OVA;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>tar xf &lt;name&gt;.ova<\/code><\/pre>\n\n\n\n<p>You will either have VDI or VMDK depending on how the vm was created. See example files below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -1<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ubuntu22.vmdk\nubuntu22.mf\nubuntu22.ova\nubuntu22.ovf<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the above case, you need to convert VMDK image to QCOW2 format:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>qemu-img convert -f vmdk -O qcow2 ubuntu22.vmdk ubuntu22.qcow2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create New KVM Virtual Machine<\/h3>\n\n\n\n<p>You can now transfer the QCOW2 disk image to KVM host.<\/p>\n\n\n\n<p>After that, you can create a new virtual machine by importing from the existing disk image.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials<\/h3>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-rename-kvm-virtual-machine-with-virsh-command\/\" target=\"_blank\">How to Rename KVM Virtual Machine with virsh command<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-virtualbox-guest-additions-on-centos-8\/\" target=\"_blank\">Install VirtualBox Guest Additions on CentOS 8<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/autostart-virtualbox-vms-on-system-boot-on-linux\/\" target=\"_blank\">AutoStart VirtualBox VMs on System Boot on Linux<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do you have some VirtualBox virtual machines that you would like to re-use on your KVM? Follow through this guide to learn how to use<\/p>\n","protected":false},"author":1,"featured_media":11813,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,112,46,36],"tags":[4679,1178,113,1180,1177,1179,24],"class_list":["post-4547","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-kvm","category-virtualbox","category-virtualization","tag-convert-ova-to-qcow2","tag-convert-vdi-to-qcow2","tag-kvm","tag-qcow2","tag-use-virtualbox-vms-on-kvm","tag-vdi","tag-virtualbox","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4547"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=4547"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4547\/revisions"}],"predecessor-version":[{"id":21273,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4547\/revisions\/21273"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/11813"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=4547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=4547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=4547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}