The Linux kernel is the core foundation that all other system software is built upon. It provides the interface between a machine‘s hardware components (CPU, memory, devices etc) and the processes running on top. Upgrading the kernel can thus have significant improvements on overall performance, stability, security and hardware support.

However, changing kernel versions also carries a risk of breaking compatibility or causing regressions if not tested properly. Striking the right balance is key to maximizing benefits while minimizing disruptions.

This in-depth guide will cover best practices around installing, upgrading, downgrading and removing kernels on Manjaro Linux. Both command line tools and graphical user interface options will be explained from an expert perspective.

Kernel Architecture Refresher

Before diving into kernel management, let‘s do a quick recap on the role of the Linux kernel and its architecture:

Linux kernel architecture diagram

The kernel is the fundamental bridge between all software processes and underlying hardware resources. It handles vital tasks like:

  • Memory management and provisioning
  • CPU scheduling and access
  • Device drivers and peripherals
  • File systems and disk operations
  • Network stack and communication protocols

At a high level there are essentially two spaces: User Space comprised of applications, services, libraries, desktop environments etc. And Kernel Space made up of the core kernel components controlling the hardware itself.

The kernel plays referee – arbitrating resource contention between processes and doling out access. Having a high performance, stable kernel ensures optimal utilization of compute, storage and networking capacity.

Why Keep Kernels Updated?

On modern hardware and software, significant optimizations happen rapidly. Every new kernel revision brings enhancements like:

  • Improved scheduling for multi-core CPUs
  • Better utilization for fast NVMe storage
  • Compatibility fixes for latest GPUs
  • Enhanced laptop battery efficiency
  • Faster network throughput
  • New hardware support (e.g. ARM SoCs)

For example, Phoronix benchmarks show around 25% faster performance on Kubernetes workloads moving from kernel 5.0 to 5.4. And nearly 40% speedup in some PostgreSQL cases from 4.19 to 5.10 kernels!

There are also crucial security patches that minimize attack surface and exposure to bugs. Running outdated kernel opens up more vulnerability risks.

Of course hardware/software compatibility tradeoffs exist when upgrading as well. But generally it is advantageous to stay updated if possible.

Checking Current Kernel Version

Before updating the kernel, we need to confirm which version is presently running. Use the mhwd-kernel utility to interrogate details on the current working kernel:

mhwd-kernel -li  

Sample output:

Currently running: 5.9.16-1-MANJARO (linux59)
The following kernels are installed in your system: 
* linux59

This shows us kernel 5.9.16 is active with the internal label "linux59". Good to know as the label is referenced in many kernel management operations.

Upgrading Kernel via Command Line

Manjaro gives flexibility to upgrade kernels using either 1) its own mhwd-kernel tool or 2) the standard Pacman package manager used by Arch. Both have similar capabilities but it‘s good to understand the nuances.

mhwd-kernel: Manjaro‘s Kernel Helper

mhwd-kernel is purpose built for managing Manjaro kernels. To see all available candidates:

pacman -Ss linux5* | grep "kernel and modules"

Sample output:

linux510 kernel and modules
linux511 kernel and modules
linux54 kernel and modules 
linux59 kernel and modules

This displays all installable kernels from the repositories along with their package names (which contain the actual kernel version).

To upgrade from say 5.9 to the latest 5.11:

sudo mhwd-kernel -i linux511

By default this keeps your existing kernels as fallback options too. To purge old kernels automatically during install, add the -r flag:

sudo mhwd-kernel -i linux511 -r

Pros of mhwd-kernel:

  • Purpose built for Manjaro
  • Simple syntax
  • Handles dependencies and modules
  • Auto removes old kernels

Pacman: Arch‘s Package Manager

Alternatively, the standard pacman tool can be used since Manjaro kernels are packaged up like other software.

To upgrade a kernel, install its package:

sudo pacman -S linux511

To autoremove old kernel packages:

sudo pacman -R linux59

Why use Pacman over mhwd-kernel?

  • Leverage other Pacman features (hooks, scripts, etc)
  • Consistency with updating other software
  • More flexible control

But for most kernel use cases, mhwd-kernel is simpler.

