Hyper-V introduced the second-generation virtual machines with Windows Server 2012 R2. They offer several advantages over Gen 1 VMs, so you should consider converting to them. Although an automatic conversion does not exist, you can avoid a new installation of the VM.
Latest posts by Wolfgang Sommergut (see all)

There are several reasons why workloads are still being run in first-generation VMs. Often, they have been around for a few years and were created under a version of Hyper-V that only supports Gen 1 VMs. They can still be used under a newer version of the hypervisor and are fully supported.

Conversely, it is also possible that a version of Windows was originally installed in the VM that only supports VMs Gen 1. The guest OS may have been updated in the meantime, but it is trapped in the old VM.

Generation 1 is still preselected in the Hyper V Manager for new VMs

Generation 1 is still preselected in the Hyper V Manager for new VMs

Finally, of course, it can happen that Gen 1 is inadvertently selected when creating a VM, as this is still the default in Hyper-V Manager.

Advantages of Generation 2 ^

One of the most important advantages of the newer VMs is higher performance, because the guest OS "knows" that it is running on a hypervisor and therefore no hardware needs to be emulated. Gen 2 VMs support only virtual SCSI controllers, and VHDs attached to them can be hot-added, removed, and resized at run-time. Network adapters can also be added while the system is active.

If you want to set up a VM based on UEFI, you can only do this with a generation 2 VM, which means that Secure Boot is only available there. Gen 1 virtual machines, on the other hand, only support BIOS and are therefore limited to the MBR layout of the disks. This proves to be the main hurdle during migration.

Finding old VMs ^

The first step will be to get an overview to see which VMs are still Gen 1. With PowerShell, it is relatively easy to find this out:

Get-VM | select vmname, generation

This command lists all virtual machines on the local host and prints their names and generation.

Listing all VMs on the local host including name and generation

Listing all VMs on the local host including name and generation

Basically, you can now start to convert the old VMs. However, this is not possible if the guest OS is older than Windows Server 2012 R2 or is a 32-bit version.

Therefore, you have to find out which OS is installed in a VM. If it is switched on, this can be determined relatively easily via WMI:

Get-CimInstance -ComputerName <myComputer> -ClassName win32\_operatingsystem |
select Caption, OSArchitecture
Finding out the name and bit width of the guest OS via WMI

Finding out the name and bit width of the guest OS via WMI

If, on the other hand, a VM is switched off, you would have to mount the VHD containing the system partition and look inside.

Changing disk layout to GPT ^

Once you have determined which VMs are suitable for conversion, you should first update the guest OS to the version of Windows you have intended for the new environment.

Then convert the system drive to GPT. Since Windows 10 1703, Microsoft provides MBR2GPT.exe for this purpose. You access it on a live system like this:

mbr2gpt.exe /convert /allowFullOS

The tool is located in %SystemRoot%\system32 and can easily be copied to other computers if it is not available there. This applies to Windows servers, for example.

In the case of older OS versions, however, Microsoft recommends shutting down the VM, booting from a current Windows PE, and starting the conversion to GPT from there. The command then looks a little different:

mbr2gpt.exe /convert /disk:<disknumber>

The drive numbers can be displayed in diskpart with:

list disk

Transferring VHDs to new VMs ^

Since it is not possible to convert a Gen 1 VM to a Gen 2, you must now create a new Type 2 virtual machine and connect the VHDs to it.

Subscribe to 4sysops newsletter!

One side effect of this action is that it also raises the VM version up to a current level. This is necessary to take advantage of newer Hyper-V features available in Server 2016 or 2019. However, there is no way back from there either, so the VM will no longer run on an older hypervisor.