{"id":814,"date":"2021-11-13T18:10:16","date_gmt":"2021-11-13T12:10:16","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=814"},"modified":"2021-11-13T18:10:16","modified_gmt":"2021-11-13T12:10:16","slug":"how-to-add-raw-image-into-an-existing-openvz-7-vm","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-add-raw-image-into-an-existing-openvz-7-vm.html","title":{"rendered":"How to Add RAW Image into An Existing OpenVZ 7 VM"},"content":{"rendered":"\n<p>OpenVZ 7 supports both KVM VM and OpenVZ containers. For a customer, we were trying to import a CentOS 7 based KVM VM to OpenVZ 7 KVM VM. But the problem is, the VM was created in RAW format. But OpenVZ 7 KVM does not support RAW files for KVM, it supports QCOW2. Hence, we had to first convert the RAW image into a QCOW2 image first. <\/p>\n\n\n\n<p><strong>How to convert RAW KVM VM Image to QCOW2 VM Image<\/strong><\/p>\n\n\n\n<p>To convert raw to qcow2, you may use qemu-img kvm tool. This tool comes with the KVM setup. Let&#8217;s say your raw image is &#8216;harddisk.hdd.raw&#8217;, and you would like to produce a qcow2 image, called &#8216;harddisk.hdd&#8217;. To do that, you may run the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">qemu-img convert -f raw -O qcow2 \/root\/harddisk.hdd.raw \/root\/harddisk.hdd.qcow2<\/pre>\n\n\n\n<p>Make sure, you are running this script from the place where you have the harddisk.hdd.raw stored. <\/p>\n\n\n\n<p><strong>Replace the disk in OpenVZ 7<\/strong><\/p>\n\n\n\n<p>In our case, our files are stored under \/vz\/vmprivate\/. Under this folder of OpenVZ, you would find folders with VM id. In our case, it was under the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/vz\/vmprivate\/9d07cfef-42bf-4fbe-ac6a-7af9c85c9475<\/pre>\n\n\n\n<p>You can also see the list of VMs UUID, by typing the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">prlctl list --all<\/pre>\n\n\n\n<p>First, stop the VM<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">prlctl stop 9d07cfef-42bf-4fbe-ac6a-7af9c85c9475<\/pre>\n\n\n\n<p>Now, all you need to do, is to replace the &#8216;harddisk.hdd&#8217; with the one we had converted<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/vz\/vmprivate\/9d07cfef-42bf-4fbe-ac6a-7af9c85c9475\nmv harddisk.hdd harddisk.hdd_backup\nmv \/root\/harddisk.hdd.qcow2 harddisk.hdd<\/pre>\n\n\n\n<p>Now, start the VM, and you should be good to go<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">prlctl start 9d07cfef-42bf-4fbe-ac6a-7af9c85c9475<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>OpenVZ 7 supports both KVM VM and OpenVZ containers. For a customer, we were trying to import a CentOS 7 based KVM VM to OpenVZ 7 KVM VM. But the problem is, the VM was created in RAW format. But OpenVZ 7 KVM does not support RAW files for KVM, it supports QCOW2. Hence, we &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-add-raw-image-into-an-existing-openvz-7-vm.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Add RAW Image into An Existing OpenVZ 7 VM&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[606],"tags":[608,159,607,609],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/814"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=814"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/814\/revisions"}],"predecessor-version":[{"id":815,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/814\/revisions\/815"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}