Preparing DotNetPanel VPS Templates with Windows Server 2008
DotNetPanel VPS Solution Guides
Wednesday, 9 December 2009
Table of Contents
The process of deployment of Virtual Private Servers (VPS) to end customers is very similar to deployment of dedicated servers.
Installing guest Operating System on every purchased VPS from scratch is time-consuming process which leads to order delivery delays (some hosting companies may setup new VPS up to 48 hours) and potentially leads to security breaches as a result of configuration errors and human factor.
The goal of every VPS hosting company is to minimize VPS provisioning time (up to several minutes if possible!), reduce administrative overhead and exclude human factor. This could be achieved by creating a new VPS from “operating system template” (OS template) once prepared by highly-skilled personnel.
In DotNetPanel (DNP) VPS solution OS template represents a set of Virtual Hard Disk (VHD) file containing “generalized” image of installed OS (and other applications) and a meta-information describing template supported features as well as provisioning options.
In this article we will demonstrate how to prepare OS template ready for completely automated provisioning of customer VPS with Windows Server 2008 or Windows Vista.
The process of creating a new VPS template for DNP solution could be outlined by the following diagram:
Create a new “master” virtual machine. Its’ Virtual Hard Drive (VHD) with pre-installed operating system and other software will be used as a template for customer virtual machines.
Install desired operating system on “master” virtual machine. Configure operating system settings, services and install additional applications.
Install Hyper-V Integration services including drivers for virtual hardware, mouse support and integration components.
Install DotNetPanel Virtual Machine Configuration Service (DNP VmConfig) to execute various provisioning tasks and gather real-time statistics.
Generalize “master” operating system with Sysprep utility and prepare it for multi-copying.
Copy “master” VHD to DNP Templates library, mount it and replace unattended Setup answer file with template. Setup other installation scripts if required.
Add a new template “item” into Template library index file, describe template supported features and provisioning options.
This document covers every step in more details below.
It is more suitable to work with VHD and virtual machines on full Windows Server 2008 with Hyper-V role installed.
However, if you have remote Hyper-V Server 2008 or Windows Server 2008 Server Core installed you could use “Hyper-V Remote Management Update for Windows Vista (KB952627)”: http://www.microsoft.com/downloads/details.aspx?FamilyID=BF909242-2125-4D06-A968-C8A3D75FF2AA&displaylang=en
Important notes regarding this update:
1. It doesn’t work on Windows Vista Home Basic or Premium editions.
You should enable “Administrative Tools” menu
To enable “Administrative Tools” menu right-click on Task Bar -> “Properties” menu item -> “Start menu” tab -> “Customize...” button.
For complete Windows Server 2008 remote management you could use “Microsoft Remote Server Administration Tools for Windows Vista (KB941314)”: http://www.microsoft.com/downloads/details.aspx?FamilyID=9ff6e897-23ce-4a36-b7fc-d52065de9960&displaylang=en
1. It requires Windows Vista Business edition or above
2. It requires Service Pack 1 installed.
In all our examples below we will be using full Windows installation with Hyper-V role installed.
You have to create a “master” virtual machine which will be used to work with template VHD.
To install guest OS on master virtual machine you need .ISO file or physical DVD media with operating system distributive. You can download DVD ISO files from MSDN subscriptions.
Open “Hyper-V Manager” and click “New -> Virtual Machine...” from action menu to start virtual machine creation wizard.
· Give new VM some meaningful name helping to distinguish it from others, for example “Master - Windows 2008 Standard x64”. We recommend to establish some VM naming conventions, such as “Master - <OS_NAME> <OS_EDITION> <BITNESS> [(INSTALLED_APP_1, INSTALLED_APP_2, ...)], for example to indicate that particular VM is a master VM with Windows Server 2008 Enterprise x64, IIS, SQL Server and DNP installed you could use the following name: “Master – Windows 2008 Enterprise x64 (IIS, SQL, DNP)”.
Select VM location. It is recommended to store virtual machines on a separate hard disk
volume. It would simplify their backup procedure (VM backup procedure is
described in a separate DNP VPS solution guide). For example, in our case the
system volume is C: and Hyper-V virtual machines are created on M: volume.
Again, we recommend here to define some folders structure, for example customer
virtual machines are stored in M:\VPS\Customers folder and master VMs are in
· Give new VM enough virtual memory to run Windows Server 2008 (at least 512MB).
· Connect VM to valid external network
Create a new virtual hard disk with the minimum
space, just enough to install Windows 2008 and other optional applications.
Windows Server 2008 requires minimum 10GB, so let’s give it 15GB of free space
by specifying this size for new VHD on appropriate wizard step:
Select “Install an operating system from a boot
CD/DVD-ROM” option and select DVD image file (.ISO) or pass-through physical
DVD drive on Hyper-V machine:
· On the last wizard step select “Start the virtual machine after it is created” option and click “Finish”.
Just created master VM boots from Windows Server 2008 installation DVD and OS installation process begins:
Note that mouse could not be available at this time as Integration Services must be installed in guest OS to support mouse.
Select required Windows Server 2008 Edition from the list and press “Next” button. In our example we are installing “Windows Server 2008 Standard (Full Installation) x64”.
Follow the rest of wizard steps to install Windows Server 2008:
While installing on every restart VM displays a prompt “Press any key to boot from CD or DVD...” – disregard this message and continue to boot from HDD.
Once Windows Server 2008 installation
process is finished OS loads in “Windows Welcome” phase. Specify Administrator
After completing OS installation you should see “Initial Configuration Tasks” screen:
The first thing you have to do after OS setup is installing “Hyper-V Integration Services”. Integration services include:
· Drivers for Hyper-V virtual devices like synthetic network adapter
· Mouse integration support
· Windows Services for communicating with host Hyper-V machine:
o System shutdown
o Time synchronization
o Data exchange
o Backup (VSS)
To install Integration Services remove Windows Server 2008 installation DVD from VM DVD drive by click “Media -> DVD Drive -> Eject”:
Then select “Action -> Insert Integration Services Setup Disk”:
Restart the system after completing the installation of Integration Services.
After successful setup of Integration Services:
· You are able to use mouse to work with VM through “Virtual Machine Connection”.
· VM must allow network connectivity as NIC drivers were installed.
There are special Hyper-V Windows services
running in the guest OS:
Using “Initial Configuration Tasks” wizard change computer name, make it a member of some workgroup or join to Active Directory domain. We recommend selecting meaningful computer name easily distinguishing it from others, for example in our case it might be “MASTER-W2K8-STD”. Note that NetBIOS name is limited to 15 symbols.
Restart computer after changing its name.
On “Server Manager” home page click “View Network Connections”:
· Change connection properties to connect network. You might need access to your LAN or Internet to download software distributives and other remote files.
On “Server Manager” home page click “Configure Remote Desktop”:
· Select “Allow connections from computers running any version of Remote Desktop” as it will allow you to connect from Windows XP, Remote Desktop Web Connection and other RDC-enabled clients.
· Allow RDC exception on the Firewall
· Click OK.
It is recommended policy. You can choose another policy, but anyways DNP Virtual Private Servers Policy should be correlated with those setings.
· Open Administrative tools > Local Security Policy > Account Policies > Password Policy
· Press “Enforce password history” and choose 0.
· Press “Maximum password age” and choose 0.
· Press “Minimum password age” and choose 0.
· Press “Minimum password length” and choose some desired valuse. Do not forget ajust DNP Virtual Private Servers Policy to the same value.
· Press “Password must meet complexity requirements” and choose Disabled.
· Stay “Store passwords using reversible encryption” with default Disable settings.
· Click OK.
Before moving to the next steps backup your master VHD:
1. Shut down virtual machine (do not “Turn off” it!).
Locate its .VHD and copy it to some safe
location, say to “M:\VPS\Master\Backups” folder. You can see the exact location
of VHD file by opening VM properties dialog:
After making VHD backup start VM again.
DotNetPanel Virtual Machine Configuration Service (DNP VmConfig) is a Windows Service that runs in guest operating system and performs the following functions:
· Executes provisioning modules to configure guest operating system
· Gathers real-time statistics (RAM, HDD) that is displayed on DotNetPanel user interface (UI).
The current version of DNP VmConfig includes the following provisioning modules:
· Change computer name
· Change administrator password
· Change network adapter configuration
DNP VmConfig service communicates with host Hyper-V machine through “Hyper-V Data Exchange” integration component, so make sure its service is up and running.
· Windows XP of any edition, Windows Vista of any edition, Windows Server 2003 of any edition, Windows Server 2008 of any edition
· .NET Framework 2.0 runtime:
Note: You don’t need to install .NET Framework 2.0 on Windows Server 2008 as it is installed with OS by default.
Download the latest version of DNP VmConfig from
DotNetPanel web site: http://www.dotnetpanel.com/downloads/?CategoryID=10
Please note you will need to register at www.dotnetpanel.com in order to download files from “VPS Solution” section.
· Extract the contents of the zip file to the destination directory, e.g. “C:\Program Files\DotNetPanel\VmConfig”.
· Install VmConfig service using installation batch:
o In Windows Explorer the destination directory in which DNP.VmConfig.exe executable file is located.
o Run “install.bat”
Open “Services” snap-in by clicking “Start ->
Administrative Tools -> Services”. You should see “DotNetPanel Virtual
Machine Configuration Service” in the list:
· Start “DotNetPanel Virtual Machine Configuration Service”.
Open DNP.VmConfig.log file and make sure it
doesn’t contain any errors. Normally, immediately after service start it must
contain the following text:
[11/26/2008 4:53:32 PM] APP: DNP.VmConfig 18.104.22.168 started successfully
[11/26/2008 4:53:32 PM] START: Loading provisioning modules...
[11/26/2008 4:53:32 PM] END: 3 module(s) loaded
It may probably seem that once we have a ready master VHD the most straightforward way to create another virtual machine would be just copying this VHD instead of creating it from scratch. But if you do that, the duplicated VHD will contain the same Computer Security Identifier (SID) as the master VHD. If you try to join new system to the domain, you won’t be able to login with the following error message: “The system cannot log you on due to the following error: The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain.”
Microsoft states that “Computers running the Windows operating system use a Security ID (SID) to uniquely identify themselves. When you use disk-duplicating software, it is important to take steps to ensure the uniqueness of these Security IDs.”
Sysprep prepares a computer for disk imaging or delivery to a customer by configuring the computer to create a new computer security identifier (SID) when the computer is restarted. In addition, Sysprep cleans up user- and computer-specific settings and data that must not be copied to a destination computer.
Sysprep.exe utility is a part of Windows Server 2008 and it is located in %windir%\system32\sysprep folder (in our case it is c:\windows\system32\sysprep).
You can find more information about Sysprep utlity here: http://technet.microsoft.com/en-us/library/cc766049.aspx
After running Sysprep utility on Master VPS all user- and computer-specific information will be deleted from the operating system. On the next VPS restart operating system will behave much like a fresh OS in the middle of setup process, i.e. it will run “specialize” and then “oobeSystem” (OOBE – out-of-the-box experience) passes. User will be asked to select computer locale and regional settings, specify computer name and set administrator password. But our goal is to hide this process from VPS customers and specify (“answer”) all these parameters on their behalf.
More information about how Windows Setup
configuration passes work:
To automate Windows Setup we provide Sysprep utility with an “answer file” to configure unattended Setup settings for various passes. Answer file represents an XML file with clear and well-documented structure. This file could be conveniently edited in Windows System Image Manager (WSIM) tool that is a part of Windows Automated Installation Kit (WAIK).
You can download WAIK from Microsoft Downloads or MSDN Subscription Downloads. We recommend downloading WAIK from MSDN as it perfectly works on 64-bit systems.
WAIK ISO from Microsoft Downloads is available at: http://www.microsoft.com/downloads/details.aspx?FamilyID=94bb6e34-d890-4932-81a5-5b50c657de08&DisplayLang=en
WAIK could be installed on both Windows Vista and Windows Server 2008.
In order to create an answer file you will also need a copy of install.wim file that is available in “Sources” folder of Windows Server 2008 installation DVD. In order to create a catalog from install.wim image file WSIM must have a write access to the folder where it is located, so copy this file from DVD to some folder on the hard drive (say, “c:\WSIM\Windows Server 2008 x64”).
When you start WSIM toll you will see its main window with several panes:
The first step is to create a catalog from image file. Select “Tools -> Create Catalog” from the top menu. Select install.wim file and select image to catalog. In our case it is the first option (Windows Server 2008 Standard edition):
All possible settings that could be included in the answer file are in the tree in “Windows Image” pane:
The full documentation for Windows Setup configuration settings could be found here: http://technet.microsoft.com/en-us/library/cc749204.aspx
All settings can be applied during various
passes of the Windows Setup process. More information about Windows Setup
Strictly speaking, WSIM tool is just a visual editor for editing XML files with tree-view representation. For instance, sample XML answer file that can be downloaded from “VPS Solution” section of our web site (https://www.dotnetpanel.com/downloads/Default.aspx?ID=75). Specifying settings for computer name, administrator password and three network adapters looks in WSIM as following:
We are going to prepare a very basic answer file just for “generalize” pass which is initiated in the time of Sysprep execution. Later, we will create another answer file with settings for “specialize” and “oobeSystem” phases that will be used by Windows Setup on the first run of new customer VPS.
For “generalize” phase we are disabling auto-starting “Server Manager” application and disabling “Initial Configuration Tasks” dialog:
Save answer file as “unattend-generalize.xml” in “c:\WSIM\Windows Server 2008 x64” folder (where install.wim is located).
You can download this file from “VSP
Solution” section of our web site:
Connect to “master” VPS using Remote Desktop or Hyper-V Virtual Machine Connection and copy “unattend-generalize.xml” file to “%windir%\system32\sysprep” folder of guest OS as “unattend.xml”:
Open command line interface:
Switch to c:\Windows\System32\sysprep directory:
Run sysprep with the following parameters:
When “master” virtual machine is shut down VPS template is almost ready.
Copy master VHD file from its original location (in our example it is “M:\VPS\Master\Master - Windows 2008 Standard x64”) to DNP VPS solution “Templates” folder (in our example it is C:\VPS\Templates”) and rename it to “Windows 2008 Standard x64.vhd”.
Using “vmutils” tool that is available on DotNetPanel web site (http://www.dotnetpanel.com/downloads/?CategoryID=10) mount copied VHD:
Open “Computer Management” snap-in and expand “Disk Management” node. Bring mounted disk online (if it’s offline):
Alternatively, you could make the disk online and clear volume “readonly” attribute (if set) by using DiskPart utility:
From command line:
Display all available disks:
Select required disk by specifying its index:
Bring selected disk online:
List all volumes:
Select volume by specifying its index or drive letter:
Clear readonly flag:
Exit from DiskPart:
In Windows Explorer open “Windows\System32\sysprep” folder on mounted disk.
Download “Sysprep Files for Windows Server 2008” from “VPS Solution” section of our web site (https://www.dotnetpanel.com/downloads/Default.aspx?ID=75) and unpack it to some folder.
Replace contents of “unattend.xml” file in “Windows\System32\sysprep” folder of mounted disk with “unattend-template.xml” from archive.
Help page for “ProductKey” element: http://technet.microsoft.com/en-us/library/cc749389.aspx
Help page for “SkipAutoActivation” element: http://technet.microsoft.com/en-us/library/cc749137.aspx
When deploying a new VPS DotNetPanel will mount VHD again and process this template with VPS-specific values.
When the sysprep process is finished “unattend.xml” file won’t be deleted automatically, however it might contain sensitive information (e.g. product key) that should be hidden from user. To delete “unattend.xml” create “SetupComplete.cmd” batch file in “\Windows\Setup\Scripts” folder (create this folder if not exists) and add the following file:
You can perform any other post-setup tasks in SetupComplete.cmd, for example change names of network connections:
You can find more information about “SetupComplete.cmd”
Unmount VHD using “vmutils” tool:
OS Templates folder (in our example “C:\VPS\Templates”) with template .VHD files must contain “index.xml” file which contains the list of all available templates and has the following structure:
· path – is the name of VHD file without .VHD extension, for example “Windows Server 2008 x64”. This attribute is mandatory.
· diskSize – the internal size in gigabytes of VHD (the size the first disk volume inside VHD). This value is used during VPS creation. If “HDD” quota allocated to VPS less then specified VHD size then VPS won’t be created and error will be displayed. However, this attribute is optional and if it is not specified or equal to 0 (“zero”) disk size will not be verified during VPS creation.
· legacyNetworkAdapter – specifies the type of network adapter that will be created in virtual machine: synthetic (for new Microsoft operating systems where “Intergration Services” exist) or legacy (for Microsoft operating systems prior Windows XP and non-Microsoft operating systems like Linux). If "legacyNetworkAdapter" attribute is not specified it is "synthetic" by default.
– specifies whether remote desktop is enabled in
guest OS and VPS could be access with Remote Desktop Web Connection (RDWC). If
remoteDesktop is “true” a link with RDWC will appear on “General” tab of VPS
properties. If this attribute is not specified RDWC link will be hidden by
· name – display name of OS template. This is the value that will be shown in the dropdown on VPS creation wizard.
· description – description of OS template. Currently it is not used.
· provisioning – optional element including provisioning options.
· sysprep – allows to specify a file inside VHD that must be processed during VPS provisioning. The file may contain DNP template variables and instructions. The “file” attribute must specify relative path (without drive letter) to the file inside VHD as DNP accesses only the first VHD volume, for example “\Windows\System32\sysprep\unattend.xml”. There can be any number of “sysprep” elements to process several files.
· vmconfig – optional element specifying which VmConfig service modules will be executed during VPS provisioning. Using VmConfig on provisioning stage could be helpful if it is hard or even impossible to configure some settings in unattended setup answer file. For example, to configure computer name and administrator password in Windows XP template you could use answer file and network adapters could be configured with VmConfig tool (as it’s quite hard to describe their parameters in the answer file). Other hand, Windows Server 2008 and Windows Vista can be completely configured with answer file (explained in this guide), so this section could be omitted.
o computerName – specifies whether “Change computer name” VmConfig task must be executed during VPS provisioning or not. “true” means task will be executed;
o administratorPassword – specifies whether “Change administrator password” VmConfig task must be executed during VPS provisioning or not. “true” means task will be executed;
o networkAdapters – specifies whether “Setup network adapters” VmConfig task must be executed during VPS provisioning or not. “true” means task will be executed;
When creating index.xml file pay attention to:
· File extension that must be “.xml”. When you are creating a new .txt file in Windows it may hide known extension, so it might be confusing.
· File encoding. UTF-8 is recommended to allow various national characters in template names and descriptions. You may choose encoding on “Save as...” dialog of Notepad.
The following diagram outlines VPS guest OS provisioning and it helps to better understand what’s happening when DNP creates a new VPS:
VHD from Templates Library
DNP copies template VHD to customer VPS folder. If required destination VHD is converted either to dynamic or fixed type and then expanded if its size must be greater that OS template.
Process Unattended setup answer template
VHD is mounted and all specified templates are processed by DNP.
DNP creates a new virtual machine and attaches copied and processed VHD. New virtual machine is starting.
During first run of operating system Windows Setup process configuration settings from “specialize” pass.
Right after “specialize” pass Windows Setup process configuration settings from “oobeSystem” pass.
DNP VmConfig configures the rest of OS parameters
DNP VmConfig service is starting and executing specified provisioning tasks.
This whitepaper described required steps for successful creation of VPS OS template with Windows Server 2008 or Windows Vista. Provided guidance could be used as a good starting point for creation your own OS templates based on Windows Server 2008, but with additional pre-installed software and deployment scenarios.
Initial document version.
Added the information about “ProductKey” element in the answer file and skipping Windows Activation process.
Added a note regarding network adapter parameters before doing sysprep.