5 reasons you might want to compile your Linux kernel from source

It's been over 20 years since I had to compile a Linux kernel, and that's because the boxed copy of Red Hat Linux someone gifted me wasn't going to work with my PC back then without adding stuff that is standard today.But if standard pre-compiled kernels have everything you need, what's the point of compiling the kernel? There are lots of reasons, actually, but these are five of the most common ones.You need support for very new or unusual hardware Well, aren't you the early adopter? With every kernel release, Linux hardware support is getting better.

However, it still has a long way to go compared to Windows.The thing is, your current distro of Linux may not have the latest kernel.This is more likely if you use an LTS (Long-Term Stable) distro which prioritizes stability over cutting-edge features and support.

Close If you're installing Linux on cutting-edge new PC hardware, the hardware support you need may not yet be in your kernel.So you can take the latest Linux kernel source, and compile it manually for your computer.It's not just about new computer hardware either.

There might be some niche hardware that's no longer part of the standard kernel, or is meant for some specialist industrial application.You want to remove features your system will never use Just a little nip and tuck The standard kernel has to support thousands of computers with practically infinite combinations.That means there are huge chunks of the pre-compiled kernel that your specific computer will never use.

If you trim the parts from the kernel your computer won't use, then technically the kernel will have a smaller footprint, and you'll also cut out tons of modules.Should anyone do this? It really only makes sense for specialized computers, like small embedded systems or other highly-specialized devices with fixed hardware and limited resources.For a typical laptop or desktop computer, you'll likely see no benefit of paring down the kernel.

You're more likely to disable something you'll actually need down the line, and that's a headache to deal with.That said, advanced users sometimes build custom kernels for battery and power tuning, security hardening (minimal attack surface), or to enable specific kernel config options not exposed by their distro.You need to apply a patch that your distribution hasn’t adopted Sometimes you have to be quicker on the draw Server admins, and other professional computer users actually have a good reason to compile a kernel themselves, and that has to do with security and patches.

If your mission-critical Linux system is affected by a kernel bug or a new exploit has been discovered, then you can compile a kernel yourself that includes the fixes faster than waiting for the distro maintainers to issue an update.Most people, most of the time, can just wait for the distro to get a hotfix, but for some systems it really is a matter of every second counting.But it's going to be a highly-contextual decision.

You want precise control over performance and latency When every millisecond counts So you might have heard that if you compile your own kernel, you can make Linux go faster.Except, I just said a little earlier that making the kernel leaner won't really make much of a difference unless you're on some tiny embedded computer.So what do people actually mean by this? One possibility is that they're actually talking about system latency, and there are some types of computer users that need to do things that are sensitive to real-time tasks.

A music producer or recording musician might compile a special version of the kernel that prioritizes latency in the audio bus.An industrial control system, or a robot might need to respond to input faster than a standard Linux kernel can manage.A server admin might want to optimize for handling massive numbers of concurrent connections, and so on.

Kernel configuration allows you to tweak all sorts of parameters and remove components that pare away milliseconds of latency.This is the sort of difference a regular person won't notice, but makes a real difference in the examples I just mentioned.Of course, this isn't a free lunch.

Such ultra-specialized kernel configurations can lead to drops in performance in other areas, such as throughput, or it can increase power consumption.So it's not something you'd do just because you felt like it.You want to understand how Linux actually works You can see both the nuts AND the bolts While I don't think the vast majority of people need to compile the Linux kernel manually for their own needs, I do think everyone should try it at least once.

Don't do it on your mission-critical machine or anything, but a virtual machine running any old distro will do.This is a risk free way to see how it works, and going through the steps of customizing and compiling a kernel first-hand, you end up learning quite a bit about how Linux is put together even if (just like me) you don't really understand everything you're looking at.This is one of the great things Linux can offer that macOS and Windows can't.

Those proprietary operating systems don't want you to see inside the heart of the OS, but Linux is happy to let you look and learn as much as you can stand.

Read More
Related Posts