[Techtalk] Kernel Building (was Re: Simply Hardware 3B)

hobbit at aloss.ukuu.org.uk hobbit at aloss.ukuu.org.uk
Wed Aug 21 11:03:09 EST 2002


On Tue, Aug 20, 2002 at 10:48:24PM -0700 or thereabouts, Kai MacTane wrote:
> At 8/20/02 08:56 PM , Andrew wrote:
> >         As the guy who started this thread I am now scared to the 
> > bone...that's two references to building a kernel...(-: (-;  :-) whhaat 
> > am I in for????
> 
> Hi, Andrew. Building a kernel is actually not nearly as scary as people 
> generally make it out to be. Not that it's a walk in the park, but it's not 
> brain surgery, either.
> 
> If you look at the Kernel HOWTO, at 
> <http://www.tldp.org/HOWTO/Kernel-HOWTO.html>, it will give you a general 
> idea of what's involved in the process. Basically, it's going to look like 
> this:

I will add one and a half things here. The one for RH. The half for
Debian, because I am missing bits. 

>     make menuconfig (or xconfig, or just plain config, as desired)
>     make dep
>     make
>     make bzImage
>     cp arch/i386/boot/bzImage  /boot/some-name-you-choose
>     make modules (optional)
>     make install
>     make modules_install (optional)
>     vi /etc/lilo.conf
>     lilo
>     [cross fingers]
>     shutdown -r now

_If you are on Red Hat_, you can skip a lot of this. You can do:

    make menuconfig (or xconfig, or config)
    make rpm

That's almost it. It does the make dep, bzImage, modules etc for you. 

This gives you a kernel rpm you can install. Use rpm --install and
don't use rpm --upgrade. This will leave your old rpm around in case
your new one is no good (it happens to all of us occasionally that
the new kernel is missing something like oh... the module for the
network card you use, or something). 

If you are on a recent RH you will need to edit /etc/lilo.conf and
run /sbin/lilo if it has lilo; or you will need to do the grub 
equivalent. RH seems to be switching to grub, and I have been 
putting off learning it.

_If you are on Debian_, (don't think you are? But I want to know 
the answer myself), there is a Debian Way to build kernels. I have
forgotten it. Someone please remind me! Something to do with a
kpkg package or some such.

Unless you have a really slow machine, the longest part of this
whole process is the "make menuconfig" stage. You go through a
list of every single thing the kernel can and can't do. It's
daunting the first time, and just plain boring the second time.
Sort of like installing Debian, actually. "More choices? Where
are they all coming from?" And you say yes or no to each stage.
(There is _always_ a "if you aren't sure, pick..." in the help
for every choice. If there isn't, it's a bug :)) 

> I'm not going to go into all of those in detail -- that's what the Kernel 
> HOWTO is for, and it does it better than I could, anyway. But I will point 
> out a few things that are fairly important in doing a kernel compile, both 
> personal qualities and steps to perform:

I used to be wary of the Kernel-HOWTO because it had make modules
tucked away in the "extra make targets" at the back where it was
easy to miss (speaking from personal experience there). Re-reading it
to check, though, I find it's been improved extensively and 
make modules and make modules_install are in the main sequence.

> 1) The ability to *carefully* and *precisely* follow directions.
> 2) The ability to keep your cool and not panic.
> 3) Do *NOT* abandon your old kernel!
> You can keep your old kernel around while making the new one the default to 
> boot from. Then, if something goes wrong, you can just Ctrl-Alt-Del twice 
> and select the old kernel at the LILO prompt. This is a total lifesaver.
> 4) Before doing anything involving /usr/src/linux*, make sure you
>     know if that directory is real or a symlink!
> 5) Don't forget to re-run LILO!
> 
> After editing /etc/lilo.conf, you need to run lilo (just "lilo", on its 
> own, from a command prompt; no arguments necessary). This makes it actually 
> read the changes you've made and apply them to its map file in the boot 
> sector. Otherwise, on your next boot, LILO will get as far as "LI" and 
> hang. Easy to forget to do, and easy to diagnose when you see it happen, 
> but rather difficult to recover from.

Many distributions now use grub. (Actually, the HOWTO doesn't
mention this at all.) Before going down this path, find out 
whether your bootloader is grub or lilo. Just look in /etc and
see which is mentioned. 

> 6) Have some spare boot media around.

> As you might guess, the last three points are ones I've learned from 
> personal experience. However, I've also learned from personal experience 
> that building your own kernel is something that the average Linux user 
> *can* do. 

Yes. In theory, one day, the distros will all get it right and
there will be no need for 95% of people to do it. So they tell 
me. I'm still waiting..

There's another point I always forget, and someone else will have to
provide the details for. After you have survived the long boring
make menuconfig, there is a .config or some such name file lying
around which has all your options.

If it turns out this is a perfect kernel, you can save a copy of
this .config somewhere, and use it as a base for future upgrades.
I forget the details because I always forget to save the 
wretched file so rarely do it :) 

> But let's get all the way through your BIOS routines first... :)

Good thought :) 

Telsa



More information about the Techtalk mailing list