March 1, 2017
Creating and Configuring VMs in Windows Server 2016 Hyper-VIn the previous post, we looked at the initial configuration of our Windows Server 2016 Hyper-V server. This included installation, administration, storage and network configuration and remote management. The whole point of configuring our Windows Server 2016 Hyper-V hypervisor host is to run VMs. Let’s look at creating and configuring VMs in Windows Server 2016 Hyper-V.
Creating and Configuring VMsThe first thing we need to do is use the Hyper-V manager to connect to our Hyper-V host. The Hyper-V manager is included in the Remote Server Administration Tools (separate download) for client operating systems such as Windows 10, or included in the Server Manager install features section of a server operating system such as Windows Server 2016.
We begin by right-clicking our Hyper-V host and selecting New >> VM.
This begins the New VM Wizard.
We begin the configuration by selecting a name for our VM.
Generation of the VM
Next, we select the Generation of the VM. We have two choices here – Generation 1, and Generation 2. What are the differences? To start with, Generation 2 VMs are only compatible with Hyper-V 2012 R2 and higher. Also, Windows Server 2012/Windows 8 64-bit and above are supported with Generation 2, so no 32-bit versions of those operating systems will work. In fact, if you create a Generation 2 VM and try to boot from an ISO of a 32 bit OS, it will simply give you an error that no boot media can be found. Microsoft has also been working on support of Generation 2 VMs with Linux. Be sure to check with your particular distribution as not all are supported with Generation 2.
Other considerations to mention – for those thinking of moving a previously created Hyper-V VM to Azure, Generation 2 is not supported. For greater compatibility including moving to Azure, Generation 1 VMs should be selected. If none of the limitations mentioned are true, and you want to utilize such features as UEFI secure boot, then Generation 2 would be the preferred choice.
A note here also about choosing the VM Generation – this cannot be changed afterwards, so make sure you choose the right Generation level before proceeding.
Memory Management in Hyper-V
The next configuration section is where we can Assign Memory. The memory management in Hyper-V can utilize what is called dynamic memory. Hence, on this screen, you see the Use Dynamic Memory for this VM checkbox that can be selected. Hyper-V dynamic memory management when selected cooperates with the VM guest operating system in managing guest operating system memory.
Using its hot-add feature, Hyper-V grows the guest operating system memory as memory pressure builds within the guest. Dynamic memory helps to dynamically and automatically divide RAM between running VMs and provide a VM with more or less memory in response to changes in the resource demand of running VMs. This helps to provide more efficient use of memory resources on a Hyper-V host and greater VM density on a given host as well.
When you select Use Dynamic Memory for this VM, you have a Minimum RAM value and a Maximum RAM value.
The next step in our VM configuration is Configuring Networking. In order for a particular VM to have connectivity to the network, we must attach the VM to a virtual switch that has connectivity to the intended networks. However, we can also leave a VM in a disconnected state as well as this is not a requirement in finishing the VM configuration. As you can see here, we are connecting the VM to the ExternalSwitch which is a virtual switch connected to the production LAN.
Hard Disk Configuration
Next, we want to configure the hard disk that is assigned to our VM. We have three options that we can select – Create a virtual hard disk, Use an existing virtual hard disk, and finally Attach a virtual hard disk later. The three options are fairly intuitive. When we choose the Create a virtual hard disk option, we are choosing to create a brand new vhdx disk on our Hyper-V host. We can set the size of the disk as well. The wizard defaults to 127GB which can easily be changed.
If we want to simply attach our new VM configuration to an existing virtual hard disk we can select that option. Maybe we copied over a vhdx file we want to reuse with a new VM configuration. We can simply point the wizard to the vhdx file with this option.
With the third option – attach a virtual hard disk later, we can choose to skip the creation of a hard disk in the wizard and assign a disk later. A note here is that one of the caveats to create a virtual hard disk option is that you have no choice at that point to choose the type of disk to create. By default, Hyper-V creates dynamically expanding disks, which many are more familiar with as thin provisioned disks. Space is only used as the VM needs it. There is overhead however to this process. While the Hyper-V storage driver makes efficient use of these, for the best performance, many will still want to provision thick disks or fixed size in the Hyper-V world. To do that, we need to choose the third option and attach a virtual hard disk later.
Next, we have the Installation Options which is basically the configuration of how we plan on installing the guest operating system in our VM. Most will want to boot from ISO and install the guest in that way. However, we have the option to Install an operating system later or we can choose to install via a network-based installation server as well.
When we choose to Install an operating system from a bootable image file we will need to have an ISO file copied to our server to a location we can browse to in the wizard.
Finally, we reach the summary of our configuration choices. Once we click Finish our VM is created with the options we chose.
Once we complete the configuration of our VM and it is created, we can power on the VM and then connect to it to view the console. To power on the VM, we can right-click it and select Start.
After starting the VM, we can connect to the console by right-clicking and selecting Connect.
After connecting to the console, we should now be able to boot our VM and install the operating system as normal through the operating system installation prompts.
We have covered the options in creating new VMs in Hyper-V Manager and the configuration options that are available. In the next post, we will look in more detail in adding a fixed size hard disk to a VM in Hyper-V manager. Also, we will look at copying ISO installation media to our Hyper-V host as well as provisioning VMs using PowerShell.