After installing new kernels, reboot to load it and verify proper functionality before removal of old ones.

Downgrading Kernel Versions

While the general best practice is keeping kernels updated, some use cases warrant downgrading to an older kernel. For example:

  • Critical infrastructure where uptime is paramount, and the latest kernel has regressions
  • Specialized workloads reliant on particular kernel capabilities
  • Developers targeting/testing specific kernels

To downgrade, first list available older candidates:

pacman -Ss linux5* | grep "kernel and modules"

Then install the desired legacy one like:

sudo mhwd-kernel -i linux54  
sudo pacman -S linux54 

Be mindful to then remove unneeded newer kernels to tidy things up:

sudo mhwd-kernel -r linux510
sudo pacman -R linux510 

Also consider keeping an LTS (Long Term Support) kernel version like linux-lts installed as a fallback.

Removing Old Kernels

With a rolling release model, accumulating outdated kernels on a Manjaro system is common. To remove these "cruft" packages:

With mhwd-kernel

sudo mhwd-kernel -r linux59

Where the argument is the internal label of the target kernel package.

With Pacman

More steps are needed with Pacman since the main package, headers and extra modules must be removed separately:

sudo pacman -R linux59 linux59-headers linux59-extramodules

Regardless of the method, exercise extreme caution to never remove the currently running kernel! Always maintain at least two working kernel options before deleting.

Kernel "Flavors" and Types

Manjaro supports several categories of kernel flavors:

Stable

These are the standard kernels rigorously tested through the official release cycle before being blessed in long term support distributions. They offer maximum compatibility.

Examples:

linux510
linux58
linux414-lts

Real Time

Real time kernels are tuned for extremely low latency, minimal jitter, and consistent response times demanded by audio production, scientific, engineering, financial trading and gaming scenarios.

They trade off a bit of throughput performance for prioritizing latency sensitive requests over bulk throughput tasks. Identified by the -rt suffix.

Examples:

linux58-rt
linux510-rt 
linux411-rt

Experimental/Development

Cutting edge kernels that have new features and changes under active development, less testing, and higher instability risk. Useful for those needing the very latest changes at the bleeding edge or to contribute to kernel projects. Denoted by the -git tag.

Examples:

linux59-git
linux510-git

When selecting kernels, factor in your performance needs, risk tolerance, and workload types. Most will be fine sticking with stable kernels from recent releases for best all-around platform stability.

Enterprise infrastructure stacks demand rigorous validation and change controls where even minor regressions are unacceptable making LTS (Long Term Support) kernels mandatory there.

On bleeding edge hardware, experimental kernels may better leverage the latest capabilities though. Understand the pros and cons of each flavor.

Updating Kernels via GUI

In addition to using command line tools, kernels can be managed visually through Manjaro‘s Settings Manager:

  1. Launch "Manjaro Settings Manager"
  2. Go to Kernel -> Manage Kernels
  3. Available kernels will now be shown with install/remove actions

Manjaro kernel version manager GUI

Compared to raw CLI, benefits of the GUI include:

  • Seeing kernels in a visual tabular view
  • Install/remove kernels with button clicks
  • Requires less command syntax memorization

However, certain advanced functions like removing individual kernel packages may still need CLI. Overall, nice supplemental way to augment command line kernel updates.

Kernel Updates Best Practices

Based on all the factors around maintaining kernel currency, compatibility and stability – here are best practice recommendations:

  1. Test changes first – Introduce kernel updates in dev/staging environments before production servers whenever feasible.
  2. Stagger updates – Roll out a new kernel in a phased manner to a portion of systems first to catch any early issues.
  3. Keep fallback kernel – Always preserve at least two working kernel versions to rollback if the latest has problems.
  4. Delay removals – Wait 1-2 weeks after an upgrade before deleting old kernels to confirm stability.
  5. Tune kernels – Optimize kernel parameters for specific workloads using tools like `tuned` profiles.
  6. Monitor closely – Keep an eye out for kernel regressions in issue trackers, forums, release notes.
  7. Consider LTS – Evaluate Long Term Support kernels for systems needing extended stability like servers.
  8. Understand compromises – Recognize that upgrading always involves tradeoffs between new features and compatibility risks.

