Monday, February 28, 2011

Hyper-V Windows 2008 Server Core setup

Why Server Core installation? Although it does not include the traditional full graphical user interface it provides several benefits that I appreciate very match.

Because this installation option installs only what is required to have a hyper-v server less maintenance is required:
- Less updates and reboots;
- Less disk space;
- Lower risk of bugs;
- Lower attack surface;

And of course, it is absolutelly free, Microsoft offers Hyper-V Server as a free download with no Windows Server license required. Anyone can download Hyper-V Server 2008 R2 from the Microsoft Downloads website.

After the installation you don't need to activate the Hyper-v role, the necessary components needed to create and manage Virtual Machines are already installed by default.

First of all, it is very important to have your server BIOS settings configured properly. Make sure that "Virtualization Technology" and "Execute Disable" are both set to Enabled. In my Dell PowerEdge 1950 I have found them in the "CPU Information" settings. If you receive the "The Virtual Machine could not be started because the hypervisor is not running" error probably you forgot to do the steps above.

The installation steps are straightforward, here you can find detailed instructions. As soon as you have the installation finished, you setup local administrator password and login

Pretty spartan, there are no Desktop and Start Menu, only command-line. But with the SCONFIG tool, you can easily set your system up, get it on the network so you can easily manage the server remotely. Navigation through SCONFIG's options is done by typing a number or letter representing the correct configuration or information option.

With SCONFIG you easy can set up your Hyper-V Server name, join to a domain or a workgroup, configure network settings, make windows update, etc. For details see Configuring a Server Core ....
So assuming that your network configured and the machine is properly joined to a domain, let's enable remote management. Enabling remote management means that you will be able to manage the server from your workstation using Microsoft Management Console(MMC). So once you are in SCONFIG you will need to press 4 and select options 1 and 2.
It will enable MMC Remote Management and Windows PowerShell. It should be made first because the "Allow Server Manager Remote Management" option requires that you have PowerShell enabled - so you cannot shuffle this ordering around to try and avoid the reboot. After the reboot select option 3.

Also you can enable the remote access to your hyper-v server's desktop. It's the option number 7 of the main menu of the SCONFIG. And of course don't forget to add a user that you are going to manage your Hyper-V server with to the Local Administrators group - option number 3 of the main menu.

That's it. Now you can head on to your workstation to manage you Hyper-V remotely. Pay attention that you need Windows 7 desktop to do it. Because the Remote Server Administration Toolkit that is used to manage Hyper-V does not available for previous Windows versions. So download it from the Microsoft site and install. After you have done this you will find new option in the Windows Features list(Control Panel->Programs->Turn Windows features on or off) - Remote Server Administration Tools.
Check Hyper-V Tools (under Role Administration Tools) and Server Manager under the top level list. Now in your Administrative Tools the Server Manager and Hyper-V Manager commands are available.
Actually the Server Manager console is comprehensive tool to manage the whole server: disks, services, users, etc. including Hyper-V Feature. For example, in this article you can read how you can remotely manage devices of your hyper-v server.
But the Hyper-V Manager can be run in its own console that is enough to create and manage virtual machines. Also you need to enable the use of WinRM to connect to your Hyper-V server. To do this run cmd as administrator and type in
winrm quickconfig
Say yes to a couple of prompts. Then type in
winrm set winrm/config/client @{TrustedHosts='RemoteComputerName'}
If you use a firewall configure it to allow remotely manage the servers storage. This command should help:
netsh advfirewall firewall set rule group="Remote Volume Management" new enable=yes

