Chapter 2
IN THIS CHAPTER
Creating a Hyper-V virtual machine
Configuring a virtual machine in Windows Server 2019 Hyper-V
Safeguarding your virtual machines with shielded virtual machines
In Chapter 1 of this minibook, I explain what virtualization is and show you how to install and configure Hyper-V. There’s no point in having a host if you aren’t going to have virtual machines (VMs). That’s the fun part, after all! VMs on Hyper-V hosts and the Hyper-V hosts themselves can be centrally managed from the Hyper-V console. This makes day-to-day administration more efficient for system administrators because they can accomplish all their tasks in one console.
VMs, also referred to as guests, are the virtual servers that run on the host server. They’re given resources by the host, and they’re able to function much like a regular physical server would. You have a lot of configuration options when it comes to your VMs, and I explain those options in this chapter.
This chapter is all about VMs. Here, you find out how to create and configure Hyper-V VMs. You discover some of the choices you need to make when creating your VMs (some of them can’t be changed later), and see why you may want to make those decisions for your VMs.
Creating a VM is the most common activity that a system administrator will undertake. There are, of course, some very important decisions that you need to make in regard to your server, like which generation of VM you want it to be. You can’t change the generation of a VM after it’s created, so it’s important that you choose the right one the first time.
Hyper-V supports multiple guest operating systems on both the Windows side and the Linux side. Supported Windows guests are Windows Vista with Service Pack 2, up to Windows 10, and Windows Small Business Server 2011 up to Windows Server 2019. Supported Linux guest VMs include Red Hat Enterprise and CentOS, Debian, Ubuntu, Oracle, SUSE, and FreeBSD.
To get started, you need to start the New Virtual Machine Wizard. Follow these steps:
On the Specify Name and Location screen, name your virtual machine.
I’ll name mine VM1 (creative, I know).
Select the Store the Virtual Machine in a Different Location check box if you want the VM’s storage to be somewhere other than the default location.
I will leave that unchecked.
On the Specify Generation screen, select Generation 2 and click Next.
Hyper-V supports Generation 1 and Generation 2 VMs. In most cases, you want Generation 2 VMs because they provide support for more advanced features. Generation 2 provides Unified Extensible Firmware Interface (UEFI) support, which is required if you need to use Secure Boot. Generation 1 is useful if you need to install a 32-bit operating system or if you need to support legacy hardware.
On the Assign Memory screen, specify startup memory for the VM and, if you want, select the Use Dynamic Memory for This Virtual Machine check box.
For Windows Server 2019, I set the startup memory to 4096MB, and I do select the Use Dynamic Memory for This Virtual Machine check box.
Startup memory is just that: memory used by the system at startup. This should not be confused with minimum random access memory (RAM), which you can set later on. Dynamic memory allows the host to control memory for the VM. As far as the VM knows, it has 4096MB of RAM, but when it’s sitting idle, the host may let something else use the RAM if needed.
On the Configure Networking screen, choose the virtual switch that you want to connect to.
In Figure 2-2, you can see that I’ve chosen the virtual switch that was created when I installed the Hyper-V role.
On the Connect Virtual Hard Disk screen, you can choose to create a hard disk, attach to an existing hard disk, or choose to attach a hard disk later.
I’ll create a hard disk, but I’ll change the default 127GB size to 40GB, as shown in Figure 2-3.
On the Installation Options screen, you can choose to install an operating system (OS) later, install from an ISO file, or install the OS from a network installation server like WDS.
For now, I’ll leave Install an Operating System Later selected.
On the Completing the New Virtual Machine Wizard screen, if everything looks correct, click Finish.
Assuming there were no issues encountered during creation, you’ll find yourself on a screen similar to Figure 2-4 with your newly create VM powered off and ready to be worked with.
When you create the VM, you have a limited set of initial configuration options. In most cases, you’re going to want to customize the VM further. Similar to changing settings on a Hyper-V host, you can get into the configuration menu for a VM by right-clicking the VM and choosing Settings.
The Add Hardware section allows you to additional Small Computer System Interface (SCSI) controllers, network adapters, or Fibre Channel adapters. Simply select the device that you want, and click Add. The new device shows up in the menu on the left.
The Firmware section allows you to set the boot order of the attached devices and allows you to entry in the boot file for each device. You can change the boot order if desired by selecting the device you want to move, and then by using the Move Up or Move Down buttons on the right side, shown in Figure 2-5.
The Security section contains check boxes that allow you to provide further security to your VMs. Specifically, you can enable the following:
The Memory section allows you to finetune how your VM will be assigned its memory. When you created the VM, you were only asked how much startup RAM you wanted to assign the machine. The value that you specified there becomes the amount that the host will present to the VM.
If you enable dynamic memory, you can set the minimum and maximum amount of RAM that you want the host to be able to assign. If the VM absolutely needs 512MB to run, you’ll want to ensure that the Minimum RAM is set to 512MB. You can set the maximum RAM if you need to make sure that the VM is not allowed to go over a certain amount of RAM.
The memory buffer is used to tell Hyper-V how much memory it should set aside for a VM, when you’re using dynamic memory. Think of it as the Hyper-V equivalent of a rainy-day fund. When the VM needs more memory, the buffer is used in between the time that the VM makes it known that it needs the RAM and when the RAM is actually granted. So the VM gets the memory it needs, even though it hasn’t technically been allotted yet. By default, this value is set to 20%.
The last setting on this screen is Memory Weight. This is where you can tell the host how important this VM is. If, for example, a mission-critical application is running on it, and you need to make sure that it’s never starved for resources, you would set the Memory Weight to High. By default, this setting is on Medium, which you can see in Figure 2-6.
The Processor section allows you to set the number of virtual processors that are assigned to the VM. If you click the plus (+) sign next to Processor, you get additional screens for Compatibility and NUMA. If you check the check box on the Compatibility screen, the processor features presented to the VM will be limited, but this will allow you to move to a system with a different processor version. The NUMA configuration screen allows you to set things specifically for NUMA node use. This can improve performance on VMs that have more than one processor assigned to them, if they’re sharing CPU resources made available by a NUMA node.
The SCSI Controller section allows you to add additional hard drives, DVD drives, or shared drives. When you select the device that you want to add, all you need to do is click the Add button and the new device will appear in the menu. With each device, you’re taken to a page that will allow you to configure the new device that you’ve added.
If you click the plus (+) sign next to SCSI Controller, you see all the SCSI-based devices that are currently connected to your VM. If you select one of the devices (the hard drive, for instance), you can see its location, you’re presented with a few options to work with the virtual hard disk file, and you’re also presented with the option to remove the hard disk file completely (as shown in Figure 2-7).
Below your hard drive in SCSI Controller, you see an option for Quality of Service. If the VM is hosting an application that has specific Input/Output Operations Per Second (IOPS) needs, you can specify minimum and maximum IOPS on this screen. The vendor will usually specify minimum IOPS if its application is really dependent on low-latency storage. The storage you’re using must be capable of meeting the IOPS requirements; making the setting change here only tells Hyper-V to potentially give greater importance to storage traffic for this drive.
The network adapter section allows you to do several things. You can change the virtual switch that the network adapter is attached to, you can enable vLAN identification to support vLAN tagging, and you can enable and configure bandwidth management. If you click the plus sign (+) next to Network Adapter, you have two options:
NIC Teaming: Allows you to create a NIC team for the VM. The operating system of your VM needs to support NIC teaming for this to work.
NIC teaming allows you to logically join multiple network adapters, so that they behave as if they were one big network adapter. NIC teaming offers some fault tolerance, assuming the connections in the team are going to separate infrastructure switches. NIC teaming can also be used to load-balance traffic coming to the server.
The Name section allows you to change the name of the VM and add any notes that you want to have visible when someone clicks on the VM within Hyper-V Manager.
The Integration Services section allows you to expose services on the host Hyper-V server to the VM you’re configuring. This includes things like operating system shutdown, time synchronization, data exchange, heartbeat, backup, and guest services.
Checkpoints are a point-in-time backup of your VM. They’re very useful before a change is made within the operating system that could potentially be destructive. They should not be used in place of backups.
By default, checkpoints are enabled and will be created as production checkpoints. You have the choice between production and standard checkpoints.
You can set your VMs to create automatic checkpoints, and you can also set the save location for all your checkpoints.
This screen allows you to set the location for the smart paging file for the VM. Smart paging is only used at boot time and can be used to ensure that a VM will be able to boot, even if the host can’t provide the minimum startup RAM that the VM requires.
The Automatic Start Action section allows you to set what you want the VM to do when the host is started. You have a choice between doing nothing, automatically starting if it was running when the service stopped, and always starting this VM automatically.
The Automatic Stop Action section determines what the VM will do if the Hyper-V host is shut down. The options are to save the VM state, turn off the VM, or shut down the guest operating system.
In the “Configuring your Virtual Machine” section, earlier in this chapter, I show you the check box that allows you to turn a VM into a shielded VM. Shielded VMs require more than that simple check box to function properly. You must set up the appropriate server infrastructure to support shielded VMs.
In Windows Server 2016, the Host Guardian Service was introduced. The Host Guardian Service protects shielded VMs by ensuring that the host they’re on is a trusted Hyper-V host (guarded host). Essentially, a shielded VM may only run on a Hyper-V host that is able to pass its health attestation to the system or systems running the Host Guardian Service. There are two types of attestation that a guarded host can use:
For VMs to support being shielded VMs, they must be Generation 2 VMs and have a virtual TPM. Shielded VMs are encrypted by BitLocker.