Linux Kernel Update – How to Without Changing System

dependencieslinux-kernel

I'm an OpenBSD user. In the OpenBSD FAQ it says:

OpenBSD is a complete system, intended to be kept in sync. It is not a kernel plus utilities that can be upgraded separately from each other.

When you upgrade a system, you do so in one go; the kernel and the base system is replaced. Then you go and update your 3rd party packages. If compiling from source, you recompile the kernel and boot it. Then you rebuild the base system, and then the packages that you've got installed. If more than a couple of weeks/months have past since you last rebuilt everything, you first install a snapshot and rebuild from there (if you're following the most current CVS branch).

Having an out of sync kernel, base system and/or 3rd party packages is a potential source of issues and more or less disqualifies you from getting any serious help from the official mailing lists.

I'm quite okay with this. In fact, this is one of the reasons I use OpenBSD. It makes the system a consistent unit and it makes it easy for me to form a mental overview of it.

What's it like on Linux? Most Linuxes that I'm aware of don't have a "base system" in the same sense as the BSDs, but rather a collection of packages assembled by the distribution provider. Further software is then added to this by a local administrator in such a way that the boundary between what was there from the start and what was added later is, at best, blurry.

Does Linux (in general) not have a strong kernel to userspace coupling? The kernel is updated, as far as I know, like any other software package, and it confuses me slightly that this is at all possible. Add to this the fact that some even compile custom kernels (which is discouraged on OpenBSD), and have a multitude of various kernel versions listed in their boot menus.

Who or what guarantees that the various subsystems of a Linux system are able to cooperate with each other even though they are updated independently from each other?

The reason I'm asking is because another user on this site asked me whether replacing the kernel in his Linux system with a newer version "would be doable". Coming from the OpenBSD side of things, I couldn't say that yes, this would be guaranteed to not break the system.


I use "Linux" above as a shorthand for "Linux distribution", kernel + utilities.

Best Answer

Linus Torvalds has a very strong opinion against kernel changes resulting in userspace regressions (see the question "The Linux kernel: breaking user space" for details).

Interface between userspace and kernel is provided by system calls. Newer kernels can have more system calls, and changes in exiting ones when those changes do not break existing applications. When a system call interface has a flag parameter, new kernels often expose the new functionality with a new bit flag. This way kernel maintains backwards compatibility to old applications.

When it has not been possible to alter existing interface without breaking userspace, additional system calls have been added that provide the extended functionality. This is why there are three versions of dup and two versions of umount system call.

The policy of having a stable userspace is the reason why kernel updates rarely cause issues in userspace applications and you do not generally expect issues after upgrading the kernel.

However same API stability is not guaranteed for kernel interfaces and other implementation details. Sysfs (on /sys) and procsfs (on /proc/) expose kernel implementation details on runtime configuration, hardware, network, processes etc. which are used by low-level applications. It is possible for those interfaces to change in an incompatible way between kernel versions if there is a good reason to. Changes still try to minimize incompatibilities if possible and there are rules for how applications can use the interfaces in a way least likely to cause issues. The impact is also limited because non low-level applications shouldn't be using these interfaces.

@PeterCordes pointed out if a change in procfs or sysfs breaks an application used by your distributions init scripts, you could have a a problem.

This depends somewhat on how your distribution updates kernel (long term support or mainline) and even then the issues are relatively rare as distributions usually ship the updated tools at the same time.

@StephenKitt added that upgraded userspace might require a newer version of the kernel, in which case the system might not be able to boot with the old kernel and that distribution release notes mention this when appropriate.

Related Question