Now you can connect the manager to the Hyper-V server and create first virtual machine. With very straightforward wizard you easy can do it. Just run it from the right side "Actions" panel: New > Virtual Machine
I would recommend to change default Hyper-V folder to store hard disk file and virtual machine configuration file to well known for you folder because sometimes you will need to access some of these files on a file system. To do it use Hyper-V settings. It is better that each virtual machine will have its separated sub folder and the sub folder name will be the virtual machine's host name. For example "C:\Hyper-V\First-VM"
It is obligatory to check the "Store the virtual machine in a different location" option but don't change the path, it should be your default Hyper-V folder. Only in this case all information about this virtual machine will be under appropriate folder:
- Disk file "C:\Hyper-V\First-VM\First-VM.vhd"
- Virtual machine configuration "C:\Hyper-V\First-VM\Virtual Machines"
- Snapshots "C:\Hyper-V\First-VM\SnapShots"
Otherwise in my case this structure was spread across the C:\Hyper-V default folder. It seems that there is a bug in this wizard.
If you are not sure what size of RAM specify for now it does't matter, afterwards you easily can change this value.
To configure network you need to create the virtual network first. Read here for details. Make sure that you use the "Network Adapter". Do not use the "Legacy Network Adapter". The legacy adapter has a lot of emulation, which causes lots of CPU overhead.
This page is about creating a storage for your virtual machine, it is very simple. But unfortunately, the ease of use of the wizard masks some powerful features of Virtual Hard Disks within Hyper-V. As far as selecting the right disk type is a key decision here I want to cover some aspects of Hyper-V virtual hard disk creation and configuration.

There are two types of disk controllers that Hyper-V supports: SCSI and IDE. SCSI is a synthetic storage controller that uses Virtual Machine BUS (VMBUS) and allows to perform disk I/O without any emulation involved with reduced CPU overhead in a very high performance manner. It differs from the IDE that is en emulated device. This means there is a little bit of overhead in processing disk operations and SCSI controller should provide significantly better performance than the IDE. But it is not. Actually Hyper-V has a filter driver that reroutes IDE device I/Os to the synthetic storage device. As a result IDE and SCSI devices both offer equally fast I/O performance when integration services are installed in the guest operating system. There a couple limitations that remain for IDE disks:
  • Disk commands to IDE disks on the same controller are serialized by the guest operating system (note that you can only have two IDE disks on a single controller);
  • The IDE disk is limited to I/O block sizes of 512kb or less – while the SCSI controller can go up to block sizes of 8mb;
However I have yet to see a test where either of these limitations resulted in a noticeable performance difference between IDE and SCSI.

At the same time SCSI has a serious limitation too. So far as SCSI is a synthetic device that uses VMBUS but Hyper-V BIOS has no knowledge of VMBUS, SCSI can't be a boot drive. So the operating system disk must be mounted on the IDE device for the operating system to boot correctly. And this is oblige you to have IDE disk anyway. But Microsoft strongly recommended that you mount the data drives directly to the synthetic SCSI controller if their expected I/O rate is high.

So how about to have two virtual disks for a VM? Actually I don't think it is a challenge. It is generally good practice to separate the OS partition from Data/Workload partitions. So in that respect yes two disks is even a good idea.

Also you need to know about Virtual Hard Disk types. With Hyper-V, your choices include dynamically expanding, fixed-size, differencing and passthrough disks. There are a lot of descriptions these disk types in the internet and for the sake of this tip, I want to focus on fixed and dynamic disks. By default the wizard creates the dynamic disk where you can install an operating system. Such disk saves space on your hard disk, but it is bad choice if you want to get the best performance. Fixed VHD always performs better than a dynamic in most scenarios by roughly 10% to 15%.

So to gain access to configuration options that will allow you to create better performed VM, just skip this step and create the disks independently of the virtual machine later. Then subsequently assign it to the virtual machine after the disks have been created.

1 comment:

  1. I have found a gui app that you can use on the desktop (such as it is) on Free core server 2012 hyper-v 3.0 I use several free apps and one pay for GUI hyper-v manager app. check out my blog at stephanco.blogspot.com pretty cool what you can do with some standalone apps and a fine piece of coding from VT Utilities.

    ReplyDelete