Hyper-V Guide: Create and Configure Generation 1 and 2 Virtual Machines

Hyper-V supports two different types of virtual machine ‘models’. Think of them as the Generation 1 virtual machine with the older, legacy, computer hardware and the newer Generation 2 virtual machine with modern computer hardware. In this post I will primarily focus on the new Generation 2 virtual machines but we will touch on the more familiar Generation 1 virtual machines.

All of the Hyper-V Exam Guide and Notes are available.

Reference

The following PowerShell commands are used:

  • New-VM – Creates a new virtual machine;
  • Set-VMFirmware – Sets the firmware configuration of a Generation 2 virtual machine;
  • Convert-VHD – Converts a virtual hard disk file by copying the data to the new disk. For Generation 1 virtual machines, conversion is an offline operation and the virtual hard disk must not be attached during conversion;
  • Resize-VHD – Allows a virtual hard disk to be expanded or shrunk. Shrinking is only supported on VHDX disks only. Resizing is an offline operation and the virtual hard disk must not be attached during the resizing;
  • Set-VMComPort – Configures the COM port of a virtual machine;

Some of the references used are below:

Overview

  • Once you select a virtual machine generation it cannot officially be changed;

Generation 1 Virtual Machines

  • This is the virtual hardware ‘model’ that was the only one available in previous versions of Hyper-V;
  • Still available to use;
  • Must be used for 32 bit operating systems;
  • Must still be used for pre-Windows 8 or pre-Windows Server 2012 operating systems;
  • Used an old Intel chipset;
  • Is created by default if you don’t specify the -Generation parameter when using the PowerShell New-VM command;

Booting / Boot Order

  • Can only boot using IPv4;
  • Cannot boot from a fibre channel adapter;

Storage

  • Boot disks can be a maximum of 2TB for VHDX format and 2040GB for VHD;

Generation 2 Virtual Machines

  • Has revised hardware;
  • To create a Generation 2 virtual machine use the option in the wizard or use the -Generation parameter of PowerShell New-VM cmdlet:

  • Only 64-bit operating systems supported;
  • Does not have a DVD device added by default unless you are booting from an ISO at install;
  • Attack surface is reduced compared to Generation 1;
  • Performance may be increased as Generation 2 virtual machine consumes less resources than a Generation 1;

Firmware

  • Uses UEFI compared to BIOS in Generation 1;

Devices

  • These devices have been removed in Generation 2 virtual machines:
  • Legacy network adapter;
  • IDE controller;
  • Floppy disk controller;
  • Serial ports;
  • i8042 keyboard controller – this causes issues with Windows 8 / Server 2012 as the Generation 2 software keyboard is not present. Solution is to use an unattended install, an on-screen keyboard or use Windows 8.1 / Server 2012 R2;
  • PS/2 mouse;
  • S3 video;
  • Programmable Interrupt Controller (PIC);
  • Programmable Interrupt Timer (PIT);
  • PCI Bus;
  • Speaker;
  • Co-processor;

Booting / Boot Order

  • Change the boot order using PowerShell:

  • Can network boot using IPv6 but can only be configured using WMI or PowerShell:

  • Ensure the network adapter is high up in the network boot order;
  • Can boot from a SCSI virtual device of either a VHDX or ISO;
  • Cannot boot from a fibre channel adapter;
  • As UEFI boots very quickly you can set a boot pause via WMI by setting PauseAfterBootFailure;
  • Boot performance is more efficient as native support for VMBus is in the UEFI firmware;

Networking

  • Slow network performance is common in a Generation 2 virtual machine with the legacy network adapter and Integration Services installed. Replace the Legacy Network Adapter
  • Can support a maximum of 8 network adapters;

Storage

  • Only supports VHDX format;
  • A VHDX boot volume on a Generation 2 virtual machine can be a maximum of 64TB;
  • Can hot expand VHDX boot or data disks using Hyper-V Manager or PowerShell:

  • Allows disks to be hot added or removed, including the system disk (which could cause problems!) and the DVD device;
  • DVD does not support physical drive passthru only ISO’s;
  • SCSI devices are limited to 256 (4 adapters with 64 devices each);
  • SCSI DVD supported;

Kernel Debugging

  • Kernel Debugging requires SecureBoot to be turned off, which requires the virtual machine to be powered off:

  • Kernel Debugging requires serial ports which are not enabled and visible in a Generation 2 virtual machines. They must be enabled using PowerShell:

Secure Boot

  • Checks signatures during the boot loader to ensure only authorised components are allowed to run;
  • SecureBoot is enabled by default when creating a new VM;
  • Can be configured when the virtual machine is powered off using PowerShell:

  • Non-Windows guests are unlikely to work with Secure Boot;

RemoteFX

  • RemoteFX relies on PCI which is removed from Generation 2 virtual machines so will not work;

VHDX Disks

  • To convert from VHD to VHDX format use:

  • Converting boot disks causes the newly converted disk to be un-bootable. A clean operating system install is required for them to be bootable again;
  • Boot disks are recommended to be GPT, however MBR or GPT are supported as long as there is an EFI partition with a boot loader;

Have something to add? Let me know ...