Custom Linux Kernels Trim Fat and Tune Performance
I have some shocking news: despite the astonishing growth of Linux, there is a whole new generation of Linux users who have never, ever compiled a kernel. How to account for this sad state of affairs? Perhaps it's because the distribution maintainers are doing such fine jobs it's not necessary. Maybe users just don't know that they can. Whatever the reasons, today we're taking a tour of some of the different ways to customize the Linux kernel. First we'll learn the old reliable generic way, and then take a tour of the Fedora Way and the Debian Way of customizing kernels.
A word of warning: while building a custom kernel isn't all that difficult, it is complex and time-consuming, and when you're all finished you might be the proud parent of a non-booting kernel. The good news is you can have as many do-overs as you want without hurting your system. Any Linux system can have any number of kernels and you can choose which one to boot to, so never delete old kernels until you're certain your new one works correctly. Your system will not try to boot to a new kernel until you explicitly configure it to do so, so it can't sneak up on you. So you can go on a wild spree and build and test a whole army of new kernels if you like.
Give yourself a couple of gigabytes of disk space to play with. You'll need it to hold your kernel sources and build tools and other utilities, plus you'll need 500 megabytes just for the interim files created during the build process, and you'll need a place to keep your nice new kernels and kernel modules.
You should have the
installed in case you need to look up hardware information. Run the
update-pciids command first to bring them up-to-date.
/proc/cpuinfo displays your CPU specs.
Why would you even want to do this? For a number of reasons: to get extra functionality, to weed out unneeded features, to try for better performance, to help with testing new patches, or just because you want to know how. The last two reasons are the best ones. I wish everyone had curiosity and a desire to tinker and improve things.
Most general-purpose Linux distributions ship with kernels and sets of modules that try to please everyone and support all the hardware in the world, so you end up with a couple hundred megabytes of kernel + modules fattening your system. This raises security concerns, and some things are just plain silly such as support for infrared, ham radio, and bales of laptop-specific crud on a desktop system, to name my three personal favorite useless features. And why have all that lard in the first place? It's fun to build a kernel customized for your CPU and that supports only the hardware and other features that you want it to. You might even see a performance gain.
- 1Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 2Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 3Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 4Linux 4.6 Charred Weasel adds USB 3.1 Support
- 5Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader