Simple kernel make help.

To understand howto compile a kernel you can read
/usr/src/linux/README this file is short and too the point.
You can get a lot more help by reading /usr/src/Linux-HOWTOs/Kernel.HOWTO

This document concerns kernel 2.2.14, in itself there are no
differences if you use another version, its stated above because
somewhere else in this document 2.2.14 WILL be used as an example.

In short you can do;
cd /usr/src/linux
edit Makefile
adjust line 4 as follows.
You may substitute -3 for whatever you want,for example;
EXTRAVERSION = -first-try
save to file,
make mrproper
The above is only needed when a fresh kernel source is installed.
For example you have just installed Linux and you are now doing a
compile for the first time.
make config
You will now be presented with a program which will ask you all sorts
of questions, you answer with "y" "n" "m"
"y" = yes this implies compile the option into the kernel itself.
"n" = no implies do not compile it at all.
"m" = compile the option a a kernel module.
I am of the opinion that kernel modules are by far the best way to
compile our kernel, advantages are, the kernel itself stays smaller,
a module can be loaded/unloaded at will, which means after its use
you unload it and retrive the memory it used.
'make config' presents you with the questions like the following line.
Prompt for development and/or incomplete code/drivers (CONFIG_EXPERIMENTAL) [Y/n/?]

Note there is also the "?" option if one was to enter the "?"
question mark we would see;

Some of the various things that Linux supports (such as network drivers,
filesystems, network protocols, etc.) can be in a state
of development where the functionality, stability, or the level of
testing is not yet high enough for general use. This is usually known
as the "alpha-test" phase amongst developers. If a feature is currently
in alpha-test, then the developers usually discourage uninformed
widespread use of this feature by the general public to avoid
"Why doesn't this work?" type mail messages.
However, active testing and use of these systems is welcomed.
Just be aware that it may not meet the normal level of reliability or
it may fail to work in some special cases. Detailed bug reports from
people familiar with the kernel internals are usually welcomed by the
developers (before submitting bug reports, please read the documents
Documentation/oops-tracing.txt in the kernel source).
Unless you intend to help test and develop a feature or driver that falls
into this category, or you have a situation that requires using these
features you should probably say N here, which will cause this configure
script to present you with fewer choices. If you say Y here, you will be
offered the choice of using features or drivers that are currently
considered to be in the alpha-test phase.

and the same line (CONFIG_EXPERIMENTAL) [Y/n/?] will appier again
as the last line of text.

Everything you choose is written to a file called

The next step is "make dep" "make bzImage"
In a nutshell;
make config
make dep bzImage
make modules modules_install
Or you can place both lines as above on one command line;
make dep bzimage && make modules modules_install
If you have compiled a kernel from this source before then you would
be well advised to do;
make dep clean bzImage && make modules modules_install
make clean does what it says, it cleans out old unwanted and used files.
Thats it as far as compiling is concerned, now you have to install
the new kernel, give it a new name, tell lilo its been installed.

cp arch/i386/boot/bzImage /boot/vmlinuz-2.2.14-3
cp /boot/
Thats the kernel installed and renamed.
You must now tell lilo where to find the new kernel, thats done firstly
by editing /etc/lilo.conf

To make lilo reread its file and test it to see if all is ok do;
/sbin/lilo -t
You should then see something like the following;
Added 2.2.14-3 *
Added 2.2.14-2
Added Slack-2.2.13
Added Slack-2.2.14-1
Added Redhat-2.2.14
Added dos
The boot sector and the map file have *NOT* been altered.

Now run lilo without any options;

A small note on /etc/lilo.conf
Note the * asterisk on the first line returned from lilo, in the example
above 2.2.14-3 is the default kernel, in this case its the first "image"
entry in /etc/lilo.conf.
You may specify a default image under the "Global" section of lilo.conf.

Thats it, reboot choose a kernel or simply hit enter to choose the
default image, or hit the tab key to get a list.

make options one should know about.

make install

Dont use it unless you know what you are doing, why one may ask.?
Well if you only have one kernel to boot from and this option is used
and lets say you forgot to include some vital protocol, say for example
ext2 filesystem, then that new kernel of yours will fail to boot and you
are left with an unbootable system, let me explain what make install

When make install is used to install the newly compiled kernel it will
make a backup of the old kernel image, the make process will place the
image in the root directory, No not /root but / unless you edit
/usr/src/linux/Makefile and define the place you want the new kernel
placed in, its around line 77 of the Makefile and looks like;
Note the hash "#" that means its commented out and will be ignored,
simply uncomment that line to get 'make install' to place your new
kernel into /boot.
If in doubt dont use make install.

make distclean

This make option cleans out all files created by previous makes, it
cleans out even more files than make clean does, be carefull with this
option as it will remove your .config file and you will need to start
over again and create a new one with make config.
If you tinker with your kernel all the time it is adviseable to copy
.config to a safe place outside of the kernel source tree.

make oldconfig

If you copied your old .config as per advice above, this command is
for you, after you copy the .config file back to /usr/src/linux
doing 'make oldconfig' will automate the configuration process.
Note it states at the top of .config;
# Automatically generated make config: don't edit
You can edit it to make short cuts, but it is adviseable not to do so
unless you know what you are doing.
An example would be you want to add a new kernel module for a newly
purchased ethernet card, one could edit the .config file and look for
text concerning the make and type of card, lets say its a PCI NE2000
compatable card and you read the documentation of this card in the
Documents dir of the kernel source and saw that is needs the NE2K_PCI
driver, open .config into your favorite editor.
Search for text like NE2K, you will see the following;
#CONFIG_NE2K_PCI is not set
Make it look like
save the file and run 'make oldconfig'
now compile the kernel from the steps at the top of this page.

If you find mistakes in any files here on my web-stie please dont
hessitate in sending me a message.
  • home