2.1.3. Linux Distribution Configuration Files

Some OpenVZ tools (e.g., prlctl) need to run special scripts inside a container to perform certain operations on it. However, carrying out one and the same operation inside containers running different Linux versions may require execution of different actions. This may be caused by the fact that different Linux distributions store files in different locations, use different commands to complete one and the same task, and so on. To distinguish between containers running different Linux versions and to determine what scripts should be executed while performing the relevant container-related operations, OpenVZ uses special distribution configuration files located in the /usr/libexec/libvzctl/dists directory on the server.

There are a number of distribution configuration files shipped with OpenVZ by default (centos.conf, fedora-core.conf, gentoo.conf, etc.). To view all configuration files available on your OpenVZ, you can go to the /usr/libexec/libvzctl/dists directory and issue the ls command. The distribution configuration files will be displayed in the form of <Linux_distribution>-<version>.conf where <Linux_distribution> and <version> denote the name of the Linux distribution and its version, respectively (e.g., centos-7.conf).

Any distribution configuration file consists of a number of entries in the form of <parameter_name>=<script_name> where <parameter_name> denotes the name of the parameter defining the operation when the script in the right part of the entry is to be executed and <script_name> is the name of the script to be run on performing the operation defined by the parameter in the left part of the entry. In the current version of OpenVZ, the following parameters are used to define what scripts should be executed for the corresponding Linux version a container is running:

  • ADD_IP: the script specified as the value of this parameter has the default name of <distribution_name>-add_ip.sh and is used to configure the network settings during the container startup and the IP address(es) assignment. The script is launched inside the container on executing the following commands:

    prlctl start <CT_name>
    prlctl set <CT_name> --ipadd <IP_address>
    prlctl set <CT_name> --ipadd <IP_address> --ipdel all
  • DEL_IP: the script specified as the value of this parameter has the default name of <distribution_name>-del_ip.sh and is used to delete an existing IP address from the container. The script is launched inside the container on executing the following commands:

    prlctl set <CT_name> --ipdel <IP_address>
    prlctl set <CT_name> --ipdel all
  • SET_HOSTNAME: the script specified as the value of this parameter has the default name of <distribution_name>-set_hostname.sh and is used to configure the hostname of the container. The script is launched inside the container on executing the following command:

    prlctl set <CT_name> --hostname <name>
  • SET_DNS: the script specified as the value of this parameter has the default name of <distribution_name>-set_dns.sh and is used to configure DNS parameters in the /etc/resolv.conf file. The script is launched inside the container on executing the following command:

    prlctl set <CT_name> --searchdomain <domain> --nameserver <IP_address>
  • SET_USERPASS: the script specified as the value of this parameter has the default name of <distribution_name>-set_userpass.sh and is used to add a new user or change the current password. The script is launched inside the container on executing the following command:

    prlctl set <CT_name> --userpasswd <user>:<passwd>
  • SET_UGID_QUOTA: the script specified as the value of this parameter has the default name of <distribution_name>-set_ugid_quota.sh and is used to set up per-user/group quota. The script is launched inside the container on executing the following command:

    prlctl set <CT_name> --quotaugidlimit <num>
  • POST_CREATE: the script specified as the value of this parameter has the default name of <distribution_name>-postcreate.sh and is used to perform certain tasks (e.g., to modify the crontab files) after the container creation. This script is launched on the server on executing the following command:

    prlctl create <CT_name>
  • POST_MIGRATE: the script specified as the value of this parameter has the default name of <distribution_name>-post_migrate.sh and is used to perform certain operations on the container where the physical server has been successfully migrated. This script is launched inside the container on executing the following command:

    vzp2v [<options>] --ctid <CT_name>

The scripts specified in distribution configuration files are located in the /usr/libexec/libvzctl/dists/scripts directory on the server and executed on performing the aforementioned operations on the containers. After an operation has been initiated, the prlctl or vzp2v utility turns to the corresponding container configuration file, looks for the value of the DISTRIBUTION variable or, if the latter is not present, of the OSTEMPLATE variable in this file, and defines on their basis what Linux version the given container is running. After that, prlctl reads the corresponding configuration file for the determined Linux version from the /usr/libexec/libvzctl/dists/ directory and executes the scripts specified in this file.

Note

Note: If no distribution is specified as the value of the DISTRIBUTION and OSTEMPLATE variables in the container configuration file or no configuration file for the given Linux version was found in the /usr/libexec/libvzctl/dists directory, the default file from this directory is used.