Product Documentation

OS layer

Jan 11, 2018

You can prepare an operating system image for layering and then import the image into a new OS layer. Then, you can use the OS layer to build multiple App layers, Platform layers, and Layered Images. The OS layer is a virtual disk attached to a virtual machine running your selected Windows operating system for your Layered Images.

Before you start

  • Start with a fresh operating system image, preferably from your hypervisor, so that the operating system is partially optimized for your environment.
  • Make sure that the operating system image is not in a domain. Ensure that the image gets its IP address from DHCP.
  • Ensure that the virtual machine for your OS layer is master boot record (MBR) partitioned, rather than GUID partition table (GPT) partitioned. If you use the GPT partition, you cannot install the OS Machine Tools in Citrix App Layering appliance, also known as Enterprise Layer Manager (ELM). 
  • Avoid using third-party optimization scripts, because they can change services and features that the appliance software uses. For example, Universal Plug and Play and the 8.3 file names setting. Use the optimization tools in the installer download to optimize your image.
  • XenCenter uses Port 5900 to access the console on each virtual machine. Make sure that this port is open on your operating system image. Otherwise, the packaging machines or publish images the console will not work until you restart the virtual machine.
  • The OS Machine Tools are in the appliance download package.

Prepare the image for layering

Prepare a Windows Server 2016 or Windows Server 2012 R2 image (Session Host)

Step 1: Set up a Windows Server 2012 R2 operating system image on a virtual machine

In the XenServer client, do the following.

  1. Create a virtual machine for the operating system image.
  2. Configure the virtual machine hardware settings, for example, the network adapter and video memory.
  3. Configure a virtual hard disk that is large enough for a Windows operating system installation. Make sure it is accessible by the management appliance.
  4. Install the operating system.
  5. Disable Windows System Restore and Windows Automatic Updates. The system handles restore points for you. Layer versions allow you to control when updates occur.
  6. Install XenServer Tools on your operating system image.

Step 2: Copy the Machine Tools on to the operating system image

  1. Download the file Citrix_App_Layering_OS_Machine_Tools.zip onto the operating system image.
  2. Extract the zip files to the directory c:\windows\setup\scripts.

Step 3: (Optional) Configure scripts for Key Management Service activation

If you use Key Management Service (KMS) activation, you can configure scripts for by creating a script file to call the correct KMS activation script when the system starts. You can also run the Unattend file included in the App Layering OS Machine Tools download, as described in the next step. To configure scripts for KMS, do the following. 

In the directory folder c:\windows\setup\scripts, run the file SetKMSVersion.exe as an administrator.
Running this file creates a script file in the directory folder c:\windows\setup\scripts\kmsdir. The script file calls the appropriate KMS activation script when the operating system starts.

Step 4: Install the operating system Machine Tools on to the operating system image

  1. In the folder Citrix_App_Layering_OS_Machine_Tools, run the file setup_x86.exe (32-bit) or setup_x64.exe (64-bit).
  2. The installation prompts you for the location of the unattend.xml file. (The default location is c:\windows\panther.)

After completing the steps, you can import the image into a new OS layer.

Prepare a Windows Server 2008 R2 image

Step 1: Set up a Windows Server 2008 R2 operating system image on a virtual machine

In the XenServer client, do the following.

1. Create a virtual machine for your operating system image. Ensure that you choose the default cluster allocation size of 4 K.

2. Configure the virtual machine hardware settings; for example, the network adapter and video memory.

3. If you are using Citrix Provisioning Services or VMware Horizon View, install Windows Server 2008 R2 Service Pack 1 (SP1).

4. If using Provisioning Services:

a. Install hotfix KB2550978 on the Provisioning Services server..

b. Restart the virtual machine..

c. Enter the commands:

set devmgr_show_nonpresent_devices=1
devmgmt.msc

d. Uninstall any dead (ghost) NICs.

e. Reboot the system.

5. Disable Windows System Restore and Windows Automatic Updates. The system handles restore points for you. Layer versions allow you to control when updates occur.

6. Install XenTools on the OS image.

