|
Michal Marek |
11905e |
WORKING WITH THE SUSE 2.6.x and 3.x KERNEL SOURCES
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Andreas Gruenbacher <agruen@suse.de>, SUSE Labs, 2003, 2004, 2005, 2006
|
|
Michal Marek |
11905e |
Michal Marek <mmarek@suse.de>, SUSE Labs, 2010
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
This document gives an overview of how SUSE Linux kernels are
|
|
Michal Marek |
11905e |
created, and describes tasks like building individual kernels
|
|
Michal Marek |
11905e |
and creating external kernel modules.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
A companion HOWTO that describes how to build driver update disks (among
|
|
Michal Marek |
11905e |
other things) is available at:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
http://developer.novell.com/wiki/index.php/Creating_a_Driver_Update_Disk_%28DUD%29
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
TABLE OF CONTENTS
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Overview
|
|
Michal Marek |
11905e |
Compiling your own kernel
|
|
Michal Marek |
11905e |
Building additional (external) modules
|
|
Michal Marek |
11905e |
Supported vs. unsupported modules
|
|
Michal Marek |
11905e |
Patch selection mechanism
|
|
Michal Marek |
11905e |
Where to find configuration files
|
|
Michal Marek |
11905e |
How to configure the kernel sources
|
|
Michal Marek |
11905e |
Module load paths
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
OVERVIEW
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The kernels for SUSE are generated from the vanilla Linux kernel sources
|
|
Michal Marek |
11905e |
found at http://ftp.kernel.org, on top of which a number of patches are
|
|
Michal Marek |
11905e |
applied. The resulting kernel source tree is configured and built,
|
|
Michal Marek |
11905e |
resulting in a binary kernel.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The add-on patches and configuration files are maintained in
|
|
Michal Marek |
11905e |
a GIT repository at
|
|
Michal Marek |
11905e |
|
|
Jiri Slaby |
31864f |
https://github.com/openSUSE/kernel-source
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
A script (scripts/tar-up.sh) packs up the files in the repository in a
|
|
Michal Marek |
11905e |
form suitable for rpmbuild. When building the RPM packages, the
|
|
Michal Marek |
11905e |
following binary packages get created:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
* kernel-source
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The kernel source tree, generated by unpacking the vanilla kernel
|
|
Michal Marek |
11905e |
sources and applying the patches. The kernel sources are used by
|
|
Michal Marek |
11905e |
a number of other packages. They can also be used for compiling
|
|
Michal Marek |
11905e |
additional kernel modules.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
* kernel-devel
|
|
Michal Marek |
f357ab |
|
|
Michal Marek |
f357ab |
A subset of the kernel-source package that is needed to build
|
|
Michal Marek |
f357ab |
external modules.
|
|
Michal Marek |
f357ab |
|
|
Michal Marek |
11905e |
* kernel-$FLAVOR
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
A number of binary kernels (for example, kernel-default for
|
|
Michal Marek |
11905e |
uniprocessor machines, kernel-smp for smp machines, etc.). These
|
|
Michal Marek |
11905e |
packages are all generated from the same kernel sources, and
|
|
Michal Marek |
11905e |
differ in the kernel configurations used.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
* kernel-$FLAVOR-base
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
A subset of kernel-$FLAVOR, for use in paravirtualized quests that
|
|
Michal Marek |
11905e |
only require a few device and filesystem drivers.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
* kernel-$FLAVOR-devel
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The files used for generating kernel module packages for use with
|
|
Michal Marek |
11905e |
kernel-$FLAVOR.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
* kernel-syms
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
A meta package that pulls in the relevant kernel-$FLAVOR-devel
|
|
Michal Marek |
11905e |
packages for a given architecture.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The repository contains the configuration files (.config) for all SUSE
|
|
Michal Marek |
f357ab |
kernel flavors. All configuration files are included in the dependencies
|
|
Michal Marek |
f357ab |
of the kernel-syms package (see WHERE TO FIND CONFIGURATION FILES below).
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
In the installed system, the kernel-source package installs files in the
|
|
Michal Marek |
11905e |
following directories:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
* /usr/src/linux-$VERSION-$RELEASE/
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The kernel sources.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
* /usr/src/linux
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
A symbolic link to /usr/src/linux-$VERSION-$RELEASE.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
* /usr/share/doc/packages/kernel-source/
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
This document.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
The kernel-$FLAVOR-devel packages install the following files:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
* /usr/src/linux-$VERSION-$RELEASE-obj/$ARCH/$FLAVOR/
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
Kernel build object files for one kernel flavor. These
|
|
Michal Marek |
f357ab |
files are used for compiling additional kernel modules.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
* /usr/src/linux-obj/$ARCH/$FLAVOR
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
A symbolic link to /usr/src/linux-$VERSION-$RELEASE-obj/$ARCH/$FLAVOR.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
COMPILING YOUR OWN KERNEL
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The kernel sources are found in the kernel-source package. The
|
|
Michal Marek |
11905e |
recommended way to produce a binary kernel is:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(1) Install kernel-source. Change to the /usr/src/linux directory.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(2) Create a build directory for use in configuring and building
|
|
Michal Marek |
11905e |
the kernel. Using /usr/src/linux directly requires root priviledges
|
|
Michal Marek |
11905e |
and will cause problems if you need to build kernel modules for
|
|
Michal Marek |
11905e |
other installed kernels.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(3) Configure the kernel (for example, ``make -C /usr/src/linux
|
|
Michal Suchanek |
3371ad |
O=$(pwd) oldconfig'', see HOW TO CONFIGURE THE KERNEL SOURCES).
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(4) Build the kernel and all its modules (``make'').
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(5) Make sure that /etc/modprobe.d/unsupported-modules contains
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
allow_unsupported_modules 1
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
otherwise modprobe will refuse to load any modules.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(6) Install the kernel and the modules (``make modules_install'',
|
|
Michal Marek |
11905e |
followed by ``make install''). This will automatically create
|
|
Michal Marek |
11905e |
an initrd for the new kernel as well (see ``mkinitrd -h'').
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(7) Add the kernel to the boot manager. When using lilo, run ``lilo''
|
|
Michal Marek |
11905e |
to update the boot map.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Instead of building binary kernels by hand, you can also build
|
|
Michal Marek |
11905e |
one of the kernel-$FLAVOR packages using RPM.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
BUILDING ADDITIONAL (EXTERNAL) MODULES
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
A single binary kernel module generally only works for a specific
|
|
Michal Marek |
11905e |
version of the kernel source tree, for a specific architecture and
|
|
Michal Marek |
11905e |
configuration. This means that for each binary kernel that SUSE ships, a
|
|
Michal Marek |
11905e |
custom module must be built. This requirement is to some extent relaxed
|
|
Michal Marek |
11905e |
by the modversion mechanism: modversions attach a checksum to each
|
|
Michal Marek |
11905e |
symbol (function or variable) exported to modules by the kernel. This
|
|
Michal Marek |
11905e |
allows to use kernel modules that have been built for a kernel with a
|
|
Michal Marek |
11905e |
different version or release number in many cases, as long as none of
|
|
Michal Marek |
11905e |
the symbols the module uses have changed between the two kernel
|
|
Michal Marek |
11905e |
versions.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
When releasing maintenance or security update kernels for a specific
|
|
Michal Marek |
11905e |
product, we carefully try to keep the kernel ABI stable. Despite this,
|
|
Michal Marek |
11905e |
we sometimes have no choice but to break binary compatibility. In this
|
|
Michal Marek |
11905e |
case, those kernel modules must be rebuilt.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Additional kernel modules for one of the SUSE kernel flavors can be
|
|
Michal Marek |
11905e |
built in three different ways:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(1) by configuring the kernel sources in a separate build directory
|
|
Michal Marek |
11905e |
(see HOW TO CONFIGURE THE KERNEL SOURCES), or
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(2) by using one of the standard configurations in
|
|
Michal Marek |
11905e |
/usr/src/linux-obj/$ARCH/$FLAVOR, or
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(3) by creating a Kernel Module Package (KMP) as described in the
|
|
Libor Pechacek |
9ab365 |
Kernel Module Packages Manual, https://drivers.suse.com/doc/kmpm/.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The first method involves the following steps:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(1) Install the kernel-source package.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(2) Configure the kernel, see HOW TO CONFIGURE THE KERNEL SOURCES.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(3) Create files required for compiling external modules:
|
|
Takashi Iwai |
17a207 |
``make prepare'' and ``make scripts''.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(4) Compile the module(s) by changing into the module source directory
|
|
Michal Marek |
11905e |
and typing ``make -C $(your_build_dir) M=$(pwd)''.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(5) Install the module(s) by typing
|
|
Michal Marek |
11905e |
``make -C $(your_build_dir) M=$(pwd) modules_install''.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The second method involves the following steps:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
(1) Install the kernel-devel package.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
f357ab |
(2) Install the kernel-$FLAVOR-devel package. This is necessary for
|
|
Michal Marek |
11905e |
symbol version information (CONFIG_MODVERSIONS).
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(3) Compile the module(s) by changing into the module source directory
|
|
Michal Marek |
11905e |
and typing ``make -C /usr/src/linux-obj/$ARCH/$FLAVOR M=$(pwd)''.
|
|
Michal Marek |
11905e |
Substitute $ARCH and $FLAVOR with the architecture and flavor
|
|
Michal Marek |
11905e |
for which to build the module(s).
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
If the installed kernel sources match the running kernel, you
|
|
Michal Marek |
11905e |
can build modules for the running kernel by using the path
|
|
Michal Marek |
11905e |
/lib/modules/$(uname -r)/build as the -C option in the above
|
|
Michal Marek |
11905e |
command. (build is a symlink to /usr/src/linux-obj/$ARCH/$FLAVOR).
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
(4) Install the module(s) with
|
|
Michal Marek |
11905e |
``make -C /usr/src/linux-obj/$ARCH/$FLAVOR M=$(pwd) modules_install''.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Whenever building modules, please use the kernel build infrastructure as
|
|
Michal Marek |
11905e |
much as possible, and do not try to circumvent it. The
|
|
Michal Marek |
11905e |
Documentation/kbuild directory in the kernel sources documents kbuild
|
|
Michal Marek |
11905e |
makefiles.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
SUPPORTED VS. UNSUPPORTED MODULES
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
As an extension to the mainline kernel, modules can be tagged as
|
|
Michal Marek |
11905e |
supported (directly by SUSE, or indirectly by a third party) or
|
|
Michal Marek |
11905e |
unsupported. Modules which are known to be flakey or for which SUSE does
|
|
Michal Marek |
11905e |
not have the necessary expertise are marked as unsupported. Modules for
|
|
Michal Marek |
11905e |
which SUSE has third-party support agreements are marked as externally
|
|
Michal Marek |
11905e |
supported. Modules for which SUSE provides direct support are marked as
|
|
Michal Marek |
11905e |
supported.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The support status of a module can be queried with the modinfo tool.
|
|
Michal Marek |
11905e |
Modinfo will report one of the following:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
- direct support by SUSE: "supported: yes"
|
|
Michal Marek |
11905e |
- third-party support: "supported: external"
|
|
Michal Marek |
11905e |
- unsupported modules: no supported tag.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
At runtime, the setting of the" unsupported" kernel command line
|
|
Michal Marek |
11905e |
parameter and /proc/sys/kernel/unsupported determines whether
|
|
Michal Marek |
11905e |
unsupported modules can be loaded or not, and whether or not loading an
|
|
Michal Marek |
11905e |
unsupported module causes a warning in the system log:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
0 = only allow supported modules,
|
|
Michal Marek |
11905e |
1 = warn when loading unsupported modules,
|
|
Michal Marek |
11905e |
2 = don't warn.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Irrespective of this setting, loading an externally supported or unsupported
|
|
Michal Marek |
11905e |
module both set a kernel taint flag. The taint flags are included in
|
|
Michal Marek |
11905e |
Oopses. The taint status of the kernel can be inspected in
|
|
Michal Marek |
11905e |
/proc/sys/kernel/tainted: Bits 0 to 4 have the following meanings:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
bit 0 = a module with a GPL-incompatible license was loaded (tainted & 1),
|
|
Michal Marek |
11905e |
bit 1 = module load was enforced (tainted & 2),
|
|
Michal Marek |
11905e |
bit 2 = an SMP-unsafe module was loaded (tainted & 4),
|
|
Michal Marek |
11905e |
bit 3 = (reserved),
|
|
Michal Marek |
11905e |
bit 4 = an unsupported module was loaded (tainted & 16),
|
|
Michal Marek |
11905e |
bit 5 = a module with third-party support was loaded (tainted & 32).
|
|
Michal Marek |
11905e |
bit 10 = a machine check exception has occurred (taint & 1024; x86_64 only
|
|
Michal Marek |
11905e |
so far).
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The corresponding codes for the taint flags in Oopses are (x = unknown):
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
- "Pxxx" if bit 0 set or else
|
|
Michal Marek |
11905e |
"Gxxx" if bit 0 unset,
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
- "xFxx" if bit 1 set or else
|
|
Michal Marek |
11905e |
"x xx" if bit 1 unset,
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
- "xxSx" if set or else
|
|
Michal Marek |
11905e |
"xx x" if bit 2 unset,
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
- "xxxU" if bit 4 set or else
|
|
Michal Marek |
11905e |
"xxxX" if bit 5 set or else
|
|
Michal Marek |
11905e |
"xxx ".
|
|
Michal Marek |
11905e |
|
|
Libor Pechacek |
a90946 |
By default, out-of-tree modules will not have the supported flag (that
|
|
Libor Pechacek |
a90946 |
is, they will be marked as unsupported). For building externally
|
|
Libor Pechacek |
a90946 |
supported modules, please get in touch with Solid Driver Program team,
|
|
Libor Pechacek |
a90946 |
led by Scott Bahling, at <soliddriver@suse.com>.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
PATCH SELECTION MECHANISM
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The SUSE kernels consist of the vanilla kernel sources on top of which a
|
|
Michal Marek |
11905e |
number of patches is applied. The file series.conf determines which
|
|
Michal Marek |
11905e |
patches are applied and which are excluded. A script named "guards"
|
|
Michal Marek |
11905e |
converts series.conf into a plain list of patch files to be applied.
|
|
Michal Marek |
11905e |
Guards decides which patches to include and exclude based on a list of
|
|
Michal Marek |
11905e |
symbols. From the kernel-source.src.rpm package, a fully patched
|
|
Michal Marek |
11905e |
kernel source tree can be generated from vanilla sources + patches like
|
|
Michal Marek |
11905e |
this:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
# Install the package:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
$ rpm -i kernel-source.src.rpm
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
# Unpack the patches and the kernel sources:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
$ cd /usr/src/packages/SOURCES
|
|
Michal Marek |
11905e |
$ for f in patches.*.tar.bz2; do \
|
|
Michal Marek |
11905e |
tar -xjf "$f" || break; \
|
|
Michal Marek |
11905e |
done
|
|
Michal Marek |
11905e |
$ tar -xjf linux-2.6.5.tar.bz2
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
# Apply the patches
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
$ for p in $(./guards < series.conf); do
|
|
Michal Marek |
11905e |
patch -d linux-2.6.5 -p1 < $p || break
|
|
Michal Marek |
11905e |
done
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The configuration script config.conf which is similar to series.conf is
|
|
Michal Marek |
11905e |
used for configuration file selection. See the section WHERE TO FIND
|
|
Michal Marek |
11905e |
CONFIGURATION FILES.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The file format of series.conf and config.conf should be obvious from
|
|
Michal Marek |
11905e |
the comments in series.conf, and from the guards(1) manual page. (The
|
|
Michal Marek |
11905e |
guards(1) manual page can be generated by running pod2man on the guards
|
|
Michal Marek |
11905e |
script.)
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
WHERE TO FIND CONFIGURATION FILES
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Kernel configuration files are stored in the kernel GIT repository. When
|
|
Michal Marek |
11905e |
packing up the repository, they end up in config.tar.bz2.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The kernel-$FLAVOR packages are based on config/$ARCH/$FLAVOR.
|
|
Michal Marek |
11905e |
(kernel-default is based on config/$ARCH/default, for example). The
|
|
Michal Marek |
11905e |
kernel-$FLAVOR packages install their configuration files as
|
|
Michal Marek |
11905e |
/boot/config-$VER_STR (for example, /boot/config-2.6.5-99-default). The
|
|
Michal Marek |
11905e |
config is also packaged in the kernel-$FLAVOR-devel package as
|
|
Michal Marek |
11905e |
/usr/src/linux-obj/$ARCH/$FLAVOR/.config.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
In addition, the running kernel exposes a gzip compressed version of its
|
|
Michal Marek |
11905e |
configuration file as /proc/config.gz. The kernel sources can be
|
|
Takashi Iwai |
17a207 |
configured based on /proc/config.gz with ``make silentoldconfig''.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
HOW TO CONFIGURE THE KERNEL SOURCES
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Before a binary kernel is built or an additional loadable module
|
|
Michal Marek |
11905e |
for an existing kernel is created, the kernel must be configured.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
In order for a loadable module to work with an existing kernel, it must
|
|
Michal Marek |
11905e |
be created with a configuration that is identical to the kernel's
|
|
Michal Marek |
11905e |
configuration, or at least very close to that. Each configuration is
|
|
Michal Marek |
11905e |
contained in a single file. The kernel-syms package installs
|
|
Michal Marek |
11905e |
configurations for all standard SUSE kernel variants, so for building
|
|
Michal Marek |
11905e |
only external kernel modules it is not necessary to configure the kernel
|
|
Michal Marek |
11905e |
sources.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Configuring the kernel sources for a specific configuration is
|
|
Michal Marek |
11905e |
straightfoward:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
- Locate the configuration file you want to use. (See WHERE TO FIND
|
|
Michal Marek |
11905e |
CONFIGURATION FILES above).
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
- Copy the configuration to the file .config in your build directory.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
- Run the following commands in sequence to apply the configuration,
|
|
Michal Marek |
11905e |
generate version information files, etc.:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
make -C /usr/src/linux O=$PWD clean
|
|
Michal Marek |
11905e |
make -C /usr/src/linux O=$PWD oldconfig
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Alternatively to ``make oldconfig'', you can also use ``make
|
|
Michal Marek |
11905e |
menuconfig'' for a text menu oriented user interface. If the kernel
|
|
Michal Marek |
11905e |
sources do not match the configuration file exactly, ``make
|
|
Michal Marek |
11905e |
oldconfig'' will prompt for settings that are undefined. Once this
|
|
Michal Marek |
11905e |
step is completed, a Makefile will have been created that eliminates
|
|
Michal Marek |
11905e |
the need to specify the locations of the kernel source and the build
|
|
Michal Marek |
11905e |
directory.
|
|
Michal Marek |
11905e |
|
|
Michal Suchanek |
3371ad |
For configuring the kernel to match the running kernel, you can use
|
|
Michal Suchanek |
3371ad |
the file /proc/config.gz, unpack it into into .config, and then run
|
|
Michal Suchanek |
3371ad |
``make oldconfig''.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
HOW TO ADD CUSTOM PATCHES
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Typically patches are added to the appropriate patches.* directory (e.g.
|
|
Michal Marek |
11905e |
patches.fixes) and to series.conf. When the kernel-source package is
|
|
Michal Marek |
11905e |
exported from the git repository, the patch will be automatically added
|
|
Michal Marek |
11905e |
to the appropriate patch tarball.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
If your goal is to create a kernel with only a few additional patches
|
|
Michal Marek |
11905e |
and you don't want to be bothered with using the git repository, there
|
|
Michal Marek |
11905e |
is an easier way.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
The kernel-source SRPM ships with two empty archives that can be be
|
|
Michal Marek |
11905e |
filled and automatically expanded when building the kernel. You can use
|
|
Michal Marek |
11905e |
these to add your own patches and config options without disturbing the
|
|
Michal Marek |
11905e |
rest of the kernel package. This is useful if you are using the openSUSE
|
|
Michal Marek |
11905e |
Build Service and link to the main kernel-source project instead of
|
|
Michal Marek |
11905e |
creating your own branch. The advantage to this is that your project
|
|
Michal Marek |
11905e |
will automatically receive all the changes that go into the main project
|
|
Michal Marek |
11905e |
without any further effort.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
To add a patch using this mechanism, just add it to the
|
|
Michal Marek |
11905e |
patches.addon.tar.bz2 archive and add an entry to the series.conf file.
|
|
Michal Marek |
11905e |
The archive will be expanded automatically with the other kernel patches
|
|
Michal Marek |
11905e |
when the source tree is constructed.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Some patches may add new Kconfig options. The config.addon.tar.bz2
|
|
Michal Marek |
11905e |
archive contains the same hierarchy as config.tar.bz2, but is under
|
|
Michal Marek |
11905e |
config.addon. You can add your new config options to files named after
|
|
Michal Marek |
11905e |
their config/ counterparts.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
For example, the file used to configure the i386 default kernel is named
|
|
Michal Marek |
11905e |
config/i386/default. To add config options to that kernel, you would
|
|
Michal Marek |
11905e |
create a new file called config.addon/i386/default with the options as
|
|
Michal Marek |
11905e |
formatted in a normal Linux kernel .config file. This is important
|
|
Michal Marek |
11905e |
because the kernel build is non-interactive and will fail if it
|
|
Michal Marek |
11905e |
encounters new config options without entries in the config file.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
MODULE LOAD PATHS
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Modules that belong to a specific kernel release are installed in
|
|
Michal Marek |
11905e |
/lib/modules/2.6.5-99-smp and similar. Note that this path contains the
|
|
Michal Marek |
11905e |
kernel package release number. Modules from KMPs must be installed
|
|
Michal Marek |
11905e |
below /lib/modules/2.6.5-99-smp/updates/ and similar: modules below
|
|
Michal Marek |
11905e |
updates/ have priority over other modules.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
When KMPs contain modules that are compatible between multiple installed
|
|
Michal Marek |
11905e |
kernels, symlinks are used to make those modules available to those
|
|
Michal Marek |
11905e |
compatible kernels like this:
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
/lib/modules/2.6.16-100-smp/weak-updates/foo.ko ->
|
|
Michal Marek |
11905e |
/lib/modules/2.6.16-99-smp/updates/foo.ko
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Modules in the weak-updates directory have lower priority than modules
|
|
Michal Marek |
11905e |
in /lib/modules/2.6.16-100-smp/updates/, and higher priority than other
|
|
Michal Marek |
11905e |
modules in /lib/modules/2.6.16-100-smp.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
REFERENCES
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
General
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Documentation in the kernel source tree.
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Linux Documentation Project, http://www.tldp.org/
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Linux Weekly News, http://lwn.net
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Rusty's Remarkably Unreliable Guides (Kernel Hacking
|
|
Michal Marek |
11905e |
and Kernel Locking guides),
|
|
Michal Marek |
11905e |
http://www.netfilter.org/unreliable-guides/
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Kernel newbies, http://www.kernelnewbies.org/
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Loadable Kernel Modules
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Peter Jay Salzman and Ori Pomerantz: Linux Kernel Module
|
|
Michal Marek |
11905e |
Programming Guide, Version 2.4, April 2003,
|
|
Michal Marek |
11905e |
http://www.tldp.org/guides.html
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Kernel Module Packages
|
|
Michal Marek |
11905e |
|
|
Michal Marek |
11905e |
Andreas Gruenbacher: Kernel Module Packages Manual.
|
|
Michal Marek |
11905e |
Versions for CODE9 (SLES9, SUSE LINUX 10.0) and CODE10
|
|
Michal Marek |
11905e |
(SUSE Linux 10.1, SLES10),
|
|
Libor Pechacek |
9ab365 |
https://drivers.suse.com/doc/kmpm/
|