Why do you compile a custom Linux kernel?

by David Brickner

It used to be that compiling a custom Linux kernel was almost a necessity. Something you just had to do if you wanted a working system. These days, with loadable kernel modules and better hardware support in the vanilla kernel, I find kernel patching and custom configuration less "necessary" but often still desirable.

I'm curious. Why do Linux users these days configure and compile a kernel? To increase performance or hardware compatibility? To add filesystem support or enable experimental features? Just for the fun of it? An attempt to have absolutely the smallest kernel image possible? An attempt to build a highly portable kernel? My reason usually boils down to getting a new piece of hardware to work fully.

Also, what problems do most people have when compiling a kernel? Migrating to new kernel versions? Patching the kernel? Getting an initrd image to load? My biggest three problems are knowing which options I must enable, finding those options in menuconfig, and knowing the name of module I just compiled.

Please, write a comment and tell me why you find it necessary or desirable to compile a kernel, and the most annoying parts of the process.


2006-01-20 10:45:56
Not anymore
I haven't yet needed to compile a 2.6 kernel. The last time I needed to compile kernels was when I was writing Linux Unwired (http://www.oreilly.com/catalog/lnxunwired) , so I could get all the screen captures and instructions down correctly.

In the 2.4 kernel days I did have to compile a lot of kernels, primarily to enable CONFIG_NET_RADIO and to enable things like ReiserFS or JFS when I was working with big disk storage issues.

2006-01-20 11:26:46
admins might need to recompile...
There could be a number of reasons an admin will recompile kernels:

Security: to disable unneeded modules, and sometimes disable module loading at all, which helps prevent a rootkit attack.

Performance: Not sure if this still applies, because you can use sysctl to change a good number of kernel settings, but some stuff can be given more optimal values during the kernel configuration.

From an end user perspective, I haven't *had* to rebuild a kernel on an end user desktop/laptop in a very, very long time. I have done it anyway to get a better driver for one thing or another, and I use the NVidia driver, but aside from that, I don't muck with the kernel on end user machines, because I have enough work to do on the servers to mess with it.


2006-01-20 13:53:11
In a word... Win4Lin
Background: I'm a user of Ubuntu 5.10 (Breezy) on a P4 desktop and an old PIII laptop.

For the most part, I don't need to compile a custom kernel. Ubuntu offers enough included features and kernel choices that most of my hardware is covered out of the box. The few oddball drivers that I use (e.g., usbvision, DRM for the mach64 in my laptop) can be built without recompiling the kernel, just installing the kernel headers.

The one exception for me is the kernel support for Win4Lin 9x. Installing this driver requires patching the kernel and rebuilding. Worse, many distributions will not include these patches as they work in conjunction with a proprietary binary-only driver and are, therefore, seen as "bad".

2006-01-21 19:12:15
Custom kernel
I compile my kernel just to build it to improve performance, and avalibility of options. Cause on most systems like ubuntu, slackware, debian, ect... everything works out of the box but never fast enough or with enough options. Also some of my usb devices aren't supported right off, so that usually requires a little work.
2006-01-23 19:06:16
The kernel is just another tarball, man.
Actually, I'm curiosity-driven: I find learning about the OS very educational, and liberating after a day at $job.
2006-01-23 20:52:37
Recompilation not needed now-a-days
Once upon a time (when 2.4 had just been released), I used to recompile each and every release. Sometimes due to new features, major bugfixes and essential driver support etc

But for the past 1year+ (2.6.x) I just use the distro provided kernel. Why?

- They are good enough, have most of the drivers (exceptions : nvidia, hptmv-SATA RAID etc). Work pretty well.

- The other issue is the Enterprise Linux vendors will not support you on your custom kernel. You need to be running their kernel before you ask for support.

- Hardware driver restriction: eg: Topspin InfiniBand - no source code. So I have to go with RHEL/SLES/CentOS kernels only

- A newer kernel also can mean some amount of risk: There have been filesystem corruption issues earlier (2.4.x). So staying with what works is better.

So I compile kernel only to keep my skills up to date :-)

2006-01-24 04:05:05
not since 2.2
I did not have to compile a custom kernel since 2.4 was released ... only once I compiled a 2.4 to save some RAM on a 486 laptop with 4MB of RAM, but that was an exception, since I no longer use linux to show off, but for real life work ... the prepackaged kernels (in Debian, at least) are good enough for me.
2006-01-24 05:52:20
Recompilation not needed now-a-days
I agree completely. I use the distro (Ubuntu) provided kernel, compile extra modules as needed, and build a custom kernel only when I make buggy and mostly trivial hacks in the process of trying to learn how to make less-buggy and maybe-useful hacks.

Oh, and when trying to make something run on an embedded system or strange hardware platform of some kind.

2006-01-30 19:20:26
I recompile to get software suspend to work on my laptop.
2006-01-31 07:38:20
Kernel compiles
I used to compile the kernel as a passtime to try to get my aged i810 adapter to work on Slackware Linux. I didn't have too much success, one thing or another was always throwing errors and making it a very fustrating experience.

Since then, I've moved to Gentoo(and purchased an nVidia card) and I can now compile a new card with only a day lost tweaking around my settings to get it running. I only had three problems the last time, two due to my error: compiling the RivaFB modlule alongside the binary nvidia drivers, having a version mis-match between the nvidia kernel driver and the driver installed in X, and having out of date alsa tools.

My motive for all this was two-fold: One, I wanted the framebuffer going for when I wasn't in X, and two, I wanted to try out Con Koveras's code tweaks.


2006-03-22 05:18:15
I would like to know how to custom compile the kernel
under RH EL 4/Centos 4 so as to make it more slim
and faster for my old hardware.
Can anyone explain how?