Previous page

Next page

Locate page in Contents

Print this page

Creating the Template with vzmktmpl

In the last step, you use the vzmktmpl utility to create the template. To make a template with this utility, you need to specify the path to

  • Metafile that defines all parameters for the template; see Creating Metafiles for details on metafiles.
  • Scripts that are to be executed at different stages of the template life cycle (e.g., when caching an OS template or adding an application template to a Container). Each template should have its own set of scripts optimized for use with the Linux distribution for which the template is created. To learn what scripts to specify for your template:
    1. Install an official template provided by Virtuozzo for the same Linux distribution for which you are creating the template. For example, if you are making a template for CentOS 6, install the CenOS 6 OS template (use the yum install command, if necessary).
    2. Go to the configuration directory (/vz/template/os_name/os_version/arch/config/os/default) of the installed template.
    3. Look for the files starting with "pre-" and "post-" (e.g, pre-cache or post-install):

      # ls -l /vz/template/centos/6/x86_64/config/os/default

      ...

      -rwxr-xr-x 1 root root 453 Aug 13 22:12 post-cache

      -rwxr-xr-x 1 root root 3399 Aug 13 22:12 post-install

      -rwxr-xr-x 1 root root 610 Aug 13 22:12 pre-cache

      -rwxr-xr-x 1 root root 943 Aug 13 22:12 pre-upgrade

      ...

    For the full list of scripts, see the vzmktmpl section in the Virtuozzo 6 Command Line Reference Guide.

Once you have a metafile and the required scripts at hand, copy them to your current working directory and execute the vzmktmpl utility. For example, to create a template for CentOS 6, base it on the centos-6-custom.metafile file, and include the scripts post-cache, post-install, pre-cache, and pre-upgrade in the template, you can run this command:

# vzmktmpl --pre-cache pre-cache --pre-upgrade pre-upgrade --post-cache post-cache --post-install post-install centos-6-custom.metafile

Upon the command completion, the created template is put to your current working directory:

# ls

centos-custom-6-x86_64-ez-1.0-1.noarch.rpm

...

To start using the new OS template, install it on the server using the vzpkg install template command and cache it with the vzpkg create cache command.