To check for kernel headers and install them if necessary on SUSE and OpenSUSE systems, perform the following steps.

When they are properly installed, the required kernel headers are located under /usr/src/linux-$(uname -r | sed "s/-default//")/include/.

Prerequisites

Check BPF-based Sensor Requirements

Procedure

  1. To determine whether kernel headers are installed, run the following command:
    $ sudo zypper search -si kernel-default-devel | grep $(uname -r | sed "s/-default//")

    If the package is installed, the output will be similar to the following. An i or i+ in the left column signifies that the package is installed.

    i+ kernel-default-devel | package | <version> | <arch> | <repository>

  2. To determine whether the kernel headers are available to install, run the following command:
    $ sudo zypper search -s kernel-default-devel | grep $(uname -r | sed "s/-default//")

    If the package is available, the output will be similar to the following. A v in the left column signifies that the package is available.

    v kernel-default-devel | package | 4.12.14-lp150.12.25.1 | x86_64 | openSUSE-Leap-15.0-Update

  3. To install any necessary available kernel headers, run the following command:
    $ sudo zypper install --oldpackage kernel-default-devel=$(uname -r | sed "s/-default//")
  4. If the kernel headers packages are not installed and are not available, update the kernel to a supported version and install the matching kernel headers.
    Note: This action requires a reboot.
    1. To list the available kernel and kernel header packages and find matching versions, run the following command:
      $ sudo zypper search -s kernel-default kernel-default-devel | egrep "(^v|^S)"

      If newer packages are available, the output will be similar to the following:

      S Name Type Version Arch Repository
      v kernel-default package <newer-version> <arch> <repo>
      ...
      v kernel-default-devel package <newer-version> <arch> <repo>
    2. To install a newer supported kernel and kernel header packages with matching versions, run the following command:
      % sudo zypper install kernel-default=<newer-version> kernel-default-devel=<newer-version>
    3. Reboot into the new kernel.
    Note: If you cannot find a newer kernel to upgrade to by following this method, you might need to upgrade to a newer service pack or migrate to a newer release.