Step 2: Copy the OS Machine Tools onto the OS Image

  1. Download the App_Layering_Citrix_App_Layering_OS_Machine_Tools ZIP file onto the OS Image.
  2. Extract the App_Layering_OS_Machine_Tools_x.x.x to c:\windows\setup\scripts.

Step 3: (Optional) Configure Scripts for KMS Activation

If using KMS Activation, you can configure scripts for KMS activation either by creating a script file to call the correct KMS activation script when the system starts, or by running the Unattend file included in the App Layering OS Machine Tools download, as described in the next step. To configure scripts for KMS, do the following.

In the c:\windows\setup\scripts folder run SetKMSVersion.exe as Administrator. This creates a script file in the c:\windows\setup\scripts\kmsdir folder to call the appropriate KMS activation script when the OS starts.

Step 4: Install the OS Machine Tools on to the image

  1. In the Citrix_App_Layering_OS_Machine_Tools folder, run the setup_x86.exe (32-bit) or setup_x64.exe (64-bit).
  2. The installation prompts for the location of the unattend.xml file (the default location is c:\windows\panther).

Once this is done, you are ready to import the image into a new OS Layer.

Prepare a Windows 10 image

When preparing the OS Image for import into an OS Layer, you can speed up start times by removing Windows 10 built-in applications. If you do, we recommend removing these applications either on the OS Image itself, or on the OS Layer.

Step 1: Set up a Windows 10 image on a virtual machine

In the XenServer client, do the following. 

1. Create a VM for your OS image.

Important: When creating the image, be sure to choose the default cluster allocation size of 4K.

2. Configure the virtual machine hardware settings, for example, the NIC and video memory.

3. Disable Windows System Restore and Windows Automatic Updates:

The App Layering system handles restore points for you. Layer versions allow you to control when updates occur.

a. Log into the VM.

b. Select Computer Config > Administrative Templates > Windows Components > Windows Updates > Config Auto Updates.

c. Set this to Disabled.

4. If using KMS licensing, run a command window as Administrator, and enter these commands:

slmgr /skms <kmsserverhost>
slmgr /rearm
reboot
slmgr /ipk XXXX-YOUR-KMS-KEY-XXXX
slmgr /ato

5. Install the VMware Tools on the OS image.

6. If you are including the Windows Store in your Windows 10 image, get the latest updates for all Store Apps.

a. Launch the Windows Store application, click the Sign in icon (top right), then select Downloads and Updates.

b. Check for Updates, and click Update All. This should be repeated at least twice to ensure that the latest updates have been pulled.

Important

Avoid finalizing the OS Layer while download or update processes are running, as this may cause deployed images (and every user) to experience a continuation of those operations each time they log in.

Step 2: Copy the OS Machine Tools onto the OS Image

  1. Download the Citrix_App_Layering_OS_Machine_Tools ZIP file onto the OS Image.
  2. Extract the Citrix_App_Layering_OS_Machine_Tools_x.x.x to c:\windows\setup\scripts.

Step 3: (Optional) Configure Scripts for KMS Activation

If using KMS Activation, you can configure scripts for KMS activation either by creating a script file to call the correct KMS activation script when the system starts, or by running the Unattend file included in the App Layering OS Machine Tools download, as described in the next step. To configure scripts for KMS:

  • In the c:\windows\setup\scripts folder run SetKMSVersion.exe as Administrator. This creates a script file in the c:\windows\setup\scripts\kmsdir folder to call the appropriate KMS activation script when the OS starts.

Step 4: Install .Net Framework 3.5.1

The .Net Framework is a software framework provided by Microsoft that is required for many 3rd party applications to run. To install this feature, follow the steps below.

  1. On the Start menu, select Control Panel > Programs and Features.

  2. In the left panel select Turn Windows features on or off. A window opens.

  3. Select .NET Framework 3.5, click OK, and wait for the installation to complete.

    Important: Even if .NET is already installed, continue with the rest of these steps.

  4. Exit the Control Panel.

  5. In Notifications in the right-side of your taskbar, click All Settings, and open the Windows 10 Settings app.

  6. Select Settings > Update & Security.

  7. Check for updates, and install all updates available.

  8. Exit Settings.

  9. Open an administrator-level command prompt, and enter the following commands:

    cd \windows\Microsoft.Net\Framework\v4.nnnnn
    ngen update /force

  10. Wait for the command to complete, and enter the following commands:

    cd \windows\Microsoft.Net\Framework64\v4.nnnnn
    ngen update /force

  11. Exit the command prompt.

