Deciding When To Use Generation 1 or Generation 2 Virtual Machines with Hyper-V

I'm frequently receiving questions around when to select Generation 1 Virtual Machines versus Generation 2 Virtual Machines in a Hyper-V deployment, so I thought I'd write a post covering some of the things you should be taking into consideration.

Inside a Gen 1 VM (above)

Inside a Gen 2 VM (above)

Are you only planning on moving the VMs between Windows Server 2012 R2 based Hyper-V servers (or Windows 8.1 Professional/Enterprise)?

Gen 2 VMs work on the current releases, but not previous versions of Hyper-V, so this is an important one right from the start.

Are you planning on migration the VMs to any of Azure's IaaS services, including Virtual Machines or Site Recovery?

Gen 2 VMs aren't supportedĀ in Azure at this point, but Site Recovery accepts Gen 2 VMs and will convert them to Gen 1 when they are needed.

Do you want the highest level of portability between environments?

Again, Gen 1 VMs offer an advantage here if you have an unexpected need to run a VM in a Windows Server 2012 or earlier based Hyper-V environment.

Do you want to provision VMs as quickly as possible using PXE boot?

Gen 2 VMs have support for PXE with the native Hyper-V network adapter, so you don't need to rely on the legacy adapter support so will support higher network speeds.

Are you running any 32 bit VMs?

These will need to be Gen 1. Gen 2 VMs need to be Windows Server 2012 or later and Windows 8 or later 64 bit editions.

Do you want to best performing VMs?

These will need to be Gen 2 VMs. They boot faster, and have less emulated hardware devices loaded, which translates to better performance.

Do you want to get an understanding of how UEFI works?

Gen 2 VMs will give you this, with the UEFI disk partitions being created rather than what traditional PC BIOS would require.

Do you want better security?

Gen 2 VMs provide this due to the ability to use Secure Boot, so the ability to reduce the attack surface for rootkits and bootkits is enhanced, an technologies as ELAM (Early Launch Anti Malware) in Windows can take effect to ensure that only recognised device drivers are loaded, amongst other security measures.

Can I convert Gen 1 VMs to Gen 2 VMs?

Yes, you can use the https://code.msdn.microsoft.com/ConvertVMGeneration, but note that this is not a supported or guaranteed to work. Here are some of the details on the script.

Convert-VMGeneration converts a generation 1 virtual machine running on Hyper-V in Windows Server 2012 R2 or Windows 8.1 to generation 2. It does not change the source generation 1 virtual machine during the process - a new virtual machine is created with a new boot disk.

Convert-VMGeneration.ps1 is self-documenting. After saving to a local disk, run "get-help .\Convert-VMGeneration.ps1" from a Windows PowerShell prompt.

Due to virtual hardware differences between a generation 1 and generation 2 virtual machines, certain devices such as floppy disk drives, DVD drives using physical media, legacy network adapters and COM: ports are not migrated. Additional data or recovery image partitions on the boot disk are not migrated.

Due to the highly destructive action of wiping a disk (the new boot disk for the generation 2 virtual machine) during the conversion process, the warning check and prompt for user configuration cannot be overridden. You should make absolutely sure before confirming that the right disk is about to be wiped. While every attempt has been made to validate there is not a bug in the code, no liability is accepted should accidental data loss occur. If in doubt, to minimise risks, run this script on a machine where no essential data exists, and use an exported/backup copy of the generation 1 virtual machine as the source for the conversion.