- add
-
Adds a module/version combination to the tree for builds and installs.
Requires source in
/usr/src/<module>-<module-version>/
as well as a properly
formatted
dkms.conf
file.
- remove
-
Removes a module/version or module/version/kernel combination from the
tree. If the modules is currently installed, it first uninstalls it
and if applicable, will replace it with its original_module. Use the
--all
option in order to remove all instances for every kernel at once.
- build
-
Builds the specified module/version combo for the specified kernel. If
no kernel is specified it builds for the currently running kernel. All builds
occur in the directory
/var/lib/dkms/<module>/<module-version>/build/.
- install
-
Installs a built module/version combo onto the kernel it was built for. If
the kernel option is not specified it assumes the currently running kernel.
- uninstall
-
Uninstalls an installed module/version combo from the kernel it was installed
upon. After uninstall completion, the driver will be left in the built state.
To completely remove a driver, the remove action should be utilized.
- match
-
Match installs modules onto the specified kernel by looking at the
configuration of the specified
templatekernel.
Every module that is installed on the
templatekernel
within
dkms
is then installed on that specified kernel.
- mkdriverdisk
-
Creates a floppy driver disk image for use when updated drivers are needed
to install an OS. Currently, the supported distributions are redhat, suse
and UnitedLinux. For Red Hat driver disks, necessary driver disk files are
looked for in the redhat_driver_disk
subdirectory of your module source directory. You
must specify the distro while using this action. Driver disks can be made
for single kernels or can be made to support multiple kernels. To create
a driver disk image with modules for multiple kernels, just specify multiple
-k parameters on the command line (-k kernel1 -k kernel2 -a arch1 -a arch2).
Red Hat began supporting multi-arched driver disks in RHEL3. To force creation
of a driver disk with arch information, specify
-d redhat2
or if you specify multiple architectures on the command-line and use
-d redhat
, DKMS will create a version 2 driver disk. By specifying
-d redhat1
, you can force a version 1 driver disk image.
Note that redhat1 driver disks actually supported multiple architectures when
the second arch was i386 and the kernel module was for the BOOT kernel. DKMS
allows for this, and as such you can create a redhat1 style driver disk if the
only other arch is i386 and the kernel name ends in BOOT.
See
http://people.redhat.com/dledford
for more information on the Red Hat driver
disk standards and which files are necessary to make a driver disk.
Fedora Core 5 and higher, RHEL5 and higher require DKMS version 2.0.14
or higher to generate a proper driver disk image.
For suse/UnitedLinux driver disks, /usr/share/YaST2/modules/Vendor.ycp
will also be copied to the driver disk; no other files are needed.
However, for these distros, you must specify a -r release. For
SuSE 9.1, it would be -d suse -r 9.1. For SLES9, it would be -d suse -r sles9.
By default the disk image it creates is 1440 (k) in size. This can be
overridden by specifying a different
--size ####
which should should be given as a number in kilobytes divisible by 20.
You may have more content than will fit on a floppy. Therefore, DKMS
can now generate image files of different types.
--media=floppy (default)
to generate a floppy disk image, or
--media=iso
to generate a CD-ROM ISO file, or
--media=tar
to generate a tar file.
You may copy the floppy or ISO image file to a USB key to be used with
OS installer.
- mktarball
-
Creates a tarball archive for the specified module/version of all files
in the DKMS tree for that module/version combination. This includes
the source and any built modules for kernels in the tree (as specified).
Otherwise, you can specify
a singular kernel to archive only, or multiple kernels to archive
(-k kernel1 -k kernel2 -a arch1 -a arch2). Optionally, you can use
--archive
to specify the name (with no preceding path) that you would like this
tarball to have. You can also specify
--binaries-only
if you want the resultant tarball not to include the module source. Likewise,
--source-only
can be used to specify that no prebuilt binaries should be included in the tarball.
In general,
mktarball
is great for systems management purposes as you can build your driver
on just one system and then use
ldtarball
on all of your other systems to get the same built modules loaded
without having to wait for anything to compile.
- ldtarball
-
This takes a tarball made from the
mktarball
command and specified with the
--archive
option and loads it into your DKMS tree. This will leave any
newly added modules in the built state and
dkms install
should then be called to install any of them. If files already
exist where
ldtarball
is attempting to place them, it will warn and not copy over them. The
--force
option should be used to override this.
- mkrpm
-
This action allows you to create an RPM package for a specified module / version.
It uses a template .spec file found in
/etc/dkms/template-dkms-mkrpm.spec
as the basis for the RPM. Alternatively, if DKMS finds a file called
/usr/src/<module>-<module-version>/<module>-dkms-mkrpm.spec
it will use that .spec file instead. In general, a DKMS tarball is placed inside
the contents of this RPM, and the RPM itself calls various DKMS commands to
load this tarball, build and install modules on the end user's system. If you do
not want your RPM to contain any prebuilt binaries, be sure to specify
--source-only
in the mkrpm command.
- mkdeb
-
This action allows you to create a debian binary package for a specified module / version.
It uses a template debian directory found in
/etc/dkms/template-dkms-mkdeb
as the basis for the package. Alternatively, if DKMS finds a file called
/usr/src/<module>-<module-version>/<module>-dkms-mkdeb
it will use that folder instead. In general, a DKMS tarball is placed inside the
contents of this package, and the package itself calls various DKMS commands to
load this tarball, build and install modules on the end user's system. If you do
not want your debian package to contain any prebuilt binaries, be sure to specify
--source-only
in the mkdeb command.
- mkdsc
-
This action allows you to create a debian source package for a specified module / version.
It will create a .tar.gz, and a .dsc. All options supported by
mkdeb
are supported by it. The main difference in it's usage is that it will look in
/etc/dkms/template-dkms-mkdsc
as the basis for the package. Alternatively, if DKMS finds a file called
/usr/src/<module>-<module-version>/<module>-dkms-mkdsc
it will use that folder instead. If you do not want your debian source package to
contain any prebuilt binaries, be sure to specify
--source-only
in the mkdsc command.
- mkkmp
-
This action allows you to create an Kernel Module Package source RPM for a specified module / version.
It uses the .spec file specified by
--spec=specfile
else
$module-kmp.spec
as the basis for the RPM. The generated source RPM may then be built using SuSE's build.rpm or
Fedora/RHEL's mock chroot environments. See http://kerneldrivers.org/ for
more details on KMPs.
- status
-
Returns the current status of modules, versions and kernels within
the tree as well as whether they have been added, built or installed.
Status can be shown for just a certain module, a certain kernel,
a module/version combination or a module/version/kernel combination.
If more than one is found, then the first one located (by preference indicated
above) will be considered the "original_module". As well, all copies of the same-named
module will be removed from your kernel tree and placed into
/var/lib/dkms/<module>/original_module/$kernelver/collisions
so that they can be *manually* accessible later. DKMS will never actually do anything
with the modules found underneath the /collisions directory, and they will be stored there
until you manually delete them.
It is important to understand that many of the DKMS directives are arrays whose index
values are tied together. These array associations can be considered families, and there
are currently four such families of directive arrays. MAKE[#] and MAKE_MATCH[#] make up
one family. PATCH[#] and PATCH_MATCH[#] make up the second family. The third and
largest family consists of BUILT_MODULE_NAME[#], BUILT_MODULE_LOCATION[#], DEST_MODULE_NAME[#],
DEST_MODULE_LOCATION[#], MODULES_CONF_ALIAS_TYPE[#], MODULES_CONF_OBSOLETES[#],
MODULES_CONF_OBSOLETE_ONLY[#] and STRIP[#]. The fourth
family is made up of only MODULES_CONF[#]. When indexing these arrays when creating your
dkms.conf, each family should start at index value 0.
Within your
dkms.conf
file, you can use certain variables which will be replaced at run-time with their
values.
- $kernelver
-
This variable can be used within a directive definition and during use, the actual kernel
version in question will be substituted in its place. This is especially useful in MAKE
commands when specifying which INCLUDE statements should be used when compiling your
module (eg. MAKE="make all INCLUDEDIR=/lib/modules/${kernelver}/build/include").
- $dkms_tree
-
See the section on /etc/dkms/framework.conf for more information. This variable represents
the location of the DKMS tree on the local system. By default this is
/var/lib/dkms
, but this value should not be hard-coded into a dkms.conf in the event that the local user
has changed it on their system.
- $source_tree
-
See the section on /etc/dkms/framework.conf for more information. This variable represents
the location where DKMS keeps source on the local system. By default this is
/usr/src
, but this value should not be hard-coded into a dkms.conf in the event that the local user
has changed it on their system.
- $kernel_source_dir
-
This variable holds the value of the location of your kernel source directory. Usually, this
will be
/lib/modules/$kernelver/build
, unless otherwise specified with the
--kernelsourcedir
option.
/etc/dkms/framework.conf
This configuration file controls how the overall DKMS framework handles. It is sourced
in every time the dkms command is run. Mainly it can currently be used to set different
default values for the variables.
$dkms_tree
,
$source_tree
and
$install_tree
which control where DKMS looks for its framework. Note that these variables can also
be manipulated on the command line with --dkmstree, --sourcetree
and --installtree options.
dkms_autoinstaller
This boot-time service automatically installs any module which has
AUTOINSTALL=yes
set in its
dkms.conf
file. The service works quite simply and if multiple versions of a module are in
your system's DKMS tree, it will not do anything and instead explain that manual
intervention is required.
MODULES.CONF / MODPROBE.CONF CHANGES
Changes that your module will make to
/etc/modules.conf
or
/etc/modprobe.conf
should be specified with the
MODULES_CONF_ALIAS_TYPE[#]
, the
MODULES_CONF_OBSOLETES[#]
and the
MODULES_CONF[#]
directive arrays. These arrays should also be used even if your distro uses
/etc/sysconfig/kernel
to track kernel modules.
When the first module is installed upon the first kernel within the user's system,
these entries in
MODULES_CONF[#]
are automatically added to
/etc/modules.conf
and if
REMAKE_INITRD
is specified, then the user's initrd is then remade. Subsequently, as your modules are then
later removed from the user's system, until the final module/version combination is removed
from the final kernel version, those references in
modules.conf
will remain. Once the last module/version combination is removed, those references are then
removed.
As modules/versions are removed and initrds are remade, one of three things will happen if you
have specified a
MODULES_CONF_ALIAS_TYPE.
If no original_module exists for that kernel, and no
MODULES_CONF_OBSOLETES
modules are found in that kernel too, the
modules.conf
alias references will temporarily be removed so that the initrd will successfully
remake. Once the initrd is remade, however; those references are then automatically put
back into
modules.conf
(unless you are removing the last instance of the module on the last kernel).
However, if no original_module exists, but there is an OBSOLETE module
found within that kernel, the alias reference is temporarily shifted to point to the
OBSOLETE module so that the initrd can be remade. After it is remade, it then automatically
puts back the alias reference (unless you are removing the last instance of the module
on the last kernel). Lastly, if an original_module does exist for the kernel
version, then
modules.conf
is not touched and all references persist (even if you are removing the last instance of the
module on the last kernel).
Certain module installations might not only require adding references to
modules.conf
but also require removing conflicting references that might exist in the user's system. If this
is the case, the
MODULES_CONF_OBSOLETES[#]
directive should be utilized to remove these references. More information about this directive
can be found in the
DKMS.CONF
section of this man page.
Note that the end state of your modules.conf file very much depends on what kernel modules exist
in the final kernel you remove your DKMS module from. This is an imperfect system caused by the
fact that there is only one modules.conf file for every kernel on your system even though various
kernels use different modules. In a perfect world, there would be one modules.conf file for
every kernel (just like System.map).
CREATING RPMS WHICH UTILIZE DKMS
See the
sample.spec
file packaged with
DKMS
as an example for what your RPM spec file might look like.
Creating RPMs which utilize
dkms
is a fairly straight-forward process. The RPM need only to install the source into
/usr/src/<module>-<module-version>/
and then employ
dkms
itself to do all the work of installation. As such, the RPM should first untar the source into
this directory. From here, within the RPM
.spec
file, a
dkms add
should be called (remember to use the --rpm_safe_upgrade flag during the add) followed by a
dkms build
followed by a
dkms install.
Your
dkms.conf
file should be placed within the
/usr/src/<module>-<module-version>/
directory.
Under the removal parts of the
.spec
file, all that needs to be called is a: dkms remove -m <module> -v <module-version> --all --rpm_safe_upgrade.
Use of the
--rpm_safe_upgrade
flag is imperative for making sure DKMS and RPM play nicely together in all scenarios of using
the -Uvh flag with RPM to upgrade dkms enabled packages. It will only function if used during
both the add
and
remove actions within the same RPM spec file. Its use makes sure that when upgrading between different
releases of an RPM for the same <module-version>, DKMS does not do anything dumb (eg. it ensures
a smooth upgrade from megaraid-2.09-5.noarch.rpm to megaraid-2.09-6.noarch.rpm).
It should be noted that a binary RPM which contains source is not a traditional practice.
However, given the benefits of
dkms
it hopefully will become so. As the RPM created which utilizes
dkms
is not architecture specific,
BuildArch: noarch
should be specified in the
.spec
file to indicate that the package can work regardless of the system architecture. Also
note that DKMS RPM upgrades (-U option) will automatically work because of the structure
of the
dkms
tree.
Lastly, as a matter of convention, you should name your RPM:
<package>-<version>-<rpm-version>dkms.noarch.rpm. The word
dkms
as part of the rpm-version signifies that the RPM
works within the DKMS framework.
AUTHOR
Gary Lerhaupt
WEBPAGE
http://linux.dell.com/dkms
WHITE-PAPERS
http://linux.dell.com/dkms/dkms-ols2004.pdf
http://www.dell.com/downloads/global/power/1q04-ler.pdf
http://www.linuxjournal.com/article.php?sid=6896
MAILING-LIST
dkms-devel@dell.com
http://lists.us.dell.com/mailman/listinfo/dkms-devel
REFERENCES
Kernel Module Packages
http://kerneldrivers.org
Novell Kernel Module Packages
http://www.suse.de/~agruen/KMPM
Fedora Kernel Module Packages
http://fedoraproject.org/wiki/Extras/KernelModuleProposal