Skip to content

Installing a New Kernel

Ido Schimmel edited this page Sep 18, 2019 · 24 revisions
Table of Contents
  1. The Kernel Development Process
  2. Updating Fedora Kernel Using dnf
    1. Using Rawhide Kernels
  3. Building Kernels From Source
    1. Kernel Options
  4. Installing iproute2
    1. Installing from Source
  5. Further Resources

The Kernel Development Process

Knowing what to expect from each new kernel version requires understanding the kernel's development process. The netdev-FAQ in the kernel's documentation already does a good job explaining that:

Each new release starts off with a two week "merge window" where the main
maintainers feed their new stuff to Linus for merging into the mainline tree.
After the two weeks, the merge window is closed, and it is called/tagged "-rc1".
No new features get mainlined after this -- only fixes to the rc1 content are
expected.  After roughly a week of collecting fixes to the rc1 content, rc2 is
released.  This repeats on a roughly weekly basis until rc7 (typically;
sometimes rc6 if things are quiet, or rc8 if things are in a state of churn),
and a week after the last vX.Y-rcN was done, the official "vX.Y" is released.

Relating that to netdev:  At the beginning of the 2-week merge window, the
net-next tree will be closed - no new changes/features.  The accumulated new
content of the past ~10 weeks will be passed onto mainline/Linus via a pull
request for vX.Y -- at the same time, the "net" tree will start accumulating
fixes for this pulled content relating to vX.Y
...

Shortly after the two weeks have passed (and vX.Y-rc1 is released), the tree for
net-next reopens to collect content for the next (vX.Y+1) release.
...

The "net" tree continues to collect fixes for the vX.Y content, and is fed back
to Linus at regular (~weekly) intervals.  Meaning that the focus for "net" is on
stabilization and bug fixes.

Finally, the vX.Y gets released, and the whole cycle starts over.

The aforementioned net-next tree is the git repository to which new features in the driver and networking infrastructure are submitted before showing up in the mainline tree. Similarly, the net tree accumulates related fixes. After each mainline kernel is released, it is considered stable, and while the mainline kernel keeps getting new features, the stable tree gets only bug fixes during its lifetime, which usually lasts for 2-3 months. See this page for more information about Linux kernel releases.

Updating Fedora Kernel Using dnf

The Fedora kernel team keeps updating the kernel package with both bug fixes and newer stable versions using the fedora and updates package repositories.

To update to a newer Fedora kernel, use the dnf tool, which is the package manager used in the Fedora project. It allows managing and updating different packages, including the kernel.

To update the entire system including the kernel, run:

$ dnf --refresh update
$ reboot

Stable kernels can be obtained from several other places:

Note: The features described in these documents refer to the mainline tree. Not all features are present in stable kernels. Refer to the Home page for features by version.

Using Rawhide Kernels

Rawhide kernels are built by the Fedora kernel team on an almost daily basis and track the mainline tree. Using the mainline tree provides the best balance between new features and stability. Keep in mind that new features were already present in the net-next tree for a few weeks prior to their inclusion in mainline.

To install a Rawhide kernel, the following dnf package repository is needed:

$ dnf config-manager --add-repo=http://alt.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/fedora-rawhide-kernel-nodebug.repo

Then, run the following commands to update the entire system including the kernel which will be taken from the Rawhide repository:

$ dnf --refresh update
$ reboot

Building Kernels From Source

As mentioned above, bug fixes sent to the net tree are sent on a weekly basis to the mainline tree. However, if a critical bug is found and a fix is not yet available in mainline, it is possible to apply a patch on the currently running kernel.

The following instructions refer to the Fedora Rawhide kernel. However, the same instructions may also apply for upstream kernels.

Clone the Fedora kernel git tree. Run:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/jwboyer/fedora.git
$ cd fedora

Determine the version of the currently running kernel. Run:

$ uname -r
4.6.0-0.rc3.git1.1.fc25.x86_64

Check out the tag corresponding to the kernel version. Run:

