Skip to content

Installing a New Kernel

Yotam Gigi edited this page Feb 28, 2017 · 24 revisions
Table of Contents
  1. The Kernel Development Process
  2. Updating Kernel Using dnf
  3. Using Stable Kernels
  4. Building Kernels From Source
  5. Kernel Options
  6. Installing iproute2
  7. Installing from Source
  8. 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 bugfixes.

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 kernel gets only few bugfixes during its lifetime, which usually lasts for 2-3 months. See this page for more information about Linux kernel releases.

Updating Kernel Using `dnf` ---------------------------

The Linux distribution shipped with the switch is a Fedora Remix with a Fedora Rawhide Kernel. 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.

dnf is the package manager used in the Fedora project. It allows managing and updating different packages, including the kernel.

To update to a newer version of the 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

To update the kernel, run:

$ dnf update kernel
$ reboot
#### Using Stable Kernels

In addition to the mainline tree, which the Rawhide kernel tracks, there is also a stable tree used for stable versions of the kernel. Whenever mainline is released (after the last release candidate), it is considered stable. Bug fixes sent to the mainline tree are backported and applied to the stable tree. See this page for more information about Linux kernel releases.

Stable kernels can be obtained from several places:

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

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 the patch on the currently running kernel.

The following instructions refer to the Fedora Rawhide kernel. However, the same instructions 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 to apply 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 to the kernel directory and start compiling. Run:

$ cp fedora/configs/kernel-<version>-<arch>.config .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

In case a configuration file isn't already available, then it needs to be created manually. Run:

$ make menuconfig

At minimum, the following configuration options should be set:

CONFIG_NET_SWITCHDEV=y
CONFIG_NET_DEVLINK=y
CONFIG_MLXSW_CORE=m
CONFIG_MLXSW_CORE_HWMON=y
CONFIG_MLXSW_PCI=m
CONFIG_MLXSW_SWITCHX2=m
CONFIG_MLXSW_SPECTRUM=m
CONFIG_MLXSW_SPECTRUM_DCB=y
CONFIG_LEDS_MLXCPLD=m
CONFIG_NET_CLS=y
CONFIG_NET_CLS_ACT=y
CONFIG_NET_ACT_MIRRED=m
CONFIG_NET_CLS_MATCHALL=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 is still in development and only available from source. Unless features from this release are needed, it's perfectly fine to use the latest official release.

#### Installing from Source

Clone the iproute2 repository:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git

Compile and install:

$ cd iproute2/
$ make && make install

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

Further Resources -----------------
  1. A 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