Step 5: If using PVS, follow these steps to avoid ghost NICs.

  1. Enter the commands:

    set devmgr_show_nonpresent_devices=
    devmgmt.msc

  2. Remove any ghost NICs.

  3. Reboot the system.

Step 6: Install the OS Machine Tools onto the OS Image

  1. Run setup_x64.exe from c:\Windows\setup\scripts.

Once this is done, you are ready to import the image into a new OS Layer.

Prepare a Windows 7 image

Step 1: Set up a Windows 7 OS Image on a virtual machine

In the XenServer client:

  1. Create a VM for your OS Image.

    Important: When creating the image, be sure to choose the default cluster allocation size of 4K.

  2. Configure the virtual machine hardware settings, for example, the NIC and video memory.

  3. Disable Windows System Restore and Windows Automatic Updates. The App Layering system handles restore points for you, and layer versions allow you to control when updates occur.

  4. Make sure you have installed VMware Tools on the OS image.

Step 2: Mount or copy the Citrix App Layering OS Machine Tools onto the OS Image

  1. Download the Citrix_App_Layering_OS_Machine_Tools ZIP file onto the OS Image.
  2. Extract the citrix_app_layering_os_machine_tools_x.x.x to c:\windows\setup\scripts.

Step 3: (Optional) Configure Scripts for KMS Activation

If using KMS Activation, you can configure scripts for KMS activation either by creating a script file to call the correct KMS activation script when the system starts, or by running the Unattend file included in the App Layering OS Machine Tools download, as described in the next step. To configure scripts for KMS:

  • In the c:\windows\setup\scripts folder run SetKMSVersion.exe as Administrator. This creates a script file in the c:\windows\setup\scripts\kmsdir folder to call the appropriate KMS activation script when the OS starts.

Step 4: If using PVS, follow these steps to avoid ghost NICs

  1. Install KB2550978 hotfix.
  2. Reboot the VM,
  3. Enter the commands:

    set devmgr_show_nonpresent_devices=1
    devmgmt.msc

  4. Remove any ghost NICs.
  5. Reboot the system.

Step 5: Install the Citrix App Layering OS Machine Tools onto the image

  1. In the Citrix_App_Layering_OS_Machine_Tools folder, run the setup_x86.exe (32-bit) or setup_x64.exe (64-bit).
  2. The installation prompts for the location of the unattend.xml file (the default location is c:\windows\panther).

Once this is done, you are ready to import the image into a new OS layer.

Import the image into a new OS layer

  1. In the Management Console, select Layers > OS Layers and click Create OS Layer in the Action bar. This opens the Create OS Layer Wizard.
  2. In the Layer Details tab, specify a Layer Name and Version, both required values. Optionally, you can enter Descriptions of the Layer and Version, and change the Max Layer Size to accommodate the OS you are going to import.
  3. In the Connector tab, select a XenServer Connector Configuration that specifies the location of your clean OS image. If the configuration you need is not listed, add a New one, and then select it from this list. For details about adding this Connector Configuration, see Create a Connector Configuration.
  4. In the OS Disk Details tab, click Select Virtual Machine. This opens a new browser tab.
  5. Click in the Virtual Machine field to reveal a list of all available virtual machines. Select a virtual machine from the list, or start typing the name to filter the list, and select the machine.
  6. Click OK. The selected virtual machine is validated to ensure that the machine has a single OS disk attached as a SCSI disk. (Attaching the OS disk as IDE is not supported.)
    If there are problems with the virtual machine or OS disk, an error is displayed. Otherwise, you are returned to the wizard where the machine name and the size of the OS disk are listed.
  7. In the Icon Assignment tab, select an icon image to assign to this Layer.
  8. In the Confirm and Complete tab, review the details of the OS Layer, enter a comment if required, and click Create Layer. If you enter comments, they appear in the Information view Audit History.
  9. When the task completes, the new OS Layer in the Management Console displays a "Deployable" status.

