Converting Your Vmware Vm to a Hyper-V VM – CloudShell - The Legend of Hanuman

Converting Your Vmware Vm to a Hyper-V VM – CloudShell


Virtualization is essential nowadays. That unused piece of hardware it’s now useful. Most of the companies today virtualize their environment with VMware, Hyper-V or other product. For one reason or another, you might need to convert a VMware VM to a Hyper-V VM once in your life. Let’s check how we can perform that.


Table of Contents

1 – Downloading and Installing the Converter Tool

The conversion process shouldn’t be painful, that’s why I created a script here that might be helpful to download and install the following tool:

conversion mvmc cloudshell
Figure 1 : MVMC 3.0

Powershell Script:

#File Location after download and the URL to download the MVMC
$out = "c:\temp\mvmc_setup.msi"
$uri = "https://download.microsoft.com/download/9/1/E/91E9F42C-3F1F-4AD9-92B7-8DD65DA3B0C2/mvmc_setup.msi"

#To Download and Run MSI package for Automated install
Function Get-MSIFile
        Start-Process "msiexec.exe" -ArgumentList $MSIArguments -passthru 

Function Install-MSI{

    param(
        [System.IO.FileInfo[]]$MsiFile
    )

    $FileExists = Test-Path $msifile -IsValid
    $DataStamp = get-date -Format yyyyMMddTHHmmss
    $logFile=" wait-process
        write-host "The MSI has been successfully installed. " -ForegroundColor Green
    
    - wait-process
        write-host "The MSI has been successfully installed. " -ForegroundColor Green
    
    .log" -f $msifile.fullname,$DataStamp

    $MSIArguments = @(
        "/i"
        ('"{0}"' -f $msifile.fullname)
        "/qn"
        "/norestart"
        "/L*v"
        $logFile
    )

    If ($FileExists -eq $True){
        Start-Process "msiexec.exe" -ArgumentList $MSIArguments -passthru | wait-process
        write-host "The MSI has been successfully installed. " -ForegroundColor Green
    
    }Else{

        Write-Host "File doesn't exists" -ForegroundColor Red
        }
    }

Get-MSIFile -uri $uri -out $out

$msifile = Get-ChildItem -Path $out -File -Filter '*.ms*' 
write-host "$msifile "

Install-MSI -msifile $msifile

You can also find these functions on my github page.

To check whether the MSI is installed or not, simply run the following command:

Get-wmiobject Win32_Product | select Name, LocalPackage | Format-Table Name, LocalPackage -AutoSize

You’ll get an output like this:

conversion mvmc installed cloudshell
Figure 2 : MVMC installed

2 – Converting the Virtual Machines

In this section, we are going to cover how to convert both Linux and Windows boxes to Hyper-V. There’s no difference between converting one or another but the problem are the drivers after the conversion, because your VMs were running on top of a VMWare and suddenly they are running on Hyper-V.

First of all, you have to open a Powershell session as admin, and then import the following module that is coming from the MSI we’ve installed in the previous section:

Import-Module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"

The Vmware files are like this:

conversion vmware files cloudshell
Figure 3: Vmware Files

Now you have to run the “ConvertTo-MvmcVirtualHardDisk” cmdlet and specify the following:

  • SourceLiteralPath – Path to the VMDK file, it usually has 1~2 kbs in size as you can see on Figure 3, don’t get confused with the -flat file, if you select that, you’ll get an error;
  • DestinationLiteralPath – The path where the VHD must be stored, you don’t need to specify the extension, only the file name;
  • VHDType – Fixed or Dynamic;
  • VhdFormat – If it is VHD or VHDX;
ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "C:\vm01\vm01.vmdk" -DestinationLiteralPath "C:\Vm01\vm01" -VhdType DynamicHardDisk -VhdFormat Vhd

After that, you’ll get a VHD file:

conversion hyper files cloudshell
Figure 4 : Hyper-V File

Let’s spin up this new VM to see if it works.


3 – Testing the Machines on Hyper-V

With the files on hands, we can attach them to our Hyper-V host and see if that works.

undefined3.1 – Testing the Windows Box
conversion new vm cloudshell
Figure 5 : New Virtual Machine

Create a Vm as you usually do, but on the VHD section, choose the “Use an existing virtual hard disk” like the Figure 6 and point to the new VHD:

conversion connect disk cloudshell
Figure 6 : Connect Virtual Hard Disk

You can also create it using Powershell:

New-VM -Name VM01 `
       -MemoryStartupBytes 6GB `
       -BootDevice VHD `
       -VHDPath "C:\temp\vm01\vm01.vhd" `
       -Path "C:\temp\vm01" `
       -Generation 2 `
       -Switch ExternalSwitch

where:

  • MemoryStartupBytes – Is the amount of memory that this vm will use at startup;
  • BootDevice – What is the device to boot the O.S;
  • VHDPath – Path to the VHD that we just created;
  • Path – Path to the vm configuration files;
  • Generation – VM generation, note that you cannot use generation 2 with vhd, you can find out more info about this here;
  • Switch – The name of the virtual switch to connect the vm to the network;

When I start the newly created vm:

conversion vm01 cloudshell

undefined3.2 – Testing the Linux Box

Create the Vm and attach the disk the same way as you’ve done on step 3.1. You’ll probably get the following error:

conversion linux error cloudshell

This issue happened because your Linux vm has the vmware drivers but not the Hyper-V ones that are necessary to recognize the disks, the network and all other components.

I’ve written a post where I fix this issue, you can check that by clicking here.

When you fix that, you’ll be able to run your vm again:

conversion linux running cloudshell

In this post you’ve learned how to convert a Vmware vm to a Hyper-V vm. If you liked it or it helped you, leave us a comment in the section below!


Share this content:

I am a passionate blogger with extensive experience in web design. As a seasoned YouTube SEO expert, I have helped numerous creators optimize their content for maximum visibility.

Leave a Comment