{"id":1060,"date":"2014-05-05T01:10:49","date_gmt":"2014-05-05T06:10:49","guid":{"rendered":"http:\/\/yourLinuxGuy.com\/?p=1060"},"modified":"2014-05-01T07:38:08","modified_gmt":"2014-05-01T12:38:08","slug":"converting-a-vmware-linux-guest-to-hyper-v","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=1060","title":{"rendered":"Converting a VMware Linux Guest to Hyper-V\u2026"},"content":{"rendered":"<p>If there were enough room, the full title for this article would actually be something more like, &#8220;<em>Converting a Suse SLES or Opensuse Linux machine from either VMware Workstation or ESXi or to Hyper-V, even when you don&#8217;t have the VMware environment anymore\u2026<\/em>&#8221;<\/p>\n<p>To give you a little background, Microsoft recently released the <a title=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42497\" href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42497\" target=\"_blank\">MVMC v2<\/a> (<a title=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42497\" href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42497\" target=\"_blank\">http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42497<\/a>), packed with some critical new features, including better handling of Linux VM guests.\u00a0 And it just so happens that I have a small handful of dev\/test Linux machines lying around from a VMware lab environment that I tore down a while ago that I&#8217;d love to have in my Hyper-V lab.\u00a0 The problem is that I just don&#8217;t have the VMware workstation or space on my ESXi servers to bring the VMs back up and follow the standard documented procedure.<\/p>\n<p>If you haven&#8217;t figured it out already, the basic problem here is that the Linux VMs (that came from the VMware environment) don&#8217;t have the Hyper-V drivers configured because they weren&#8217;t needed at installation (again, on VMware), but the Installation ISOs *do* have the drivers at the ready when booting the &#8220;rescue system&#8221;.<\/p>\n<p>And while the very nice documentation provided with the converter kit (Microsoft_Virtual_Machine_Converter_Admin_Guide_2_0.docx) gets you close to knowing what you need to do, it doesn&#8217;t quite provide you with step-by step instructions, especially with the guests already downed or in an archive.<\/p>\n<p>So\u2026<\/p>\n<p>Without further ado, here&#8217;s how to convert and fix those Linux VMs.\u00a0 Of course, there are a few particulars here; for instance, this procedure was tested with Opensuse versions 12.2 and 12.3, and SLES 11 sp3, but should be the same for other similar versions.\u00a0 And it should go without saying that by following these instructions, you proceed at your own risk.<\/p>\n<h3>Step 1: Install MVMC2<\/h3>\n<p>First, the installation.\u00a0 Go to the <a title=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42497\" href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42497\" target=\"_blank\">MVMC2 download site<\/a>, get the software, and install.\u00a0 I recommend doing this on a Windows 8+ or Server 2012R2 machine, for a few small niceties (like defaulting to vhdx format, etc.).<\/p>\n<h3>Step2: Convert the Disk<\/h3>\n<p>Open Powershell *as Administrator* (right-click, run as Administrator), and load the module:<\/p>\n<pre>Import-Module \"C:\\Program Files\\Microsoft Virtual Machine Converter\\MvmcCmdlet.psd1\"<\/pre>\n<p>We need to create a temporary folder for our converted disk &#8212; in my case on a separate drive from where my source VMs reside, to speed things up a tad:<\/p>\n<pre>md c:\\MvmcResults\r\ncd c:\\MvmcResults<\/pre>\n<p>And then we can convert out source disk:<\/p>\n<pre>ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath \"E:\\Virtual Machines\\Opensuse12.3\\Opensuse12.3.vmdk\"<\/pre>\n<p>Next, move the newly converted disk to wherever you keep your virtual hard disks (I assume you have a designated location).<\/p>\n<p>Then, create a Generation 1 Virtual Machine in Hyper-V (try to use the same name, memory settings, and so on as before), but choose to &#8220;Use an existing virtual hard disk&#8221; and set it to the newly converted hard disk.\u00a0 But before you start it, attach the correct installation ISO (I use the tiny &#8220;network install&#8221; ISO).\u00a0 Remember, it&#8217;s mandatory that you use the correct processor type ISO (32 vs. 64), and you should use the correct distro version.<\/p>\n<h3>Step 3: Boot and Mount the Alternate Root<\/h3>\n<p>Start the VM (booting from ISO), and choose &#8220;Rescue System&#8221; as the boot choice.\u00a0 Tip: while the splash screen is up, hit the escape key and notice the Hyper-V drivers it chose; in my case it was only hv_netvsc and hv_storvsc, but you may have others.<\/p>\n<p>Once at the &#8220;Rescue&#8221; prompt, enter &#8220;root&#8221; as the login.<\/p>\n<p>Now, mount the proper disk partition for your root filesystem; this may take some guessing if you don&#8217;t remember which is which.\u00a0 For instance, on some of my lab machines, I used \/dev\/sda2 as the full root filesystem.\u00a0 On others, I created a separate partition for \/boot, so the root file system was on \/dev\/sda3.\u00a0 If you don&#8217;t know, you might have to mount a few of them and look and see what&#8217;s in them.\u00a0 And of course, if you have a separate \/boot, you&#8217;ll have to mount that too.\u00a0 But for the examples that follow, we&#8217;ll assume the full root file system is all on \/dev\/sda2.<\/p>\n<p>So mount the root filesystem under the alternate mount point, like this example:<\/p>\n<pre># mount the root\r\nmount \/dev\/sda2 \/mnt\r\n# you may have to mount \/boot too, depending on your setup\r\n# mount \/dev\/sda1 \/mnt\/boot\r\n# you must re-mount the live dev and proc\r\nmount -\u2013rbind \/dev \/mnt\/dev\r\nmount -\u2013rbind \/proc \/mnt\/proc\r\n# set the chroot environment\r\nchroot \/mnt<\/pre>\n<p>&#8230;and then we&#8217;re ready to actually do some fixing.<\/p>\n<h3>Step 4: Fix the Modules<\/h3>\n<p>(These next instructions are re-interpreted from the MVMC2 guide, courtesy Microsoft):<\/p>\n<p>Use vi to edit \/etc\/sysconfig\/kernel to include the Hyper-V modules.\u00a0 Sorry, there&#8217;s not enough room here to teach you how to use vi\u2026\u00a0 \ud83d\ude09\u00a0 Add the &#8220;hv_&#8221; modules to the end INITRD_MODULES line, which *may* look something like this:<\/p>\n<pre>INITRD_MODULES=\"mptspi ata_piix ata_generic vmxnet3 vmw_pvscsi vmxnet\u201d<\/pre>\n<p>\u2026or perhaps like this (this example does not have VMtools drivers):<\/p>\n<pre>INITRD_MODULES=\"mptspi ata_piix ata_generic\u201d<\/pre>\n<p>\u2026and with your change, you&#8217;re making it look more like this (again, we&#8217;re only adding the hv_ modules to the end):<\/p>\n<pre>INITRD_MODULES=\"mptspi ata_piix ata_generic vmxnet3 vmw_pvscsi vmxnet hv_vmbus hv_netvsc hv_storvsc\u201d<\/pre>\n<p>And finally, recreate the initrd with something similar to the following command (this example is taken from one of my older ones). The kernel and initrd specified in the command must match your current kernel the machine boots with.<\/p>\n<pre>mkinitrd -k \/boot\/vmlinux-3.7.10-1.11-desktop.gz -i \/boot\/initrd-3.7.10-1.11-desktop<\/pre>\n<p>\u2026and you&#8217;re done!\u00a0 Type &#8220;exit&#8221; to end the chroot environment, and &#8220;init 0&#8221; to shut down.\u00a0 Go to the settings of the VM, and detach the ISO, and boot it up.<\/p>\n<p>Phew!\u00a0 You did it.\u00a0 Enjoy your Linuxy goodness\u2026<\/p>\n<p>\ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If there were enough room, the full title for this article would actually be something more like, &#8220;Converting a Suse SLES or Opensuse Linux machine from either VMware Workstation or ESXi or to Hyper-V, even when you don&#8217;t have the&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=1060\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[141,11,114,126,17],"tags":[154,142,117,143],"class_list":["post-1060","post","type-post","status-publish","format-standard","hentry","category-hyper-v","category-intermediate","category-opensuse12-2","category-opensuse12-3","category-vmwaregeneral","tag-hyper-v","tag-mvmc","tag-opensuse","tag-vmware"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-h6","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/1060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1060"}],"version-history":[{"count":1,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/1060\/revisions"}],"predecessor-version":[{"id":1061,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/1060\/revisions\/1061"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}