| |
Last update: October 7, 2001
Secrets I learned...
about building a new kernel
Credits
Other sources
- jgo.local.net/LinuxGuide
(See "System: Compiling a New Kernel")
- README in the top level of an untarred kernel tar ball.
There's also a Documentation tree as well
Why build a new kernel?
Sometime after you've completed your Linux installation, perhaps
much later, you may have need to install a new kernel. Now is the time
to plan for that. And the best way to plan is to go through the
exercise.
In the normal course of creating a new kernel, a .config is
created that contains the options (and there are a lot of them)
that are being used.
But it is often the case that an initial distribution install does
not record how your newly installed kernel was built. ie: It did
not provide a .config file reflecting the
build parameters that were used. So, for that reason if none other,
we'll make a new kernel now.
When the time comes that you need to create a new kernel, odds are
that you'll want the new kernel to be configured in much the same
way as the old one.
This discussion deals with the creation of a new kernel. At this
time, the only reason you may wish to create a new kernel is to create a
.config file. (By the way, you may choose to save the config
file by any name you want; it doesn't have to be .config)
Before building a new kernel
Do you have a boot diskette? If not, make one...
# fdformat /dev/fd0H1440
#
# uname -r
2.2.16-3
# mkbootdisk --device /dev/fd0H1440 2.2.16-3
...and test it!
The /dev/fd mentioned here may not be the one for you.
The storage media may not be in sufficiently good a shape.
Building a new kernel
Assume your new kernel source is in a file such as linux-2.4.0.tar.gz
- Make sure it's in directory /usr/src/
- If you already have a directory there called linux move
it to another name which more properly describes it, with a command
such as mv linux linux-2.2.14
- If, on the other hand, you already have a linux which is
currently pointing to some other directory, break the link with
rm linux
- After you've un-zipped and un-tarred the kernel, make sure it's in
a sub-directory of /usr/src/. Its name should fully describe
it, such as /usr/src/linux-2.4.0
- Create a symbolic (soft) link to it named (just) linux
with something like
ln -s /usr/src/linux-2.4.0 linux
Three kernel configuration tools
What do you want your kernel to look like? There are a lot of questions
to be answered.
- make config is the (painful) question after question
after question console dialogue version
- make menuconfig is the slightly less painful console
version
- make xconfig is the X version and is easiest to use
Miscellaneous considersiderations
- If you want frame buffer support, you'll need to request "Code
Maturity Level" that includes prompts for development and/or
incompletes.
- Since I wanted frame buffer support, I asked for these experimental
modules (which reflect my hardware)
- nVidia Riva Support
- ATI Mach64 display support
- ATI Rage128 display support
- In "Character devices" I also chose to enable "Support for console on
serial terminal". If, as a result of what you've done, Linux thinks
there's no VGA console here, startup console messages will go to
this serial port.
Under normal circumstances, ie: when VGA does exist, this by
itself does not redirect console messages to the serial port.
You must also pass a kernel command line option at the LILO prompt
with something like
console=/dev/ttyS0
or add this option to an append line in lilo.conf
The process
Go through each and every selection in the menus given. If you are not sure
what an option is used for, click on the HELP button for more information.
If you're still not sure, look for a Documentation sub-directory in
the tree. That directory consists of files and other sub-directories. Each
directory contains a file called 00-INDEX which tells you more of
what's there. This will be a time consuming process. Make sure you document
what you did in case you have to re-visit it later!
When you have selected all of the options you would like in
your "custom" kernel configuration, you will have finished the hard part.
- Select Store Configuration to File in order to save
a copy of your configuration selections. You can use this file later
if you need to do this again.
- This is particularly handy if you have several different config
versions. The very last configuration you used is also stored in a
file named .config
- Select Save and Exit
Now...
- make dep checks dependencies and updates .depend
- make clean
- make bzImage which will create a compressed kernel image file
called /usr/src/linux/arch/i386/boot/bzImage (Don't get
sucked in as I did by /usr/src/linux/vmlinux which is the
uncompressed kernel image.)
(The "b" in bzImage means this will be a big Image.)
(The "z" in bzImage means this will be a compressed Image.)
An alternative to make bzImage which I don't like is
make bzlilo For my liking, it goes too far. Not only
does it make a kernel image file, it also
puts that image into /boot
adjusts /etc/lilo.conf (in ways I don't like)
and even runs /sbin/lilo
That's a little too much for me! I'd prefer to do those steps myself. Call me
paranoid, but I prefer to be a little more hands-on and to run lilo in test
mode /sbin/lilo -t first!
The next steps concern modules and are only needed if you are going to be
using a modular kernel, which is the preferred way. (The alternative is a
monolithic kernel.)
- make modules
- make modules_install
(These two steps took me about 10-15 minutes to complete.)
Copy the new image into your /boot partition, giving it a
meaningful name, with something like this:
cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.4.10
OK! Now your new kernel has been built and has been placed in /boot
Now you have tell LILO about it. (There's a reasonably full discussion on LILO
here in another section of
these notes.)
- Make sure you add a new stanza into your /etc/lilo.conf
leaving the other ones in tact. In case the new kernel screws up,
you'll want the option of being able to boot an old one!
- The new stanza ought to be configured quite similarly to the old
one there with the exception of the image= which will
point to your new kernel and the label= which will be
whatever text label you want to associate with this new kernel.
- Run /sbin/lilo -t If it's looking good,
- Run /sbin/lilo and reboot your system
Once you've rebooted, the command uname -r can be
used to report on which kernel is running and when it was built.
|