Previous Next Table of Contents

4. Kernel questions

4.1 Q: What's a kernel?

A: It is a "program" that executes when you boot your computer. It is stored in a file which should _NOT_ be erased. A kernel is a like a program that comunicates with the computer parts, so they'll know what to do. Right now when you are reading this, the kernel sends the data which are read from the keyboard to the cpu which sends it to the videochip, which sends it to your monitor. In other words, the "basement" of the operating system.

4.2 Q: How do I build a custom kernel?

A: First you need the kernel source and the GNU C compiler. Then you need two links in the /usr/include directory which are "asm" and "linux". Those links points to the kernel include directory so the header files can be found. Then you just go into the kernel source tree "cd /usr/src/linux" and type "make config". If you already made a kernel before you need to do "make mrproper" before you start bouiding your new kernel. This command will erase all previous compiled modules and configuration files so the new kernel won't be messed with the last one. Then you can do "make menuconfig" and a configuration program appears. The program will ask you some questions about your hardware and some other questions what do you wanna have included in your kernel. Be sure you include your right pieces of hardware otherwise you may not be able to use it. If you have a special network card, or a special cdrom you need to pick the right one. You can read the documentation in the kernel Documentation/ directory. It is pretty good for begginers who doesnt know what they are going to do. So when you build your hardware database you need to make the kernel image. So make "make zImage". This will take quite a while.. On my(xopy) 486 dx2 66MHz with 16MB of RAM and with a SCSI drive it takes about 40 minutes :) So i suggest that you get yourself some beer and go watch TV for a while.

4.3 Making modules

Next when the image is builded you need to compile the modules you included in the config section. Type "make modules" to compile them, this in in most cases way faster than making the kernel image and when the modules are done you need to install them with a command "make modules_install". Now you have your modules in /lib/modules/(kernel version) and your kernel image is in /usr/src/linux/arch/i386/boot/zImage. Most users copy their images to the root, so let's us copy the file too.

4.4 LILO (LInux LOader)

The next thing is to tell LILO (LInux LOader) which kernel to load at boot time. This is done by a file in /etc/ directory called lilo.conf. Just open the file with your favorite editor and the file looks like:


   boot=/dev/hda

   map=/boot/map

   install=/boot/boot.b

   vga=5

   image=/kernel

        label=Linux

        root=/dev/hda3

        read-only

   image=/zImage

        label=test

        root=/dev/hda3

        read-only

   other=/dev/hda1

        label=dos

        table=/dev/hda

This example shows how we will install lilo on our first disk in the Master Boot Record "/dev/hda", the map file is located in "/boot/map" and the boot data is located in "/boot/boot.b". As an option we have here "vga=5", this is just a string which tells the krenel to put the textmode in 80x30 characters (if you want a whole list try "vga=ask" and it will show you the video mode list). Then we come in a part where we specify our kernel. I have 2 kernel images, both are located in the / directory. One is /kernel (this one i just compiled) and /zImage (last one in case the new kernel doesn't work). You should always keep the old kerenl i case the new one doesn't work or you cant be able to boot back in linux :(. The label defines how we call the kerenl in the time we boot, the root assigns where we have the init and all programs for linux, and we should boot linux partitions with read-only. The "other" section is a DOS boot drive. Here DOS boots from disk 1 partition 1 "/dev/hda1" and i need to hold "shift" when LILO is prompted to enter the string "dos" (as the label string says) and this will cause LILO to boot into dos. At the end save your lilo.conf file and run the command "lilo" at your command prompt (you need to be root for doing this) and a new image of lilo will be installed. Then all you need is to reboot (ctrl+alt+del) and wait. If something goes wrong hold shift when booting and write test so the old kernel will boot. If it boots and you are setisfied with the new kernel run "depmod" to build module dependences (note some distributions already do this at boot time). And now you are set.

4.5 Comments

Maybe just a word more about switching from 1.2.x to 2.0.x kernels. Since linux 2.0.0 was relased it is a huge diference between 1.2.13 (last 1.2 kernel). Maybe some programs won't work, especially those who needs /proc filesystem. You need to upgrade some linux packets as it is described in the kernel Documentation/ directory. Check CHANGES for more detail. I suggest you to get a new distribution which runs already a 2.0.x kernel and install it.


Previous Next Table of Contents