Optional tools for optimizing the operating system

Create an answer file for unattended installation (Optional)

In the rare case that you need to run Windows Mini Setup with an Unattend.hta file, use these steps.

  1. In the c:\windows\setup\scripts folder, right-click the unattend.hta tool and choose Run as administrator. The unattend builder form opens.
  2. Complete the unattend form.Product key activation.
    • For KMS activation, select KMS Server.
      • For KMS with a Multiple Activation Key (MAK), select KMS with MAK and enter the MAK.
      • For Retail Licensing with a MAK, select Retail with MAK, and the MAK.
    • Local Administrator account
      • If you want to use the unattend.xml file to enable the Administrator account on each Layered Image, select Enable. Remember to also enable this account in your OS Image or Operating System Layer revision. It is possible to enable the Administrator account for your OS Image and then have it disabled in the deployed Layered Images by clearing the check box
      • .If you want to add an alternate Administrator account, select Enable and enter the account information. This account cannot be pre-configured in the OS Image.
      • You can create a Layered Image where the Administrator is disabled and the alternate administrator is created and enabled. However for this to work, the Administrator account must be enabled in the OS Image and it cannot be renamed.
    • Time zone
      • Select the time zone. If your time zone is not listed, you can add it to the Other box. Be sure to use the time zone, not the display setting. A list of time zone settings can be found here.
    • Disabling automatic activation
      • Select this option if you plan to use the Microsoft Volume Activation Management Tool.
  3. Click Save File.

Optimize the OS Image for layering (Optional)

The Optimization script creates a file that sets up scripts and allows for easier layering of Microsoft Office. It allows you to save memory and CPU by disabling services you don't need and removing installation-specific drivers and settings. It also enables services you need.

  1. In the c:\windows\setup\scripts folder, run the optimizations.cmd file to create a file that will be run when the image is created.

  2. If you run the Unattend.hta file, the optimizations.cmd file is run automatically. If you run optimizations.cmd without first running Unattend.hta, follow the instructions to run it on the OS Image. 

    If you are using the Optimizations script and you are enabling the View Persona feature, you must go to the section of the script called Disable Unnecessary Services to Save Memory and CPUdeselect the option to Disable Offline File Service, and click Save File. This is because View Persona folder redirection requires Offline files to be enabled, and by default, the optimization script turns off any offline files that are not a requirement for App Layering.

Import the OS Image into a new OS Layer

  1. In the Management Console, select Layers > OS Layers and click Create OS Layer in the Action bar. This opens the Create OS Layer Wizard.
  2. In the Layer Details tab, specify a Layer Name and Version, both required values. Optionally, you can enter Descriptions of the Layer and Version, and change the Max Layer Size to accommodate the OS you are going to import.
  3. In the Connector tab, select a XenServer Connector Configuration that specifies the location of your clean OS image. If the configuration you need is not listed, add a New one, and then select it from this list. For details about adding this Connector Configuration, see Create a Connector Configuration.
  4. In the OS Disk Details tab, click the Select Virtual Machine button. This opens a new browser tab.
  5. Click in the Virtual Machine field to reveal a list of all VMs. Select a VM from the list, or start by typing the name to filter the list to VMs that contain the search text, and then select the VM.
  6. Click OK. The selected VM is validated to ensure that the VM has a single OS disk attached as a SCSI disk. (Attaching the OS disk as IDE is not supported.)

    If there are problems with the VM or OS Disk, an error is displayed. Otherwise, you are returned to the wizard where the VM's name, and the size of the OS disk are listed.

  7. In the Icon Assignment tab, select an icon image to assign to this Layer.
  8. In the Confirm and Complete tab, review the details of the OS Layer, enter a comment if required, and click Create Layer. If you enter comments, they appear in the Information view Audit History.

When the task completes, the new OS Layer in the Management Console displays a "Deployable" status.