Rules to Better Hyper-V - 17 Rules
If you still need help, visit our Hyper-V consulting page and book in a consultant.
When SysAdmins first get going with Hyper-V, they often choose to use dynamically expanding VHD’s. They often do this to increase VHD creation time and reduce hard disk usage.
The problem with dynamically expanding VHDs is that they reduce the performance of the Virtual Machine. It is much better to use a fixed VHD when the Virtual Machine is used in a production environment.
Microsoft lists several recommended and supported network configurations. It is very important that you configure your Hyper-V Cluster with one of the supported network types otherwise you will have performance issues once you load up the cluster.Figure: Check you have one of the supported configurations listed on the >Microsoft Hyper-V Live Migration – Network Configuration page (this example has 3 networks) It may work fine initially on a non-supported configuration but when you start loading more Virtual Machines on to the cluster the performance will be degrade dramatically.
When creating a new VM, it is advised to always choose Gen 2 unless there is a specific reason not to. Some of the benefits of using Gen 2 VMs are:
- Secure Boot
- Faster Boot times
- Changes to Ram, CPU and VHDX can be made without shutting down
- Can support larger amounts or RAM and CPU
Some reason you may not choose Gen 2 VMs:
- Operating system requirements
- Software vendor requirements
- Virtual floppy disk support
- Virtual COM ports
When formatting a new virtual disk you have attached to a Hyper-V Virtual Machine, you can choose to to format the disk as a Basic disk or Dynamic disk .
A Dynamic disk might be useful in situations where you want to create a software RAID array, but when using Hyper-V this not a good idea because it prevents Microsoft Data Protection Manager (DPM) from doing Child State Backups (backups while the machine is running).
For this reason, never use Dynamic disks inside Hyper-V Virtual Machines.
Figure: Bad Example - DPM cannot backup this Virtual Machine's child state as it has a Dynamic Disk
Good example – Using Basic Volumes allows DPM to backup the Virtual Machine’s child state
Occasionally when you estimate the size of a VHD that you will be using in a server, you can get it wrong and you will need to give the Virtual Machine some more space. Instead of adding a bigger data disk in the Virtual Machine and migrating data, you can expand the existing disk.
- Open the Hyper-V Manager on the server hosting the Virtual Machine
- Shutdown the virtual machine (only required for Gen1 VMs)
- Click Edit Disk... in the Actions pane of the Hyper-V Manager ** **Figure: You expand a VHD from the Actions Menu | Edit Disk
- In the Edit Virtual Hard Disk Wizard window, choose the VHD you want to edit and choose Next.
- Select Expand and click Next
- Enter the new size of the VHD and click Next
You will now have a resized VHD. Next step is to boot up into the virtual machine and tell disk manager to resize the partition on the VHD to use the free space which has been added at the end of the VHD. Windows Server 2008 makes this very simple:
- Boot into the virtual machine
- Open Computer Management and choose Disk Management
- Right click on the partition sitting at the front of the newly resized disk and click on Extend Volume... ** **Figure: The first partition on the disk needs to be expanded to use up the unallocated space created when expanding the VHD
- You will have to use all the available space when you extend the volume as it is a Simple Volume. (See Rule: Do you use Basic Volumes inside VHD’s?) When you are asked to select your disks just click Next
- Click Finish Figure: The disk is now using all the available space inside the VHD
When you configure Hyper-V Clustering, each node will have upwards of 4 network adapters, some virtual and some physical. It is important to give these adapters meaningful names so you know what network adapter does what.
When your Hyper-V environment is spread across multiple hosts and contains many Virtual Servers, it can get very confusing to find the one you are looking for amongst them all. This is why you should use a standard naming convention for all your Virtual machines.
The standard we use for Production Virtual Machine naming is as follows: NetBIOSName-ServiceName.
For example: Falcon-SCVMM.
The standard we use for Development Virtual Machine naming is as follows: DEV-NetBIOSName-ServiceName-DeveloperInitials.
For example: DEV-demo2010a-SP2010MSInfoWorker-JL.
If you need to move a virtual machine from one Hyper-V server to another, you should using the Hyper-V Managers export option rather than just moving the VHD files.
If your machine has snapshots and you copy them rather than export them, it can cause issues with the VHD’s and AVHD’s (Snapshot VHD’s) because Hyper-V does not know there has been a snapshot when you load it onto the new Hyper-V Host. You also lose the settings for your Network Adapter, like its static IP address.
To export a Virtual Machine from the Hyper-V Manager :
- Right click on it when it is shut down and clicking Export...
- Choose the location you wish to export the Virtual Machine to and click on Export
Snapshots are a very easy way to back up a system before a big change is made. They can also be easily restored if something goes wrong during the change.
- In the Hyper-V Manager , ensure the Virtual Machine has the state of Off
- Right click on the virtual machine you wish to snapshot and click Snapshot
- The snapshot should run very quickly and you will notice the snapshot in the Snapshots area of the **Hyper-V Manager
You will see the snapshots associated with a Virtual Machine when you click on them
Snapshots are a very handy tool for a System Administrator, but they can quickly turn into a nightmare if they are not managed properly. Snapshots take far more hard drive space than a virtual machine without, and if you don’t clean up your snapshots you may run out of drive space.Figure: Snapshots are useful, but they can take up a lot of space When you delete a snapshot you can no longer restore the virtual machine to the point in time the snapshot was taken. Deleting a snapshot does not affect any other snapshots, nor will it affect the current state of the virtual machine.
Set yourself a calendar reminder 3 weeks after you make a snapshot so you remember to apply the snapshot to the Virtual Machine (assuming you are happy with the virtual machine after the snapshot).
- In the Hyper-V Manager , click on the virtual machine you want to apply the snapshot to
- In the Snapshots window, right click on the snapshot you wish to apply and click Delete Snapshot…
- Confirm the snapshot deletion.
- Wait for the merge process to complete (this may take a while if you have had the snapshot running for a long time and it has grown large in size).
As Hyper-V Clustering requires some advanced networking technologies make sure you download the very latest drivers for all your network cards – don’t just rely on the out of box driver.
It is important to properly decommission a Virtual Machine rather than just delete it. Developers have a knack for leaving important files everywhere, and inside a Virtual Machine is no exception.
- Let the people that may have been using the Virtual Machine that it is going to be decommissioned. This might be difficult if it was being used for testing or staging.
- Make a text file that matches the name of the Virtual Machine.
- Note down the Virtual Machines static IP address in the text file.
- Check the DNS Manager on a domain controller and note down any DNS names that pointed to the IP Address of the Virtual Machine.
- Copy the Virtual Machines folder to a file server or backup drive.
- Copy the text file into the same location.
- Set a calendar reminder for yourself to delete the Virtual Machine if it hasn’t been requested in 3 months.
To improve performance, it's a good idea to disable NetBIOS over TCP/IP on your cluster NIC and iSCSI NIC. NetBIOS isn't used in Server 2008 R2 clusters.Figure: Good example – the NetBIOS is disabled on the dedicated NIC's (iSCSI & Cluster Communications)
Virtual Machine Manager (VMM) lets you easily apply network settings to a Hyper-V host or cluster.
Instead of managing each Virtual Machine network itself, using VMM to manage them all is much easier.
To do that, you need to complete a few steps:
- Configure network settings with a logical switch;
You can learn more on how to set this up here.
2. Ask yourself: "What is this network adapter going to be used for?"
You need to specify if the network adapter is going to be used for virtual machines, host management, etc...
- Apply the logical switch and monitor physical network devices
For full instructions on how to do this, see here.
Virtual Machine Manager (VMM) is made for managing Virtual Machines (VM)!Everything is easy to set up and deploy using VMM.
You can provision VMs using a number of different approaches in VMM:
- Create VMs from a blank virtual disk; 2. Create VMs from existing hard disks; 3. Clone a VM from existing VM; 4. Create VM from a template; 5. Create VM in a service deployment; 6. Rapidly provision a VM using storage area network (SAN) copy.
You can also deploy VM guest clusters that acts as a failover cluster for your VMs, sharing the same .vhdx files as the main ones!
VMM uses an algorithm to intelligently place your newly created virtual machine on an available host, depending on a few factors:
- CPU rating; 2. RAM rating; 3. Disk I/O rating; 4. Network rating.
It then places the VM in the best host available for it.
VMM does this and much more for VMs, and you can read a bigger explanation here.
You can use Virtual Machine Manager (VMM) to manage your Windows Update Services (WSUS) directly, instead of using the server management itself.
To find full explained instructions on how to set this up, see here.
Before starting, you should take some things into consideration:
- The WSUS server must be in the same domain as the VMM server; 2. Best practices dictates that you should use a separate server to be a WSUS server; 3. After you add a WSUS server to VMM, you should use the VMM console to manage it, and not the WSUS console.
After taking these into consideration, you can start deploying update baselines, which contains a set of required updates scoped to objects, and adding update exemptions as necessary.
Using Virtual Machine (VM) templates makes it easy to deploy consistent VM setting using VMM.
There are 2 types of templates:
- VM templates, which are database objects stored in the VMM library, used to quickly set up VMs 2. Service templates, which defines how a service is configured. They hold information about the VMs, which application to install on VMs, and the network settings that should be used.
You can create a VM template from an existing virtual hard disk, or from an existing VM deployed on a host.
To see how this is done, you can check here.