Effective VM Cloning with XenServer

Many customer do leverage the powerful VM cloning functionality present in XenServer. This could either do full clones including a full copy process or even leverage storage capabilities by running fast-clone methods. Especially when using StorageLink this is even more performant and effective.

This may also be a major consideration when using XenDesktop deployments where either

– PVS is deployed with local disk write cache

– no PVS is used and there is no 3rd party deployment in place

Individualization using MS Sysprep

In above mentioned cases XenCenter cloning technology can be used. The cloning itself easily is done by XenCenter context menus of XenServer templates or VMs.

However the individualization of all created clones has to be done by other means. A part of that can be realized using Microsoft sysprep however also for sysprep it’s required to provide input with individual VM information. This might be no issue for the IP configuration a central DHCP server could be used for assigning individual IP addresses. But it might be an issue for setting individual VM hostnames which often have to be created according to custom specifications. XenServer itself does not provide a method for defining a deployed VM name during the cloning process. The easiest and most flexible way would be to enable the guest operating system automatically applying the XenCenter defined VM name.

In the following sections I’ll describe how this could be realized. As base technology I am referring to Microsoft sysprep. Besides of the below mentioned procedure there are also some scripts attached which are required for the whole process. These are required to fill the information of sysprep.inf file especially with the XenCenter name of the virtual machine referenced as computer name (VM guest OS name).

Steps to prepare a sysprep template

This documentation is related to Windows XP templates. In case other operating systems are used there might be modification required especially in the sysprep part. The whole process makes use of running sysprep 2 times. The first sysprep only makes sure that after the first boot up of the cloned VM the hostname is randomly generated and afterwards the indivdiualization script is started. The script generates a 2nd sysprep.inf with the customized hostname and executes sysprep.exe again.

In case only 1 sysprep process should be used, you have to be aware that the cloned VMs come up with the same server name for a short period of time.

  • Prepare a Windows XP VM according to customer’s needs
  • Download and install Windows Powershell in Windows XP VM
  • Create directory c:\deploy on Windows XP VM
  • Copy prep-sysprep.ps1 to c:\deploy
  • Extract deploy.cab (from Windows XP installation CD) files to c:\deploy\sysprep
  • Use Setup Manager to create customer-specific sysprep.inf file and copy it to c:\deploy\sysprepDuring creation make sure that you leave the ComputerName parameter empty:

    sysprep.inf: ComputerName=

  • Extract deploy.cab (from Windows XP installation CD) files to c:\sysprep
  • Create sysprep.inf file in c:\sysprep- Use Template below or similar one

    – Only modify the red marked sections. Make sure that the ComputerName, AutoLogon, AutoLogonCount and GUIRunOnce Parameters are use as specified below.

    – This file must not be modified to customer needs as a subsequent sysprep will be executed (see above) which is customized

;SetupMgrTag

[Unattended]

OemSkipEula=Yes

InstallFilesPath=C:\sysprep\i386

TargetPath=\WINDOWS

[GuiUnattended]

AdminPassword=”citrix

EncryptedAdminPassword=NO

OEMSkipRegional=1

TimeZone=110
OemSkipWelcome=1

AutoLogon=Yes

AutoLogonCount=1

[UserData]

ProductKey=XXXXX-XXXXX-XXXX-XXXX-XXXXX
FullName=”Citrix

OrgName=”Citrix

ComputerName=*

[TapiLocation]

CountryCode=49

[RegionalSettings]

LanguageGroup=1
Language=00000407

[Identification]

JoinWorkgroup=WORKGROUP

[Networking]

InstallDefaultComponents=Yes

[Branding]

BrandIEUsingUnattended=Yes

[Proxy]

Proxy_Enable=0

Use_Same_Proxy=0

[GuiRunOnce]

Command0=”powershell c:\deploy\prep-sysprep.ps1″

  • Execute c:\sysprep\sysprep.exe- Use following settin

    – Click “Reseal”

  • VM is ready for cloning and could be converted to template!
Deployment of VMs

For deployment of the VMs now XenCenter context menus can be used. In case the deployment should be automated by scripts, you could use the steps below with the provided script:

  • Copy vm-deploy.bat script to a system running XenCenter
  • Modify the environment variables according to the customer’s environment and run the script as explained in the top REM section of the script.