|
Bernhard M. Wiedemann |
878168 |
Working with the SUSE Kernel Sources
|
|
Bernhard M. Wiedemann |
878168 |
====================================
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
This document gives an overview of how SUSE Linux kernels are created, and
|
|
Bernhard M. Wiedemann |
878168 |
describes tasks like building individual kernels and creating external kernel
|
|
Bernhard M. Wiedemann |
878168 |
modules.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Overview
|
|
Bernhard M. Wiedemann |
878168 |
--------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The SUSE kernels are generated from the upstream Linux kernel sources found at
|
|
Bernhard M. Wiedemann |
878168 |
<https://kernel.org/>, on top of which a number of patches are applied. The
|
|
Bernhard M. Wiedemann |
878168 |
expanded kernel source tree is configured and built, resulting in a binary
|
|
Bernhard M. Wiedemann |
878168 |
kernel.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The add-on patches and configuration files are maintained in a Git repository at
|
|
Bernhard M. Wiedemann |
878168 |
<https://github.com/SUSE/kernel-source>, with an alternative mirror at
|
|
Bernhard M. Wiedemann |
878168 |
<https://github.com/openSUSE/kernel-source>.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A script named `scripts/tar-up.sh` packs up the files in the repository in a
|
|
Bernhard M. Wiedemann |
878168 |
form suitable for rpmbuild. When building the RPM packages, the following
|
|
Bernhard M. Wiedemann |
878168 |
binary packages get created:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* kernel-source
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The kernel source tree, generated by unpacking the vanilla kernel sources and
|
|
Bernhard M. Wiedemann |
878168 |
applying the patches. The kernel sources are used by a number of other
|
|
Bernhard M. Wiedemann |
878168 |
packages. They can also be used for compiling additional kernel modules.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* kernel-devel
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A complement of the kernel-source package that is needed to build external
|
|
Bernhard M. Wiedemann |
878168 |
modules.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* kernel-`$FLAVOR`
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A number of binary kernels, for example, kernel-default for standard use,
|
|
Bernhard M. Wiedemann |
878168 |
kernel-debug with extra debugging features, etc. These packages are all
|
|
Bernhard M. Wiedemann |
878168 |
generated from the same kernel sources, and differ in the kernel
|
|
Bernhard M. Wiedemann |
878168 |
configurations used.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* kernel-`$FLAVOR`-base
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A subset of kernel-`$FLAVOR`, for use in virtualized guests that only require
|
|
Bernhard M. Wiedemann |
878168 |
a few device and filesystem drivers.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* kernel-`$FLAVOR`-devel
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The files used for generating kernel module packages for use with
|
|
Bernhard M. Wiedemann |
878168 |
kernel-`$FLAVOR`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* kernel-syms
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A meta package that pulls in the relevant kernel-`$FLAVOR`-devel packages for
|
|
Bernhard M. Wiedemann |
878168 |
a given architecture.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The repository contains configuration files (`.config`) for all SUSE kernel
|
|
Bernhard M. Wiedemann |
878168 |
flavors. All configuration files are included in the dependencies of the
|
|
Bernhard M. Wiedemann |
878168 |
kernel-syms package, see [Where to find configuration
|
|
Bernhard M. Wiedemann |
878168 |
files](#where-to-find-configuration-files) below.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
In the installed system, the kernel-source package installs files in the
|
|
Bernhard M. Wiedemann |
878168 |
following directories:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* `/usr/src/linux-$VERSION-$RELEASE/`
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The kernel sources.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* `/usr/src/linux`
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A symbolic link to `/usr/src/linux-$VERSION-$RELEASE/`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* `/usr/share/doc/packages/kernel-source-$VERSION-$RELEASE/`
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
This document.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The kernel-`$FLAVOR`-devel packages install the following files:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* `/usr/src/linux-$VERSION-$RELEASE-obj/$ARCH/$FLAVOR/`
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Kernel build object files for one kernel flavor. These files are used for
|
|
Bernhard M. Wiedemann |
878168 |
compiling additional kernel modules.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* `/usr/src/linux-obj/$ARCH/$FLAVOR`
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A symbolic link to `/usr/src/linux-$VERSION-$RELEASE-obj/$ARCH/$FLAVOR/`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Compiling your own kernel
|
|
Bernhard M. Wiedemann |
878168 |
-------------------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The kernel sources are found in the kernel-source package. A binary kernel can
|
|
Bernhard M. Wiedemann |
878168 |
be built from these sources as follows:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
1. Install the kernel-source package.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
2. Create a build directory for use in configuring and building the kernel.
|
|
Bernhard M. Wiedemann |
878168 |
Using `/usr/src/linux/` directly requires root privileges and will cause
|
|
Bernhard M. Wiedemann |
878168 |
problems if you need to build kernel modules for other installed kernels.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
3. Configure the kernel, see [How to configure the kernel
|
|
Bernhard M. Wiedemann |
878168 |
sources](#how-to-configure-the-kernel-sources). For example,
|
|
Bernhard M. Wiedemann |
878168 |
`make -C /usr/src/linux O=$PWD oldconfig`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
4. Build the kernel and all its modules by invoking `make`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
5. Make sure that `/etc/modprobe.d/10-unsupported-modules.conf` contains
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
allow_unsupported_modules 1
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
otherwise modprobe will refuse to load any modules.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
6. Install the modules and kernel: `make modules_install`, followed by
|
|
Bernhard M. Wiedemann |
878168 |
`make install`. This automatically creates an initrd for the new kernel and
|
|
Bernhard M. Wiedemann |
878168 |
adds an entry to the GRUB boot menu.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Instead of building binary kernels by hand, you can also build one of the
|
|
Bernhard M. Wiedemann |
878168 |
kernel-`$FLAVOR` packages using RPM.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Building additional (external) modules
|
|
Bernhard M. Wiedemann |
878168 |
--------------------------------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A single binary kernel module generally only works for a specific version of the
|
|
Bernhard M. Wiedemann |
878168 |
kernel source tree, for a specific architecture and configuration. This means
|
|
Bernhard M. Wiedemann |
878168 |
that for each binary kernel that SUSE ships, a custom module must be built. This
|
|
Bernhard M. Wiedemann |
878168 |
requirement is to some extent relaxed by the modversion mechanism: modversions
|
|
Bernhard M. Wiedemann |
878168 |
attach a checksum to each symbol (function or variable) exported to modules by
|
|
Bernhard M. Wiedemann |
878168 |
the kernel. This allows to use kernel modules that have been built for a kernel
|
|
Bernhard M. Wiedemann |
878168 |
with a different version or release number in many cases, as long as none of the
|
|
Bernhard M. Wiedemann |
878168 |
symbols the module uses have changed between the two kernel versions.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
When releasing maintenance or security update kernels for a specific product, we
|
|
Bernhard M. Wiedemann |
878168 |
carefully try to keep the kernel ABI stable. Despite this, we sometimes have no
|
|
Bernhard M. Wiedemann |
878168 |
choice but to break binary compatibility. In this case, those kernel modules
|
|
Bernhard M. Wiedemann |
878168 |
must be rebuilt.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Additional kernel modules for one of the SUSE kernel flavors can be built in the
|
|
Bernhard M. Wiedemann |
878168 |
following ways:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
1. by doing an ad-hoc module build, using one of the standard configurations in
|
|
Bernhard M. Wiedemann |
878168 |
`/usr/src/linux-obj/$ARCH/$FLAVOR`, or
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
2. by creating a Kernel Module Package (KMP) as described in the Kernel Module
|
|
Bernhard M. Wiedemann |
878168 |
Packages Manual,
|
|
Bernhard M. Wiedemann |
878168 |
<https://documentation.suse.com/sbp/all/html/SBP-KMP-Manual-SLE12SP2/index.html>.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The first method involves the following steps:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
1. Install the kernel-devel package.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
2. Install the kernel-`$FLAVOR`-devel package. This is necessary for symbol
|
|
Bernhard M. Wiedemann |
878168 |
version information (`CONFIG_MODVERSIONS`).
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
3. Compile the module(s) by changing into the module source directory and typing
|
|
Bernhard M. Wiedemann |
878168 |
`make -C /usr/src/linux-obj/$ARCH/$FLAVOR M=$PWD`. Substitute `$ARCH` and
|
|
Bernhard M. Wiedemann |
878168 |
`$FLAVOR` with the architecture and flavor for which to build the module(s).
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
If the installed kernel sources match the running kernel, you can build
|
|
Bernhard M. Wiedemann |
878168 |
modules for the running kernel by using the path
|
|
Bernhard M. Wiedemann |
878168 |
`/lib/modules/$(uname -r)/build` as the `-C` option in the above command.
|
|
Bernhard M. Wiedemann |
878168 |
(`build` is a symlink to `/usr/src/linux-obj/$ARCH/$FLAVOR`.)
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
4. Install the module(s) with
|
|
Bernhard M. Wiedemann |
878168 |
`make -C /usr/src/linux-obj/$ARCH/$FLAVOR M=$PWD modules_install`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Whenever building modules, please use the kernel build infrastructure as much as
|
|
Bernhard M. Wiedemann |
878168 |
possible, and do not try to circumvent it. The `Documentation/kbuild` directory
|
|
Bernhard M. Wiedemann |
878168 |
in the kernel sources documents kbuild makefiles.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Supported vs. unsupported modules
|
|
Bernhard M. Wiedemann |
878168 |
---------------------------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
As an extension to the mainline kernel, modules can be tagged as supported
|
|
Bernhard M. Wiedemann |
878168 |
(directly by SUSE, or indirectly by a third party) or unsupported. Modules which
|
|
Bernhard M. Wiedemann |
878168 |
are known to be flakey or for which SUSE does not have the necessary expertise
|
|
Bernhard M. Wiedemann |
878168 |
are marked as unsupported. Modules for which SUSE has third-party support
|
|
Bernhard M. Wiedemann |
878168 |
agreements are marked as externally supported. Modules for which SUSE provides
|
|
Bernhard M. Wiedemann |
878168 |
direct support are marked as supported.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The support status of a module can be queried with the modinfo tool. Modinfo
|
|
Bernhard M. Wiedemann |
878168 |
will report one of the following:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* direct support by SUSE: "supported: yes",
|
|
Bernhard M. Wiedemann |
878168 |
* third-party support: "supported: external",
|
|
Bernhard M. Wiedemann |
878168 |
* unsupported modules: no supported tag.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
|
4f2006 |
At runtime, the support status of a module can be obtained by reading
|
|
|
4f2006 |
`/sys/module/$MODULE/supported`.
|
|
|
4f2006 |
|
|
|
4f2006 |
Note that this information is available only if the module was not built
|
|
|
4f2006 |
directly into the kernel. Builtin modules are implicitly supported.
|
|
|
4f2006 |
|
|
|
4f2006 |
The aggregated support status for the entire kernel can be inspected by reading
|
|
|
4f2006 |
`/sys/kernel/supported`. The value is also included in Oopses.
|
|
|
4f2006 |
|
|
|
4f2006 |
The setting of the "unsupported" kernel command line parameter and
|
|
|
4f2006 |
`/proc/sys/kernel/unsupported` controls whether unsupported modules can be
|
|
Bernhard M. Wiedemann |
878168 |
loaded or not, and whether or not loading an unsupported module causes a warning
|
|
Bernhard M. Wiedemann |
878168 |
in the system log:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* 0 = only allow supported modules,
|
|
Bernhard M. Wiedemann |
878168 |
* 1 = warn when loading unsupported modules,
|
|
Bernhard M. Wiedemann |
878168 |
* 2 = don't warn.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
|
4f2006 |
Irrespective of this setting, loading an unsupported module sets a kernel taint
|
|
|
4f2006 |
flag. The taint status of the kernel can be inspected in
|
|
|
4f2006 |
`/proc/sys/kernel/tainted`. The taint flags are also included in Oopses.
|
|
Bernhard M. Wiedemann |
878168 |
Relevant bits have the following meaning:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
| Bit | Log | Number | Reason that got the kernel tainted |
|
|
Bernhard M. Wiedemann |
878168 |
|----:|----:|-----------:|----------------------------------------------------|
|
|
Bernhard M. Wiedemann |
878168 |
| 0 | G/P | 1 | proprietary module was loaded |
|
|
Bernhard M. Wiedemann |
878168 |
| 12 | ␣/O | 4096 | externally-built ("out-of-tree") module was loaded |
|
|
Bernhard M. Wiedemann |
878168 |
| 13 | ␣/E | 8192 | unsigned module was loaded |
|
|
Bernhard M. Wiedemann |
878168 |
| 16 | ␣/X | 65536 | module with third-party support was loaded |
|
|
Bernhard M. Wiedemann |
878168 |
| 31 | ␣/N | 2147483648 | unsupported module was loaded |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
|
4f2006 |
Bits 16 and 31 are specific to the SUSE kernels. Since SLE15-SP6, loading an
|
|
|
4f2006 |
externally supported module does not taint the kernel, but bit 16 (X) is still
|
|
|
4f2006 |
tracked per module and can be read in `/sys/module/$MODULE/taint`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Out-of-tree modules do not have the supported flag set by default; that
|
|
Bernhard M. Wiedemann |
878168 |
is, they are marked as unsupported. For building externally supported
|
|
Bernhard M. Wiedemann |
878168 |
modules, please get in touch with the Solid Driver Program team, led by
|
|
Bernhard M. Wiedemann |
878168 |
Scott Bahling, at <mailto:soliddriver@suse.com>.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Patch selection mechanism
|
|
Bernhard M. Wiedemann |
878168 |
-------------------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The SUSE kernels consist of the upstream kernel sources on top of which a number
|
|
Bernhard M. Wiedemann |
878168 |
of patches is applied. The file `series.conf` determines which patches are
|
|
Bernhard M. Wiedemann |
878168 |
applied and which are excluded. A script named `guards` converts `series.conf`
|
|
Bernhard M. Wiedemann |
878168 |
into a plain list of patch files to be applied. Guards decides which patches to
|
|
Bernhard M. Wiedemann |
878168 |
include and exclude based on a list of symbols. From the kernel-source.src.rpm
|
|
Bernhard M. Wiedemann |
878168 |
package, a fully patched kernel source tree can be generated from vanilla
|
|
Bernhard M. Wiedemann |
878168 |
sources + patches like this:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
1. Install the package:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
# rpm -i kernel-source-$RPMVERSION-$RPMRELEASE.src.rpm
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
2. Unpack the patches and the kernel sources:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
# cd /usr/src/packages/SOURCES/
|
|
Bernhard M. Wiedemann |
878168 |
# for f in patches.*.tar.bz2; do \
|
|
Bernhard M. Wiedemann |
878168 |
tar -xjf "$f" || break; \
|
|
Bernhard M. Wiedemann |
878168 |
done
|
|
Bernhard M. Wiedemann |
878168 |
# tar -xJf linux-$SRCVERSION.tar.xz
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
3. Apply the patches
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
# for p in $(./guards < series.conf); do \
|
|
Bernhard M. Wiedemann |
878168 |
patch -d linux-$SRCVERSION -p1 < $p || break; \
|
|
Bernhard M. Wiedemann |
878168 |
done
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The configuration script `config.conf` which is similar to `series.conf` is
|
|
Bernhard M. Wiedemann |
878168 |
used for configuration file selection, see the section [Where to find
|
|
Bernhard M. Wiedemann |
878168 |
configuration files](#where-to-find-configuration-files).
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The file format of `series.conf` and `config.conf` should be apparent from the
|
|
Bernhard M. Wiedemann |
878168 |
comments in `series.conf` and from the guards(1) manual page. You can generate
|
|
Bernhard M. Wiedemann |
878168 |
this page by running `pod2man` on the `guards` script.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Where to find configuration files
|
|
Bernhard M. Wiedemann |
878168 |
---------------------------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Kernel configuration files are stored in the kernel Git repository. When packing
|
|
Bernhard M. Wiedemann |
878168 |
up the repository, they end up in `config.tar.bz2`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The kernel-`$FLAVOR` packages are based on `config/$ARCH/$FLAVOR`, for instance,
|
|
Bernhard M. Wiedemann |
878168 |
kernel-default is based on `config/$ARCH/default`. The kernel-`$FLAVOR` packages
|
|
Bernhard M. Wiedemann |
878168 |
install their configuration files as `/boot/config-$VERSION-$RELEASE-$FLAVOR`.
|
|
Bernhard M. Wiedemann |
878168 |
The config is also packaged in the kernel-`$FLAVOR`-devel package as
|
|
Bernhard M. Wiedemann |
878168 |
`/usr/src/linux-obj/$ARCH/$FLAVOR/.config`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
In addition, the running kernel exposes a gzip compressed version of its
|
|
Bernhard M. Wiedemann |
878168 |
configuration file as `/proc/config.gz`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
How to configure the kernel sources
|
|
Bernhard M. Wiedemann |
878168 |
-----------------------------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Before a binary kernel is built or an additional loadable module for an existing
|
|
Bernhard M. Wiedemann |
878168 |
kernel is created, the kernel must be configured.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
In order for a loadable module to work with an existing kernel, it must be
|
|
Bernhard M. Wiedemann |
878168 |
created with a configuration that is identical to the kernel's configuration, or
|
|
Bernhard M. Wiedemann |
878168 |
at least very close to that. Each configuration is contained in a single file.
|
|
Bernhard M. Wiedemann |
878168 |
The kernel-syms package installs configurations for all standard SUSE kernel
|
|
Bernhard M. Wiedemann |
878168 |
variants, so for building only external kernel modules it is not necessary to
|
|
Bernhard M. Wiedemann |
878168 |
configure the kernel sources.
|
|
Bernhard M. Wiedemann |
878168 |
|
|
Bernhard M. Wiedemann |
878168 |
Configuring the kernel sources for a specific configuration is straightforward:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* Locate the configuration file you want to use, see [Where to find
|
|
Bernhard M. Wiedemann |
878168 |
configuration files](#where-to-find-configuration-files) above.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* Copy the configuration to the file `.config` in your build directory.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* Run the following commands in sequence to apply the configuration, generate
|
|
Bernhard M. Wiedemann |
878168 |
version information files, etc.:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
$ make -C /usr/src/linux O=$PWD clean
|
|
Bernhard M. Wiedemann |
878168 |
$ make -C /usr/src/linux O=$PWD oldconfig
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
If the kernel sources do not match the configuration file exactly,
|
|
Bernhard M. Wiedemann |
878168 |
`make oldconfig` will prompt for settings that are undefined. When no
|
|
Bernhard M. Wiedemann |
878168 |
`.config` file is initially copied to the target build directory, the command
|
|
Bernhard M. Wiedemann |
878168 |
automatically uses `/boot/config-$(uname -r)` as the starting configuration.
|
|
Bernhard M. Wiedemann |
878168 |
Alternatively to `make oldconfig`, you can also use `make menuconfig` for
|
|
Bernhard M. Wiedemann |
878168 |
a text menu oriented user interface.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Once this step is completed, a `Makefile` will have been created that
|
|
Bernhard M. Wiedemann |
878168 |
eliminates the need to specify the locations of the kernel source and the
|
|
Bernhard M. Wiedemann |
878168 |
build directory.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* Update the configuration appropriately for the target use.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Configuration files for SUSE kernels include settings to integrate with
|
|
Bernhard M. Wiedemann |
878168 |
signing support provided by the Open Build Service. When using such a
|
|
Bernhard M. Wiedemann |
878168 |
configuration file directly, the build might fail due to missing files needed
|
|
Bernhard M. Wiedemann |
878168 |
for signing kernel modules.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The minimal steps to enable module signing and have the kernel build
|
|
Bernhard M. Wiedemann |
878168 |
automatically generate a new key pair are as follows:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
$ ./source/scripts/config --enable CONFIG_MODULE_SIG \
|
|
Bernhard M. Wiedemann |
878168 |
--enable CONFIG_MODULE_SIG_ALL --undefine CONFIG_MODULE_SIG_KEY
|
|
Bernhard M. Wiedemann |
878168 |
$ make olddefconfig
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Please refer to the upstream documentation located at
|
|
Bernhard M. Wiedemann |
878168 |
`/usr/src/linux/Documentation/admin-guide/module-signing.rst` for complete
|
|
Bernhard M. Wiedemann |
878168 |
information on how to configure module signing.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
How to add custom patches
|
|
Bernhard M. Wiedemann |
878168 |
-------------------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Patches are typically added to the `patches.suse/` directory and an appropriate
|
|
Bernhard M. Wiedemann |
878168 |
place in `series.conf`. When the kernel-source package is exported from the Git
|
|
Bernhard M. Wiedemann |
878168 |
repository, the patch will be automatically added to the matching patch tarball.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
If your goal is to create a kernel with only a few additional patches and you
|
|
Bernhard M. Wiedemann |
878168 |
don't want to be bothered with using the Git repository, there is an easier way.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
The kernel-source SRPM ships with two empty archives that can be filled and
|
|
Bernhard M. Wiedemann |
878168 |
automatically expanded when building the kernel. You can use these to add your
|
|
Bernhard M. Wiedemann |
878168 |
own patches and config options without disturbing the rest of the kernel
|
|
Bernhard M. Wiedemann |
878168 |
package. This is useful if you are using the openSUSE Build Service and link to
|
|
Bernhard M. Wiedemann |
878168 |
the main kernel-source project instead of creating your own branch. The
|
|
Bernhard M. Wiedemann |
878168 |
advantage to this is that your project will automatically receive all the
|
|
Bernhard M. Wiedemann |
878168 |
changes that go into the main project without any further effort.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
To add a patch using this mechanism, just add it to the `patches.addon.tar.bz2`
|
|
Bernhard M. Wiedemann |
878168 |
archive and add an entry to a `series` file inside the archive. The archive will
|
|
Bernhard M. Wiedemann |
878168 |
be expanded automatically after the other kernel patches when the source tree is
|
|
Bernhard M. Wiedemann |
878168 |
constructed.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Some patches may add new Kconfig options. The `config.addon.tar.bz2` archive
|
|
Bernhard M. Wiedemann |
878168 |
contains the same hierarchy as `config.tar.bz2`, but is under `config.addon/`.
|
|
Bernhard M. Wiedemann |
878168 |
You can add your new config options to files named after their `config/`
|
|
Bernhard M. Wiedemann |
878168 |
counterparts.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
For example, the file used to configure the x86_64 default kernel is named
|
|
Bernhard M. Wiedemann |
878168 |
`config/x86_64/default`. To add config options to that kernel, you would create
|
|
Bernhard M. Wiedemann |
878168 |
a new file called `config.addon/x86_64/default` with the options as formatted in
|
|
Bernhard M. Wiedemann |
878168 |
a normal Linux kernel `.config` file. This is important because the kernel build
|
|
Bernhard M. Wiedemann |
878168 |
is non-interactive and will fail if it encounters new config options without
|
|
Bernhard M. Wiedemann |
878168 |
entries in the config file.
|
|
Bernhard M. Wiedemann |
878168 |
|
|
Bernhard M. Wiedemann |
878168 |
|
|
Bernhard M. Wiedemann |
878168 |
Module load paths
|
|
Bernhard M. Wiedemann |
878168 |
-----------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
Modules that belong to a specific kernel release are installed in
|
|
Bernhard M. Wiedemann |
878168 |
`/lib/modules/$VERSION-$RELEASE-$FLAVOR/`. Modules from KMPs must be installed
|
|
Bernhard M. Wiedemann |
878168 |
below `/lib/modules/$VERSION-$RELEASE-$FLAVOR/updates/` and similar: modules
|
|
Bernhard M. Wiedemann |
878168 |
below `updates/` have priority over other modules.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
When KMPs contain modules that are compatible between multiple installed
|
|
Bernhard M. Wiedemann |
878168 |
kernels, symlinks are used to make those modules available to those compatible
|
|
Bernhard M. Wiedemann |
878168 |
kernels like this:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
`/lib/modules/$VERSION-$OTHER_RELEASE-$FLAVOR/weak-updates/foo.ko` →
|
|
Bernhard M. Wiedemann |
878168 |
`/lib/modules/$VERSION-$RELEASE-$FLAVOR/updates/foo.ko`
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Modules in the `weak-updates/` directory have lower priority than modules in
|
|
Bernhard M. Wiedemann |
878168 |
`/lib/modules/$VERSION-$OTHER_RELEASE-$FLAVOR/updates/`, and higher priority
|
|
Bernhard M. Wiedemann |
878168 |
than other modules in `/lib/modules/$VERSION-$OTHER_RELEASE-$FLAVOR/`.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Driver update disks
|
|
Bernhard M. Wiedemann |
878168 |
-------------------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
A Driver Update Disk (DUD) is an update archive which makes it possible to use
|
|
Bernhard M. Wiedemann |
878168 |
new device drivers to run installation of an (open)SUSE distribution. It allows
|
|
Bernhard M. Wiedemann |
878168 |
to install the distribution on devices that were not supported at the time the
|
|
Bernhard M. Wiedemann |
878168 |
distribution was created and be able to boot the installed system afterwards
|
|
Bernhard M. Wiedemann |
878168 |
without having to manually install the new device drivers after the
|
|
Bernhard M. Wiedemann |
878168 |
installation.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
For information how to create such an update, refer to the mkdud and mksusecd
|
|
Bernhard M. Wiedemann |
878168 |
tools, and their documentation:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* <https://github.com/openSUSE/mkdud>,
|
|
Bernhard M. Wiedemann |
878168 |
* <https://github.com/openSUSE/mksusecd>.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
References
|
|
Bernhard M. Wiedemann |
878168 |
----------
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
General:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* Documentation in the kernel source tree,
|
|
Bernhard M. Wiedemann |
878168 |
* LWN.net (Linux Weekly News), <https://lwn.net/>,
|
|
Bernhard M. Wiedemann |
878168 |
* Kernel newbies, <https://kernelnewbies.org/>.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Loadable kernel modules:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* Peter Jay Salzman, Michael Burian, Ori Pomerantz: The Linux Kernel Module
|
|
Bernhard M. Wiedemann |
878168 |
Programming Guide, Version 2.6,
|
|
Bernhard M. Wiedemann |
878168 |
<https://tldp.org/LDP/lkmpg/2.6/html/index.html>.
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
Kernel module packages:
|
|
Bernhard M. Wiedemann |
6ebc4a |
|
|
Bernhard M. Wiedemann |
878168 |
* Kernel Module Packages Manual, SUSE Linux Enterprise 12 SP2 or later and SUSE
|
|
Bernhard M. Wiedemann |
878168 |
Linux Enterprise 15,
|
|
Bernhard M. Wiedemann |
878168 |
<https://documentation.suse.com/sbp/all/html/SBP-KMP-Manual-SLE12SP2/index.html>,
|
|
Bernhard M. Wiedemann |
878168 |
* SUSE SolidDriver Program, <https://drivers.suse.com/doc/SolidDriver/>.
|