Adding Kernel Modules to Linux


A number of Linux packages include kernel modules for their operation.  Many of these are device drivers for such things as video cards, specialized disk hardware or virtual devices.  These kernel modules are installed in addition to those provided by RedHat are not automatically reinstalled during kernel updates.  To properly reinstall these modules requires their inclusion in the new kernel's module directory and running modprobe() on each to register it with the kernel.  It may also require recompilation of the module for use with the newer kernel.

A kernel module reinstaller has been developed for the ECN environment to process non-RedHat kernel modules so that they are automatically reinstalled when a machine is booted with an updated kernel.  This document describes the procedure to create the files and scripts required to perform these automatic reinstallations.

Building and Packaging Kernel Modules

A local kernel module should be packaged using the standard ECN model described in Hints for Creating and Installing UNIX Software.  The package will usually need no links in the /usr/local, /usr/new. /usr/old or /usr/opt directories.

One additional file that is required is a script that will compile (if needed) the module and perform all installation steps except modprobe().

Install Script

The installation script should be named 'install' and be located at the top of the package's  installation tree (/opt/<package_name>/current).  This script will perform all installation steps for the module which may include compiling and copying the created file(s) into the proper kernel module directory for the currently running kernel.  This script will be run at boot time if the module is not already prepared for loading via modprobe().  This script may be provided by the module developer or written by the packager.

Configuring Automatic Updates

To configure a module for automatic updates, a number of files must be modified.  The files are igor maintained, and so editing is done on the configuration file in igor.  The files to change are as follows:

  • modules.add - The module name should be added.  This is not always the same name as the package (e.g. fglrx is the module name for the various ATI video driver packages).  It will usually be conditionally included for a machine or class of machines such as those requiring specific hardware drivers.
  • ecn_modprobe.conf - This file will contain instructions on the module installation when modprobe() is invoked.  The installation line will first attempt to load the module using modprobe().  If that fails, the installation script described above will be invoked to ensure that the module is properly installed and then the loading is retried.  Here is a sample ecn_modprobe.conf entry for the NVIDIA video driver module:

@if defined (NVIDIA_DRIVER)
install nvidia /sbin/modprobe --ignore-install nvidia || /opt/nvidia/current/nvidia-installer --silent --no-network; /sbin/modprobe --ignore-install nvidia
(Note: The command between the @if line and the @endif line is on one line.  This page may break the line for formatting purposes.)

In this case, the NVIDIA driver for a specific machine class is installed under /opt/nvidia/current.  The script (provided by the vendor) is named nvidia-installer and is called with the options --silent and --no-network.  The first attempt to load the module with modprobe() uses the option --ignore-install to prevent modprobe from reusing the modprobe.conf install script and running into an infinite loop.  If the loading fails, the script /opt/nvidia/current/nvidia-installer is run and modprobe() is retried.

Last modified: 2010/06/29 14:25:45.300000 GMT-4 by joseph.n.howell.1
Created: 2010/06/03 16:04:52.634000 GMT-4 by joseph.n.howell.1.



Type in a few keywords describing what information you are looking for in the text box below.

Admin Options: Edit this Document