Environment Variables for a Virtual Machine

[#vmenvrst]: Handling environment variables

These directions make heavy use of some environment variables. That helps to make these directions flexible. With just slight modifications to the value assigned to one of these variables, a new value for VMGenNam, a person can start working on a different set of virtual machines.

Note that these variables are not really required to accomplish the tasks that this guide shows. People who understand basic concepts can re-implement the tasks without using the scripts that this guide provides or recommends, and many people have done so. However, using this strategy does work well, and may be quicker than trying to invent a new custom approach.

A description of the intent of these variables can be seen by: Virtual Machine: description of environment variables.

Setting needed variables

Details will be shell-dependent, as shown by: making a vm: vm env scr.


After determining the values for variables (which is actually described later), assign those values to variables. For sh-compatible shells, which is most common in Unix, this can be done using a syntax similar to the following:

export VMDirBas=/srv/virtmach
export VMGenNam=myGenName
export VMLILNAM=demosys
[#vmenvrse]: Verifying virtualization variable values

Understanding output: ][CyberPillar][ Overview: Outputting Variables.


See Warning on copy and paste”.

echo ${VMDirBas} ${VMGenNam} ${VMLILNAM}

Or, for those who don't mind typing more (or who have an easy way to just use “copy and paste” functionality)...

echo VMDirBas=${VMDirBas} VMGenNam=${VMGenNam} VMLILNAM=${VMLILNAM}

Since you requested three variables, the output should be three words long if none of the values have spaces.

Steps to perform

If the variables are not set as expected, then they should be set. If there is documentation that contains specific values for those variables, then following that documentation is recommended. If there is no such documentation, then the variables can be set from scratch. Although handling environment variables provides details about the variables, the values documented there probably need to be customized. That's why the recommended procedure is to start by checking any documentation that is likely to be more specific.


Storing these values will be useful for not only creating a virtual machine's disk image, and specifying the configuration (which contains the details about what the virtual machine is like, such as how much RAM the machine will have), but also the program (a “shell” script) that starts the virtual machine. Therefore, these values are good to document so that they can be used to start the virtual machine at a later time.