7.1. Creating Templates from Existing Virtual Machines
A template can be created from an existing virtual machine that has been configured to meet the needs of several individuals in the organization, and has been sealed with Sysprep (Windows machines only) or a similar tool.
Before selecting an existing virtual machine as the source for a template, ensure that the virtual machine is general enough for this purpose. A virtual machine that is too specific to a particular user or group may require a lot of changes, and is therefore not practical to use as a template.
7.1.1. Sealing a Windows Template with Sysprep
Templates that have been created for Windows virtual machines must be generalized (sealed) before use, by means of a tool such as Sysprep. This section describes how to use Sysprep
to seal a template before use. This ensures that machine-specific settings are not propagated through the template.
Do not reboot the virtual machine during this process.
Before beginning the Sysprep process to prepare a virtual machine to be used as a template, ensure that the following settings have been configured:
The Windows Sysprep parameters have been correctly defined. If not, click Edit VM and enter the required information in the Operating System and Domain fields.
The correct Product Key has been entered in the Configuration Tool, rhevm-config
. If not, as the root user on the Manager, run the Configuration Tool and enter the required information. The configuration keys that you need to set are ProductKey
and SysPrepPath
. For example, for Windows 7, the configuration value is ProductKeyWindow7
, and SysPrepWindows7Path
. The command to set the value is:
# rhevm-config --set ProductKeyWindow7=<validproductkey> --cver=general
For the exact syntax for getting and setting configuration values, see Red Hat Enterprise Virtualization 3.0 Installation Guide
Procedure 7.1. To seal a Windows XP template
Download sysprep
to the virtual machine to be used as a template.
Create a new folder c:\sysprep
.
Open the deploy.cab
file and put its contents in c:\sysprep
.
Execute sysprep.exe
from within the folder. Click OK on the welcome message.
The Sysprep tool displays.
Select the following check boxes:
Ensure that the Shutdown mode is set to Shut down before clicking Reseal
Acknowledge the pop-up window. The virtual desktop will go through the sealing process and then shut down automatically.
Procedure 7.2. To seal a Windows 7 or Windows 2008 template
In the virtual machine to be used as a template, open a command line terminal and type regedit.
The Registry Editor window displays. On the left pane, expand → → .
On the main window, right click to add a new string value using → .
Right click on the file and select
Modify. When the
Edit String dialog box displays, enter the following information in the provided text boxes:
Launch Sysprep from C:\Windows\System32\sysprep\sysprep.exe
Under System Cleanup Action, select Enter System Out-of-Box-Experience (OOBE).
Tick the Generalize check box if you need to change the computer's system identification number (SID).
Under Shutdown Options, select Shutdown.
Click OK.
The virtual machine will now go through the sealing process and shut down automatically.
The Windows virtual machine has now been sealed, and can be used as a template for Windows virtual machines.
7.1.2. Sealing a Linux Template with sys-unconfig
Templates that have been created for Linux virtual machines must be generalized (sealed) before use. This section describes how to use sys-unconfig
to seal a template before use. This ensures that machine-specific settings are not propagated through the template.
Login to the virtual machine to be used as a template and flag the system for re-configuration by running the following command as root:
# touch /.unconfigured
Remove ssh host keys. Run:
# rm -rf /etc/ssh/ssh_host_*
Shut down the virtual machine. Run:
# poweroff
The Linux virtual machine has now been sealed, and can be used as a template for Linux virtual machines.