$ git checkout -b some-branch kernel-4.6.0-0.rc3.git1.1.fc25

Assuming the patch is called 0001-mlxsw-Bug-fix.patch, copy it to the kernel directory and apply it. Run:

$ cp ~/0001-mlxsw-Bug-fix.patch .
$ git am 0001-mlxsw-Bug-fix.patch

Copy the configuration file of the currently running kernel and start compiling. Run:

$ cp /boot/config-<version>.<arch> .config
$ make -j`nproc`

Note: This configuration file includes debug options and is mainly meant to be used until the bug fix appears in mainline. Alternatively, the existing configuration file located at /boot/config-$(uname -r) can be used.

It is useful to edit the CONFIG_LOCALVERSION value in the .config file and give it some indicative name to differentiate it from other kernels on the system.

Finally, install the kernel and associated modules. Run:

$ make modules_install && make install
$ reboot

Kernel Options

If a configuration file is not already available, then it must be created manually. Run:

$ make menuconfig

At a minimum, the following configuration options should be set:

CONFIG_NET_IPIP=m
CONFIG_NET_IPGRE_DEMUX=m
CONFIG_NET_IPGRE=m
CONFIG_IPV6_GRE=m
CONFIG_IP_MROUTE_MULTIPLE_TABLES=y
CONFIG_IP_MULTIPLE_TABLES=y
CONFIG_IPV6_MULTIPLE_TABLES=y
CONFIG_BRIDGE=m
CONFIG_VLAN_8021Q=m
CONFIG_BRIDGE_VLAN_FILTERING=y
CONFIG_BRIDGE_IGMP_SNOOPING=y
CONFIG_NET_SWITCHDEV=y
CONFIG_NET_DEVLINK=y
CONFIG_MLXFW=m
CONFIG_MLXSW_CORE=m
CONFIG_MLXSW_CORE_HWMON=y
CONFIG_MLXSW_CORE_THERMAL=y
CONFIG_MLXSW_PCI=m
CONFIG_MLXSW_I2C=m
CONFIG_MLXSW_MINIMAL=y
CONFIG_MLXSW_SWITCHX2=m
CONFIG_MLXSW_SPECTRUM=m
CONFIG_MLXSW_SPECTRUM_DCB=y
CONFIG_LEDS_MLXCPLD=m
CONFIG_NET_SCH_PRIO=m
CONFIG_NET_SCH_RED=m
CONFIG_NET_SCH_INGRESS=m
CONFIG_NET_CLS=y
CONFIG_NET_CLS_ACT=y
CONFIG_NET_ACT_MIRRED=m
CONFIG_NET_CLS_MATCHALL=m
CONFIG_NET_CLS_FLOWER=m
CONFIG_NET_ACT_GACT=m
CONFIG_NET_ACT_MIRRED=m
CONFIG_NET_ACT_SAMPLE=m
CONFIG_NET_ACT_VLAN=m
CONFIG_NET_L3_MASTER_DEV=y
CONFIG_NET_VRF=m

Installing iproute2

iproute2 is the recommended set of utilities for Linux networking configuration. A new version is released together with official releases of the Linux kernel (e.g. 4.5, 4.6). In turn, these releases are packaged by the different distributions and made available via package managers (such as dnf).

Therefore, if a release candidate is used (e.g. 4.6-rc5), its matching iproute2 release may still be in development and only available from source. Unless features from this release are needed, it is perfectly fine to use the latest official release.

Installing from Source

Clone the iproute2 repository. Run:

$ git clone git://git.kernel.org/pub/scm/network/iproute2/iproute2.git

Compile and install. Run:

$ cd iproute2/
$ make && make install

Note: When using a net-next kernel iproute2-next should be used.

Further Resources

  1. Guide To The Kernel Development Process
  2. Building a custom kernel
  3. Building and adding patches to the Fedora kernel
  4. Grabbing kernel patches from mailing lists and the internet
Clone this wiki locally