Finding the optimal cadence between upgrading, testing, and staging kernel changes is key to maximizing benefits while minimizing disruptions across environments.

Kernel Development & Release Cycle

Understanding the continuous development processes behind kernel advancement provides helpful context around update frequencies.

Active kernel branches under maintenance by the community follow a roughly 12-14 week release cycle. Incremental dot (.) releases represent stable production-ready kernels receiving only critical fixes.

Meanwhile, Linus Torvalds merges bleeding edge feature work and disruptive patches into mainline kernels about every 8-10 weeks. These undergo extensive distributed testing worldwide before being designated for release.

Distributions subsequently pick up and integrate these mainline versions into their repositories when comfortable. Manjaro leverages its rolling update model to expose new kernels much faster than fixed Linux editions.

The version numbering scheme is also informative:

x.y.z

Where x denotes the major version, y indicates the minor version, and z represents the patch.

Major advances with architectural changes, significant new features, driver updates etc increment the x. More iterative releases go into y. And critical fixes raise z.

So a jump from say 5.15 to 5.16 brings substantially more changes than going from 5.15.5 to 5.15.6. Understanding differences helps qualify update criticality and risk.

Linux kernel release cycle

The coordinated upstream development milestones integrated by distributions like Manjaro result in users continually getting the latest kernel advancements.

Driver & Hardware Considerations

One of the most challenging areas around updating kernels involves retaining compatibility with existing hardware drivers – from enterprise RAID controllers to consumer wireless cards.

Ideally hardware vendors keep pace with kernel changes by releasing updated drivers tested against new kernels before they reach distributions. However delays here often happen resulting in temporary mismatches.

Likewise bleeding edge hardware may only recently have drivers introduced for the very latest kernels. This forces users wanting support for say an emerging ARM SBC dev board into upgrading sooner than otherwise necessary.

Monitoring Linux kernel documentation around "Removed" and "Deprecated" driver changes provides insight into upcoming compatibility issues:

  • https://kernelnewbies.org/LinuxChanges
  • https://kernel.org/doc/html/latest/admin-guide/removed-removed.html

Proactively reviewing scheduled driver changes impacting deployed hardware can steer update planning. When feasible, staging pre-release kernels in dev environments will catch any driver gaps needing attention from vendors.

Enterprise vs Consumer Kernel Considerations

The criteria around kernel selection and updates has parallels and differences between enterprise and home consumer scenarios.

For regulated industries like financial services and healthcare, staying extremely risk averse to any potential systems downtime generally prohibits adoption of latest kernels until substantial bake-in time has occurred across the community. The long term support nature delivered by RHEL, SUSE and Ubuntu LTS better match these strict change control needs.

On consumer desktops and laptops, improved functionality, features, speed, compatibility etc motivate more aggressive upgrades to benefit from new kernels faster. With less complex infrastructure dependencies, rolling back from minor hiccups is easier making it more palatable.

However, these generalizations have nuance. Plenty of startups leverage bleeding edge kernels and container orchestration to ship applications super rapidly. While some hobbyists stick to point releases for maximum stability with niche use cases.

Understanding usage scenarios, workload types, risk tolerance and technical sophistication of the audience are all crucial considerations when evaluating kernel selection for a given environment. Profiling systems accordingly guides appropriate kernel update policies.

Conclusion

Manjaro‘s flexible kernel update options empower matching machines ranging from IoT devices to cloud scale server clusters with the right kernel capabilities. Its intuitive command line tools supplemented by graphical management give precision control adaptability.

Carefully evaluating usage models, workload behaviors, hardware dependencies, driver lifecycles and risk factors enables tuning kernel upgrade frequencies for optimum gain/risk ratios. Monitoring upstream kernel community acceptance testing before deploying new versions reduces instability surprises.

With modern systems becoming so capable at economical costs, refreshing hardware alongside software periodically helps smooth major transition pains as well.

The overview of architectures, upgrade/downgrade procedures, removal practices, flavors pros/cons and more covered here distills the key considerations around maintaining current, performant and reliable kernels in Manjaro environments.

Now master your kernels by keeping them updated optimally for your needs!

Similar Posts