Why Compile a New Kernel?
I lost count of the number of times someone told me I was nuts for wanting to compile a new kernel Why not get a new different distro of Linux that works on a specific machine? What is wrong with the kernel that comes with the distro? In many cases, the default kernel works just fine. Conversely, there are reasons for compiling a new kernel.
For this article, I am focusing on the PC architecture. A 32-bit PC can vary from a slightly ancient 386 to the latest chip from different manufacturers. While the range is not as a great, the same is true for 64-bit chips. The default kernel should work on the widest variety of hardware platforms. By compiling a new kernel, you can:
- Optimize the kernel to use the instruction set of a particular class of CPU chips.
- You may not need a kernel that can span 4096 CPUs, with NUMA (Non-Uniform Memory Access) capabilities. If you are running a single-core Pentium III, these features just make the kernel bigger.
- Device drivers are part of the kernel source tree. Most distros do not compile every driver. Some distros make some of the missing drivers available as separate packages. Many do no. When you compile your own kernel, you decide which drivers you wish to include.
- Some performance tuning options are kernel configuration options that cannot be modified for a running kernel.
- You may want to turn on or off kernel debugging options, and profiler options.
- You may want to learn more about the kernel and how it works.
I am sure there are others reasons for compiling a new kernel. Following are a few cases, where I chose to compile a new kernel:
- I have an ancient Micron Transport ZX laptop that I use for ham radio applications. It only has a Pentium III processor, and 256 megabytes of memory. Turning off the SMP and debugging options will help reduce the size of the kernel and improve its performance. I can also optimize the code to a Pentium III processor.
- Most distributions do not turn on the ham radio configuration options in the kernel, and do not compile the ham radio related drivers.
- The default openSUSE 11.1 kernel configuration is set for no preemption. While this is OK for servers, it really make for choppy videos. By compiling a new kernel, I turned on voluntary preemption, and now videos play just fine.
- I have this desire to switch the scheduler from CFS to BFS, to see if it makes a difference on low-end machines.
The actual building of the Linux kernel is a cookbook process. The two hard parts are getting the source, and defining the configuration options. I swear every distro has a different mechanism for getting and installing the source code. As for the configurations options, the list is long, and I mean long. The options change with each new version of the kernel. If nothing else, it is one way to learn about new features in the kernel.
My recommendation is to make any changes to the kernel source provided by the distro for which you are building a new kernel. Most distros make changes to the kernel, and many of those changes have not made their way to the main kernel source. By staying with the source provided by the distro, you also avoid any issues with incorrect tool versions.
The remaining posts in this series will cover, downloading and installing the source, kernel configuration, and then building and installing the kernel.

k1ng Said,
February 5, 2010 @ 11:04 pm
and because it’s good geeky fun.
Links 6/2/2010: GNOME Journal Released, ARM CEO Sees Bright Future | Boycott Novell Said,
February 6, 2010 @ 5:43 pm
[...] Why Compile a New Kernel? I lost count of the number of times someone told me I was nuts for wanting to compile a new kernel Why not get a new different distro of Linux that works on a specific machine? What is wrong with the kernel that comes with the distro? In many cases, the default kernel works just fine. Conversely, there are reasons for compiling a new kernel. [...]
tetris4 Said,
February 9, 2010 @ 5:20 am
I resurrect a very old pc with Puppy Linux a few months ago, but had some troubles with wireless.Manually compiling a newer version of the kernel fixed it!
“and because it’s good geeky fun.”
Bill Anderson Said,
February 9, 2010 @ 7:01 am
I have not really kept current with Puppy Linux. I like the newer versions, but it has a very short list of ham radio packages. I use XUbuntu on my Micron Laptop.
sfsfgsgdsgdsghdsg Said,
February 9, 2010 @ 10:35 am
Why, hardware it is, that’s why!!!
linportal Said,
February 9, 2010 @ 11:48 am
Still, more people go with vendor provided kernels (check poll results below). Oh well, they don’t know what they’re missing. Or do they?
http://www.linuxinsight.com/poll-do-you-compile-your-own-linux-kernels.html
Bill Anderson Said,
February 13, 2010 @ 9:23 pm
Building a new kernel is not a task for many users. They would rather use Puppy or DSL than to build their own kernel. The configuration options are enough to scare off most people. Besides, they believe all the warnings about no support. I never call support anyway. If I can’t find an answer by searching the Web, then it is time for serious code reading. Systemtap is always a nice tool to find out what is happening.
GoblinX Project » GoblinX Newsletter, Issue 236 (02/07/2010) Said,
February 14, 2010 @ 4:15 am
[...] Why Compile a New Kernel? [...]
Gilbert Said,
December 9, 2011 @ 4:12 pm
Great explanation