Good documentation for compiling a kernel

Hello.

I’m interested in a well written document which describes the best ways of compiling a Linux kernel.

I have experience with compiling Linux kernels, but I have been unable to compile a kernel after version 2.6.5, which was released a long, long time ago. Since then I only get kernel panics at startup and therefore I’m now interested in good documentation which covers this topic.

I haven’t tried compiling a new Linux kernel for, well, maybe 6 months or more, but I think I still will be having problems.

Any suggestions where I can find this?

Hi there,

I have found a number of good on line guides, but they do tend to be somewhat general in nature - and as you do have experience in compiling kernels, they are likely not going to be particularly helpful. Some are pretty basic: How to: Compile Linux kernel 2.6 and about the best I have found are the “How to Compile a Kernel the <blank> Way” series. These are generally pretty good, and include distro specific tools and procedures. These are available for mostpopular distros, and can be good if you are used to one and are doing it on a new platform. Here is an example: How To Compile A Kernel - The CentOS Way | HowtoForge - Linux Howtos and Tutorials

In my experience though, there is the “on paper” guide and then the real world situation. I feel your pain on the kernel panics. Of course that could be a selection in menuconfig that is not compatible, of buggy hardware support, or an evil module.

Are you using a pre-existing config file and moving it to .config and doing a make oldconfig to import it’s settings or making the config completely from scratch?

Also, at what point are you getting the kernel panic specifically? (Even a screen shot if it is a virtual machine, etc.)

Cheers,
Pete

Snakedriver, one of the members here who can call himself a kernel specialist by now :nerd: often refers to this link (YAM) : A Frustrated User’s Guide to Linux

On openSUSE.org there is also a wiki page : Configure, Build and Install a Custom Linux Kernel - openSUSE

Cheers,
Wj

Hi
And this one…


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.18-0.2-default
up 16:54, 1 user, load average: 0.50, 0.24, 0.21
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82

Magic31, interesting link!

I will use that guide the next time I try to compile a kernel, which I might do in a week or two (something like that). I choose not to experiment with my own existing Linux systems at the present (I just want working systems which can be up and running 24/7 and at the present they work flawlessly without major crashes).

Before when I was compiling up Linux kernels, I created the configuration file from scratch and clicking/unclicking everything which I think I need in the kernel (this part is hard!).

Hi There,

Rather than clicking everything in menuconfig, you can save the config to reuse next time, or check and see if you already have a config from your existing kernel to re-use. Just move it to your build directory and rename it .config - then run make oldconfig and it will import it into your current build.

Also, for building and testing kernels on production machines, or to isolate your build environment, you might want to consider just virtual machines. VMWare server is quite easy to install and will give you a great build and test environment.

Cheers,
Pete

I’ve tried reusing the config file from an existing config file which I had when I compiled an older kernel and in this case I’m not sure if this is a good thing to do.

I mean, what if the newer kernel has features which the older kernel didn’t have for instance. What are the risks of using an older config file together with a newer version of the Linux kernel?

I also don’t understand why it has gotten harder to compile kernels after version 2.6.5 was released.

I will be getting back to this part about compiling kernels because I actually enjoyed it and it felt exciting!

khelben1979 schrieb:
> LewsTherinTelemon;1905263 Wrote:
>> Rather than clicking everything in menuconfig, you can save the config
>> to reuse next time, or check and see if you already have a config from
>> your existing kernel to re-use.

Btw you can recover the config your running kernel was built with
by the command “zcat /proc/config.gz”.

> I’ve tried reusing the config file from an existing config file which I
> had when I compiled an older kernel and in this case I’m not sure if
> this is a good thing to do.

In my experience starting from a working config (for example the
one of the currently running kernel) is the best way for creating
a new working config.

> I mean, what if the newer kernel has features which the older kernel
> didn’t have for instance. What are the risks of using an older config
> file together with a newer version of the Linux kernel?

The risk is almost zero. If you run “make oldconfig” over a working
config from an older kernel and answer all questions with their default
(just hit Enter) everything will be set in a backward compatible way
and you’ll almost certainly end up with a kernel that works. You can
then start poking around the new config options to see if there’s
anything worth changing.

> I also don’t understand why it has gotten harder to compile kernels
> after version 2.6.5 was released.

IMHO it hasn’t. It’s gotten easier. Nowadays compiling a vanilla
kernel is almost as simple as compiling an application. Try this:

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.8.tar.bz2
tar -xvjf linux-2.6.27.8.tar.bz2
cd linux-2.6.27.8
← install any patches you like →
zcat /proc/config.gz > .config
make oldconfig
← type Enter to everything you do not understand →
make
sudo make modules_install install
← type root password when prompted →

And voilà, on the next reboot you’ll find a shiny new boot menu entry
for kernel 2.6.27.8 above the previous ones.

Finally, a piece of advice I find sadly lacking in many of the HOWTOs
that have already been cited in this thread: If you compile a vanilla
kernel, do not unpack it to /usr/src, and neither unpack nor compile
it as root. Instead, work under your regular user account, and below
your home directory as described above. Only the last step (install)
needs root privileges, which you can safely acquire temporarily with
sudo.

HTH
T.


Tilman Schmidt
Phoenix Software GmbH
Bonn, Germany

/me wrote:
> Nowadays compiling a vanilla
> kernel is almost as simple as compiling an application. Try this:
>
> wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.8.tar.bz2
> tar -xvjf linux-2.6.27.8.tar.bz2
> cd linux-2.6.27.8
> ← install any patches you like →
> zcat /proc/config.gz > .config
> make oldconfig
> ← type Enter to everything you do not understand →
> make
> sudo make modules_install install
> ← type root password when prompted →

I forgot: in case you are afflicted with an nNidia card using the
proprietary driver, you’ll also have to recompile the nvidia.ko
module for your new kernel, like so:

sudo NVIDIA-Linux-x86-177.82-pkg1.run -asnNK --ui=none --kernel-name=2.6.27.8

(Assuming you had installed the driver manually in the first place
and you have an nVidia driver release which already supports the
kernel version you are building.)

> And voilà, on the next reboot you’ll find a shiny new boot menu entry
> for kernel 2.6.27.8 above the previous ones.

With working X, even.

HTH
T.


Tilman Schmidt
Phoenix Software GmbH
Bonn, Germany