Creating variables for the kernel command line

Red Hat Enterprise Linux 8.6 LPAR mode z/VM guest KVM guest

You can modify the kernel command line, substituting its parts with variables.

About this task

Any expression of the form ${<keyword>} in the kernel command line is replaced during boot with the value associated with <keyword>, as defined by the installed zipl environment block. If no value associated with <keyword> is found, then the expression is removed from the command line.

The initial mapping between keywords and values is established when the boot record is installed with zipl, see zipl environment file syntax. You can change the mapping by using the zipl-editenv command, which modifies the content of an installed zipl environment block, see Modifying a zipl environment block with zipl-editenv.

In a kernel command line, identify parts that you might want to be a variable. The kernel command line can be a combined string from multiple sources, see “How kernel parameters from different sources are combined” on page 28. Some of these sources support variables::
  • The zipl configuration file (/etc/zipl.conf)
  • Kernel parameter file
  • BLS snippets (boot/loader/entries/…)
  • The interactive DASD boot menu

Example

This example shows how to replace variable parts in the kernel command line with variables. The original installation is unaffected. The example shows a snippet of the kernel parameters, other parameters can be included, for example parameters that are automatically appended by an earlier stage of the boot process.

  1. Assume that a parameter specification is as follows:
    root=/dev/dasda1 panic=9
    
  2. Assume you might want to boot with another root partition and different values of panic time-out. Then, you would replace /dev/dasda1 and panic=9 with variables. Assume that you choose the keywords ROOT and PANIC_TIMEOUT for them, respectively.
    Replace the parameters in the original command line with variables as follows:
    root=${ROOT} ${PANIC_TIMEOUT}

    You can replace a whole parameter as with ${PANIC_TIMEOUT} or just the parameter value as with ${ROOT}. Now you must give the variables values. Use a zipl environment file to do this.

  3. Use your favorite text editor to set up a zipl environment file. For details about the file syntax, see zipl environment file syntax.
    Assume you create a zipl environment file /etc/ziplenv. Now use the keywords you chose before, ROOT and PANIC_TIMEOUT, to set values. For example:
    #cat /etc/ziplenv
    ROOT=/dev/dasda1
    PANIC_TIMEOUT=panic=9
  4. Prepare a block device for IPL with zipl. Run zipl.
  5. Reboot the system with the prepared boot configuration, log in, and display the current command line:
    # cat /proc/cmdline
    root=/dev/dasda1 panic=9 ...
    Figure 1 illustrates the process of replacing specifications in the command line with variables.
    Figure 1. Variables on the command line
    The figure illustrates the flow of steps 1-5.

Results

During the IPL process, the variables ${ROOT} and ${PANIC_TIMEOUT} resolved to /dev/dasda1 and panic=9 respectively, according to the keyword definitions in the zipl environment block. This ensures that the original installation works as before, but you can now boot with another root partition and different values of panic timeout by changing the zipl environment block. For an example of how to change the zipl environment block, see Modifying a zipl environment block with zipl-editenv.