{"id":214,"date":"2015-10-17T13:40:18","date_gmt":"2015-10-17T11:40:18","guid":{"rendered":"http:\/\/mail-e.dk\/pmsapp.org\/?p=214"},"modified":"2015-10-17T13:40:18","modified_gmt":"2015-10-17T11:40:18","slug":"creating-an-ova","status":"publish","type":"post","link":"https:\/\/mail-e.dk\/pmsapp.org\/?p=214","title":{"rendered":"Creating an OVA"},"content":{"rendered":"<p>While working on creating the next version of the pmsApp OVA, I ran into some issues so I thought I would try to make a small guide to creating an OVA here. Mostly for my own benefit.<\/p>\n<p>I installed version 0.2 of the pmsApp and updated it to get the latest software versions. When I then tried to create a new OVA it turned out to be quite a lot larget than the original. I needed to make the image smaller.<\/p>\n<p>I started out by clearing the yum cache and uninstalling the old kernel, that shrinked the used space to around the same as before the update. I found this <a href=\"https:\/\/lonesysadmin.net\/2013\/03\/26\/preparing-linux-template-vms\/\" target=\"_blank\">guide<\/a> as to how to prepare a VM to be a template, that freed up a bit more space.<\/p>\n<p>Using VirtualBox, i created an OVA from the VM. Now the problem is that an OVA created with VirtualBox can not be imported into ESXi. Fortunately an OVA is actually just a tar archive so I was able to extract the .ovf file and the vmdk&#8217;s without issues. After that it is a queston of editing the ovf and changing the hardware version from virtualbox-2.2 to vmx-Y where Y is the vmware hardware version wanted. I plan on going with vmx-8.<\/p>\n<p>Now the problem is assemling the OVA again, to do that, I used vmware&#8217;s ovftool, but it wants a .mf file to ensure that the files are not corrupted. I found <a href=\"http:\/\/www.virtuallyghetto.com\/2012\/01\/how-to-create-manifest-file-for-ovf.html\" target=\"_blank\">this<\/a> article, explaining how to create the .mf file.<\/p>\n<p>To have everything in one place, here is what I have done to the VM to make it into an OVA:<\/p>\n<p>First, we are working &#8220;inside&#8221; the VM to reduce space used.<\/p>\n<p>Stop logging:<\/p>\n<pre>service rsyslog stop\r\nservice auditd stop<\/pre>\n<p>Remove old kernels:<\/p>\n<pre>uname -a\r\nrpm -qa | grep kernel\r\n#remove old kernel versions with. yum remove<\/pre>\n<p>Clean yum cache:<\/p>\n<pre>yum clean all<\/pre>\n<p>Empty logs:<\/p>\n<pre>logrotate -f \/etc\/logrotate.conf\r\nrm \u2013f \/var\/log\/*-???????? \/var\/log\/*.gz \/var\/log\/*.old \/var\/log\/anac*\r\ncat \/dev\/null &gt; \/var\/log\/audit\/audit.log\r\ncat \/dev\/null &gt; \/var\/log\/wtmp\r\ncat \/dev\/null &gt; \/var\/log\/lastlog\r\n#there might be other logfiles to empty out with cat \/dev\/null\r\n#*I will update this next time I go through the process<\/pre>\n<p>Clean tmp space:<\/p>\n<pre>rm -rf \/tmp\/*\r\nrm -rf \/var\/tmp\/*<\/pre>\n<p>Zero out freespace to ensure disk images can be made as small as possible:<\/p>\n<pre>dd if=\/dev\/zero of=\/boot\/zerofile bs=1M\r\nsync\r\nrm -rf \/boot\/zerofile\r\n\r\ndd if=\/dev\/zero of=\/zerofile bs=1M\r\nsync\r\nrm +rf \/zerofile<\/pre>\n<p>Finally shut down the vm:<\/p>\n<pre>shutdown -h now<\/pre>\n<p>Using VirtualBox, I exported the VM as pmsApp-0.3.ova. Next are the steps taken to ensure that the OVA is as small as possible and can be imported by ESXi.<\/p>\n<p>Extract OVA:<\/p>\n<pre>mv pmsApp-0.3.ova pmsApp-0.3.tar\r\ntar xf pmsApp-0.3.tar<\/pre>\n<p>Above step can be skipped if the VM is exported as .ovf instead of .ova<\/p>\n<p>Replace the system type to ensure that the OVA can be imported by ESXi:<\/p>\n<pre>sed 's\/virtualbox-2.2\/vmx-8\/g' pmsApp-0.3.ovf &gt; pmsApp-tmp.ovf\r\nmv pmsApp-tmp.ovf pmsApp-0.3.ovf<\/pre>\n<p>Ensure that the disk image is as small as possible:<\/p>\n<pre>qemu-img convert -p -O vmdk pmsApp-0.3-disk1.vmdk thindisk.vmdk\r\nmv thindisk.vmdk pmsApp-0.3-disk1.vmdk<\/pre>\n<p>Create a manifest file to ensure data consistency in OVA:<\/p>\n<pre>openssl sha1 *.ovf *.vmdk &gt; pmsApp-0.3.mf<\/pre>\n<p>Create the OVA:<\/p>\n<pre>ovftool pmsApp-0.3.ovf pmsApp-0.3.ova<\/pre>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li><a href=\"#\" class=\"sharing-anchor sd-button share-more\"><span>Share<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><div class=\"sharing-hidden\"><div class=\"inner\" style=\"display: none;\"><ul><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-214\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/mail-e.dk\/pmsapp.org\/?p=214&amp;share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-214\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/mail-e.dk\/pmsapp.org\/?p=214&amp;share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-end\"><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>While working on creating the next version of the pmsApp OVA, I ran into some issues so I thought I would try to make a small guide to creating an OVA here. Mostly for my own benefit. I installed version &hellip; <a href=\"https:\/\/mail-e.dk\/pmsapp.org\/?p=214\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li><a href=\"#\" class=\"sharing-anchor sd-button share-more\"><span>Share<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><div class=\"sharing-hidden\"><div class=\"inner\" style=\"display: none;\"><ul><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-214\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/mail-e.dk\/pmsapp.org\/?p=214&amp;share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-214\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/mail-e.dk\/pmsapp.org\/?p=214&amp;share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-end\"><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p2gkts-3s","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=\/wp\/v2\/posts\/214"}],"collection":[{"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=214"}],"version-history":[{"count":1,"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":215,"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=\/wp\/v2\/posts\/214\/revisions\/215"}],"wp:attachment":[{"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mail-e.dk\/pmsapp.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}