Compiling a RedHat Linux Kernel
We had
several difficulties
getting our first kernel to compile and boot
successfully.
Preliminary
Steps:
- First you
need bootable media; either CD or floppy disk.
If you cannot boot from CD, you will need to make a
bootable floppy disk. In the images directory of
the RedHat Linux CD, you will find several images for
different methods of installation. Use
RAWRITE, a DOS command, to copy the image from
the CD to the floppy disk.
- Boot the
computer with the bootable media. Linux will
prompt you for the installation mode at the boot
prompt. Press <Enter>.
- The next
few steps are simple. You will be asked to pick
your language, time zone, monitor type, mouse type,
etc. If you have a SCSI device or network card
you want to install, you will need to add those
specifically.
- The next
step is to select the type of installation you want to
perform: Install GNOME Workstation, Install KDE
Workstation, Install Server System, Install Custom
System, or Upgrade Existing Installation. We
suggest custom installation.
- To copy
the source code of the kernel during installation of
Linux, select the Kernel Development
option. This will copy the kernel into the
/usr/src/linux-<version
number>
directory. To install the C++ compiler, select
the Development
option1.
- The
installation creates a kernel image called
'vmlinuz-<version number>' in the
/boot directory; however, in our case we had
two kernel images2
- vmlinuz-2.2.14smp
supporting multiprocessors
- vmlinuz-2.2.14
supporting uniprocessor
- The
kernel is loaded at boot time. To load a kernel,
enter the label of the kernel at the lilo
prompt. To view the list of kernels, press
<TAB> at the lilo prompt. If you do not
enter the kernel label at the lilo prompt, lilo will
timeout and load the default
kernel.3
Building the
new Kernel
Compiling
the Kernel
- To
initate compilation, type:
- >
make zImage
This will create a kernel image called
zImage in the
/usr/src/linux/arch/i386/boot.
Go have a cup of coffee; this takes some
time. If you get the error "system too
large", type:
>
make bzImage
This will allow you to compile a big zImage.
This won't take as long.
- If you
selected any options to be modules you need to compile
those. Type:
- >
make modules
This will compile the options selected as
modules.
Next
type:
- >
make module_install
This will install all the modules.
Editing
/etc/lilo.conf
- Now copy
either the bzImage or the zImage into the
/boot directory.
> cp
/usr/src/linux/arch/i386/boot/bzImage
/boot/vmlinuz-<version-number>
This command copies the bzImage file into the
/boot directory and renames it to
vmlinuz-<version-number>.
- Open
/etc/lilo.conf
in a text editor and add the following lines
image=/boot/vmlinuz-<version
number>
label=newlinux-up
read-only
root=/dev/sda1
newlinux-up
would be the label for the new kernel
image.
- Save the
changes and quit the text editor.
- Now you
need to run lilo. Lilo will read the
/etc/lilo.conf file and make the
appropriate changes.
- Reboot
with your new kernel
Hacking the
Source Code on Schemp
There
are currently two source trees:
- /usr/src/kernel-2.2.17/linux
and
/usr/src/linux-2.2.14/linux
If you
would like to edit the source code, please do so in
the /usr/src/kernel-2.2.17/linux directory
only.
/usr/src/kernel-2.2.17/linux/net/ipv4
contains the source code for TCP, IP, UDP and
others. The code for the TIME-WAIT state is in
tcp.c
1
These option are only available in a custom
installation.
2
We installed Linux on a multiprocessor capable
motherboard. Therefore we had two kernel images:
one for multiprocessors and the other for a
uniprocessor. The two images can be distinguished
by the '-up' suffix, which stands for
uniprocessor.
3
In our case the multiproccessor capable kernel was
the default; therefore, we had to load the uniprocessor
kernel, modify the /etc/lilo.conf file to make the
uniprocessor kernel image the default kernel, and re-run
lilo to effect the change.
4
For obvious reasons, we suggest that you not include the
"Prompt for development of incomplete code versions"
option in the "Code Maturity Level Options". Even
though you might be tempted to include the option for
"Kernel hacking" you may not want to because it will make
the kernel less stable.
5
There are three configuration tools: make config, make
menuconfig, make xconfig.
i)
make config: This is the most basic configuration
tool. It is a text based interface. It also
does not let you go back to change an option. The
option defaults are capitalized.
ii)
make menuconfig: This is the one we used. It
provides a basic graphical user interface.
iii)
make xconfig: This is the most advanced tool. It
takes advantage of Xwindows. We have no experience
with it.
|