Should I create a generation 1 or 2 virtual machine in Hyper-V?

In diesem Artikel

Your choice to create a generation 1 or generation 2 virtual machine depends on which guest operating system you want to install and the boot method you want to use to deploy the virtual machine. We recommend that you create a generation 2 virtual machine to take advantage of features like Secure Boot unless one of the following statements is true:

You can't change a virtual machine's generation after you've created it. So, we recommend that you review the considerations here, as well as choose the operating system, boot method, and features you want to use before you choose a generation.

Which guest operating systems are supported?

Generation 1 virtual machines support most guest operating systems. Generation 2 virtual machines support most 64-bit versions of Windows and more current versions of Linux and FreeBSD operating systems. Use the following sections to see which generation of virtual machine supports the guest operating system you want to install.

What are the advantages of using generation 2 virtual machines?

Here are some of the advantages you get when you use a generation 2 virtual machine:

Secure Boot
This is a feature that verifies the boot loader is signed by a trusted authority in the UEFI database to help prevent unauthorized firmware, operating systems, or UEFI drivers from running at boot time. Secure Boot is enabled by default for generation 2 virtual machines. If you need to run a guest operating system that's not supported by Secure Boot, you can disable it after the virtual machine's created. For more information, see Secure Boot.

Larger boot volume
The maximum boot volume for generation 2 virtual machines is 64 TB. This is the maximum disk size supported by a .VHDX. For generation 1 virtual machines, the maximum boot volume is 2TB for a .VHDX and 2040GB for a .VHD. For more information, see Hyper-V Virtual Hard Disk Format Overview.

You may also see a slight improvement in virtual machine boot and installation times with generation 2 virtual machines.

What's the difference in device support?

The following table compares the devices available between generation 1 and generation 2 virtual machines.

Generation 1 Device

Generation 2 Replacement

Generation 2 Enhancements

IDE controller

Virtual SCSI controller

Boot from .vhdx (64 TB maximum size, and online resize capability)

IDE CD-ROM

Virtual SCSI CD-ROM

Support for up to 64 SCSI DVD devices per SCSI controller.

Legacy BIOS

UEFI firmware

Secure Boot

Legacy network adapter

Synthetic network adapter

Network boot with IPv4 and IPv6

Floppy controller and DMA controller

No floppy controller support

N/A

Universal asynchronous receiver/transmitter (UART) for COM ports

Optional UART for debugging

Faster and more reliable

i8042 keyboard controller

Software-based input

Uses fewer resources because there is no emulation. Also reduces the attack surface from the guest operating system.

PS/2 keyboard

Software-based keyboard

Uses fewer resources because there is no emulation. Also reduces the attack surface from the guest operating system.

PS/2 mouse

Software-based mouse

Uses fewer resources because there is no emulation. Also reduces the attack surface from the guest operating system.

S3 video

Software-based video

Uses fewer resources because there is no emulation. Also reduces the attack surface from the guest operating system.

PCI bus

No longer required

N/A

Programmable interrupt controller (PIC)

No longer required

N/A

Programmable interval timer (PIT)

No longer required

N/A

Super I/O device

No longer required

N/A

More about generation 2 virtual machines

Here are some additional tips about using generation 2 virtual machines.

Attach or add a DVD drive

You can't attach a physical CD or DVD drive to a generation 2 virtual machine. The virtual DVD drive in generation 2 virtual machines only supports ISO image files. To create an ISO image file of a Windows environment, you can use the Oscdimg command line tool. For more information, see Oscdimg Command-Line Options.

When you create a new virtual machine with the New-VM Windows PowerShell cmdlet, the generation 2 virtual machine doesn't have a DVD drive. You can add a DVD drive while the virtual machine is running.

Use UEFI firmware

Secure Boot or UEFI firmware isn't required on the physical Hyper-V host. Hyper-V provides virtual firmware to virtual machines that is independent of what's on the Hyper-V host.

We don't support running a UEFI shell or other UEFI applications in a generation 2 virtual machine. Using a non-Microsoft UEFI shell or UEFI applications is technically possible if they are compiled directly from the sources. If these applications are not appropriately digitally signed, you must disable Secure Boot for the virtual machine.

Work with VHDX files

You can resize a VHDX file that contains the boot volume for a generation 2 virtual machine while the virtual machine is running.

We don't support or recommend that you create a VHDX file that is bootable to both generation 1 and generation 2 virtual machines.

The virtual machine generation is a property of the virtual machine, not a property of the virtual hard disk. So you can't tell if a VHDX file was created by a generation 1 or a generation 2 virtual machine.

A VHDX file created with a generation 2 virtual machine can be attached to the IDE controller or the SCSI controller of a generation 1 virtual machine. However, if this is a bootable VHDX file, the generation 1 virtual machine won't boot.

Use IPv6 instead of IPv4

By default, generation 2 virtual machines use IPv4. To use IPv6 instead, run the Set-VMFirmware Windows PowerShell cmdlet. For example, the following command sets the preferred protocol to IPv6 for a virtual machine named TestVM:

Set-VMFirmware -VMName TestVM -IPProtocolPreference IPv6

Add a COM port for kernel debugging

COM ports aren't available in generation 2 virtual machines until you add them. You can do this with Windows PowerShell or Windows Management Instrumentation (WMI). These steps show you how to do it with Windows PowerShell.

To add a COM port:

Disable Secure Boot. Kernel debugging isn't compatible with Secure Boot. Make sure the virtual machine is in an Off state, then use the Set-VMFirmware cmdlet. For example, the following command disables Secure Boot on virtual machine TestVM:

Set-VMFirmware -Vmname TestVM -EnableSecureBoot Off

Add a COM port. Use the Set-VMComPort cmdlet to do this. For example, the following command configures the first COM port on virtual machine, TestVM, to connect to the named pipe, TestPipe, on the local computer:

Set-VMComPort -VMName TestVM 1 \\.\pipe\TestPipe

Note

Configured COM ports aren't listed in the settings of a virtual machine in Hyper-V Manager.