44

My thinking was that all Linux distributions used one kernel (the one developed by Linus Torvalds).

So why do all Linux distributions have their own kernel?

0
89

There is a project, started and headed by Linus Torvalds, that maintains the source code for a kernel called the Linux kernel. This is what's distributed at kernel.org. Note that this is not a kernel, it's source code — in the same way that a recipe for a cake is not itself a cake.

To make a cake, you have to follow the recipe step by step, mix ingredients, and bake. To make a kernel, you have to configure the source code for your computer and compile it. Depending on your target architecture and the configuration you choose (and there are a lot of configuration options), you wind up with different kernels. Not wildly different, but different.

Further, the Linux kernel project is open-source. It's allowed and encouraged for everyone to get their own copy of the source code, to modify it for their own use, and to distribute their own modified copy — much like you may have inherited your grandma's cake recipe that she adapted from an old cookbook, and you may have your own personal variations.

While most people aren't hacking on their own personal version of the kernel source code, distribution projects like Ubuntu, Fedora, Slackware, etc., distribute their own modified versions of the Linux kernel. Often, the modifications are simple: backported bug fixes from more recent versions of the “upstream” kernel and security fixes that haven't made it into the upstream kernel yet. But they can be whatever the distribution project thinks would make their version “better,” for that project's definition of “better.”

So that's why we talk about the “Ubuntu kernel” as something separate from the “Linux kernel” — because it really is different. The Ubuntu kernel is maintained by Canonical. It's built on the Debian kernel, which is itself a distribution of the Linux kernel. I don't know all the differences between the Ubuntu kernel and the Linux kernel. (Not because it's secret, but because I'm just not aware.) I think this page lists a bunch, and here are the patches for the Debian kernel.

In the end, all the kernels are basically the same, and that's why we talk about them all as Linux. It's in no one's interest to change their kernel so much that it's wildly incompatible. Distributions differ much more in the variety of programs that they distribute along with their kernel to create an entire operating system.

3
  • 6
    "there are a lot of configuration options" is an understatement. Windows device drivers are typically separate entities, while in Linux they are frequently built into the kernel (though I think less so these days than a decade or so ago). So... do you need I2C support? IDE support? CAN-BUS support? Virtualization support? What CPU architecture are you targeting (even within amd64 there are several variations)? "The kernel contains almost two thousand different configuration options" (emphasis added).
    – Matthew
    Aug 3 at 13:13
  • 1
    TL;DR: Ubuntu kernel = vanilla Linux kernel + collection of patches by Canonical Aug 4 at 9:57
  • 2
    Just to add a comment that supports this - Docker and other containerisation systems use the host kernel for all kernel-level interactions by containers, which means that you can be running Debian, Ubuntu, Slack, Arch etc based containers on a Redhat host for example. And they will work (with minimal edge cases you have to actually hunt for). Because the kernels are essentially compatible at a specific level, and thats the level containerisation works at. If different distributions kernels weren't compatible, you couldn't run an Ubuntu-based container on anything other than Ubuntu.
    – Moo
    Aug 4 at 22:13
12

Somewhat oversimplified:

There is one Linux Kernel, but development is ongoing. If you take snapshots several weeks apart, you will find slight differences.

Different Linux distributions take their snapshots at different times, and each has the option to add their own secret sauce. More slight differences.

7

When you visit kernel.org, you'll see that there are several different kernel versions.

In short they are:

  • Mainline: The development kernel Linus is maintaining.
  • Stable: The latest stable branch.
  • Longterm: Older kernel versions with backported security fixes.

Ubuntu kernels generally follow the same principle. When a version of Ubuntu is released, it generally sticks to the kernel version that was "stable" at the time of release (and then become "longterm" supported in that version of Ubuntu).

For instance, the 18.04 release (Bionic) is on the 4.15 kernel branch, and 20.04 (Focal) is on the 5.4 kernel branch.

Later in a release cycle, there might be "HWE" (hardware enablement) kernels available, which is on a newer branch (for instance Focal HWE is on the 5.8 branch). This is all part of the Ubuntu kernel ecosystem, to give more choices to its users.

In addition, there are different kernel builds for different platforms (cloud and barebone) - for instance Azure, AWS, KVM, Raspi, RiscV etc.

This (rather nerdy) mapping table show which Ubuntu kernels correspond to the mainline kernel versions. Different kernel packages can also be found on the Ubuntu package lists.

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.