How to setup Hyper-V host in Nano Server – Part 3 of Deployment series

by

Part 1 — Nano Server Creation
Part 2 — How to deploy Nano on Physical
Part 3 — How to setup Hyper-V host in Nano Server
Part 4 — How to create Hyper-V cluster

Previously, on our Nano Server Deployment series, we've created a new nano server image in the part 1 and deployed it on a physical server in part 2. Now we will go through configuration.

First we need to connect remotely to that machine over PowerShell for further configuration.

$cred=get-credential

$nanoname='NANO_SRV'

Enter-PSSession -ComputerName $nanoname -Credential $cred

Setting up Nano Server with Hyper-V Role 1

As we are connected to Nano Server remotely we should verify PowerShell execution policy to avoid potential issues with some scripts later.

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Set-Item WSMan:\localhost\Client\TrustedHosts * -force

In my case I have test environment, so I set first command to Unrestricted. Be careful with this setting in production as it allows to run unsigned scripts. Later, with the Restricted or RemoteSigned parameter you can lock back the execution policy.

The second command is for removing restriction for PowerShell remoting. I used asterisk to allow any computer in my lab to connect remotely. Don’t do this in production. Instead limit allowed computers by name or IP.

Again, I recommend you to carefully use both commands in production. It’s NOT security best practice to open computer so widely.

Setting up Nano Server with Hyper-V Role 2

In the following steps, let’s add additional storage in the VMs location.

Get-Disk

$additional_disk=Get-Disk | Where-Object PartitionStyle –Eq "RAW"

Initialize-Disk $additional_disk.Number

New-Partition -DiskNumber $additional_disk.Number -UseMaximumSize -AssignDriveLetter | Format-Volume -NewFileSystemLabel "VMs" -FileSystem ReFS

  • The first command is to get information about all connected disks
  • The second line is to select disk with RAW partition
  • Third line will initialize selected disk
  • Fourth command will create new partition with maximum size and format it with ReFS file system.
Setting up Nano Server with Hyper-V Role 3

Now creating a switch. I’ll start with the Internal one. Creating Internal Switch is optional. I’m creating it for future tests only. So, if you are working with production environment and you don’t need such swich you can skip this step.

Get-NetAdapter

New-VMSwitch -Name "Internal Switch" -SwitchType Internal

Setting up Nano Server with Hyper-V Role 4

And now the normal switch. You can create it on any network interface. In my example I have only one, so I’ll create it on Ethernet0. AllowManagementOS parameter will enable management traffic over that switch.

$net = Get-NetAdapter -Name 'Ethernet0'

New-VMSwitch -Name "External VM Switch" -AllowManagementOS $True -NetAdapterName $net.Name

Setting up Nano Server with Hyper-V Role 5

This process will create an external switch linked to my Ethernet0 adapter. As part of this move, the IP settings are transferred to a new (virtual) adapter connected to that switch.

Setting up Nano Server with Hyper-V Role 6

Because of a known bug with Microsoft, the DNS settings are cleared and we must reset it on the newly created switch interface:

Get-DnsClient

Set-DnsClientServerAddress -InterfaceIndex 6 -ServerAddresses "10.11.0.10"

  • First command is to identify ID of newly created switch
  • With second command we are setting new DNS server
Setting up Nano Server with Hyper-V Role 7

Now you should be able to log in to the Nano console with the domain credentials again. You can also check newly added switches directly in the Nano Server Recovery console.

Setting up Nano Server with Hyper-V Role 8

Last thing before we create the first VM is to set some Hyper-V default options like default paths for VM and Virtual Hard Disk, authentication type, migration limitations, etc.

Get-VMSwitch

Get-VMHost | Set-VMHost -MaximumStorageMigrations 2 -MaximumVirtualMachineMigrations 2 -VirtualMachineMigrationAuthenticationType Kerberos -VirtualMachinePath e:\VMs\ -VirtualMachineMigrationPerformanceOption SMB -VirtualHardDiskPath "e:\VMs\Virtual Hard Disks"

Enable-VMMigration

Setting up Nano Server with Hyper-V Role 9

Next step, we’ll create the new VMs located on the local storage. We can use PowerShell or Hyper-V Manager for this. Bellow PowerShell way of creation.

New-VM -Name testVM -MemoryStartupBytes 1GB -SwitchName "Internal Switch" -Generation 2 -Path "E:\VMs\" -NewVHDPath "E:\VMs\testVM\Virtual Hard Disks\testVM.vhdx" -NewVHDSizeBytes 30GB

SET-VMProcessor –VMName testVM –Count 2

Start-VM testVM

We are creating Generation 2 VM with testVM name, 2 CPU, 1GB memory, new VHDX with 30GB size and connection to my Internal Switch.

Setting up Nano Server with Hyper-V Role 10
Setting up Nano Server with Hyper-V Role 11

At this moment we have a single Nano host with the Hyper-V role installed. We should be able to run the VMs from the local Nano storage. As there are no local management tools, we must use Hyper-V Manager from a remote server or workstation or use PowerShell. In the next part of this guide, we’ll go through clustering of Hyper-V Nano.

Get 30 days trial of Veeam Backup & Replication now

About the author
VeeamVeeam Logo
Mariusz works as a Veeam sales engineer, based in Poland. He has more than 15 years of IT experience and supports the biggest technology projects in managing and securing virtual environments in Central Eastern Europe. He comes from Microsoft, where he worked with Private and Public Cloud topics environments. His specialization is datacenter infrastructure, which is supported by multiple certifications: MCT, MSCE: Private Cloud, MCITP, MCTS, VCP6 and VMCE.