You are on page 1of 5

Linux Kernel Basics

Linux Kernel Basics


The Linux Kernel is the core of what makes the Linux operating systems. The kernel is what controls how your system interacts with hardware and software. As the core of the system, the kernel has direct access to certain services that communicate with the systems hardware that no other program has access to. If a program wants to perform a special task, then it must talk with the kernel first. When a program wants to read or write data to a disk or certain parts of memory, it asks the kernel for permission first. The kernel analyzes the program's request and proceeds to do several tasks for that program. The kernel is very strict and will not allow programs to get away with illegal operations. If a program operates against what the kernel says, it must be punished for its actions. If an application that got the "ok" from the kernel decides to write some data to a memory location outside its allocated block(s), the kernel will be forced to kill that application and do a core dump. A "core dump" is an operation a kernel carries out when an application tries to perform a task it is not allowed to do. The kernel then dumps the address space in memory that the application was using to the hard drive just before the kernel kills that application. A Conversation with the Kernel (application) H Hello Mr. Kernel, Could have some memory to run and play in? (kernel) Hmm... Ok, but if you try to run outside the memory space allocate for you then I am going to stop you! t (application) Ok then, it's a deal. . . . . (kernel) Hey! I never gave you permission to write data in that memory segment, you will w pay! (application) Oh no??.... I didn't mean it.. I.. I.. AHHHH.... ***Dead*** (core dump). (kernel) Ask me next time you want to do something like that! (kernel) When will those programs ever listen?! Usually the process of killing an application that was "bad" does not bring down or crash the entire Linux operating system, it just kills the application or process that has stepped out side its memory the kernel initially allocated for it. After a core dump the kernel just goes about its business as usual answering requests from other processes on the system.

Configuring the Kernel


The kernel is usually compiled like other C programs using the "make" command. Make is a smart program that does most of the compilation processing using configuration information you provide via ( xconfig, config, and menuconfig -- see below for more details.). So you can actually compile the program in which you're configuring the kernel with. There are a few ways in which to configure the kernel. Depending on what you want to do with your kernel, you have the options of:

1.

Make config A text based interactive program that helps you config the kernel by answering Y-yes Nno questions.

2.

Make menuconfig Interactive menu configuration program, selections in the kernel are made using toggle switches.

Make xconfig

A menu is displayed in x-Windows, and all possible options or modules are enabled/disabled w with radio buttons and other common GUI interactions. ( very user friendly ) T There is help inside the xconfig program, just use the "help" button. if you need help. B Be careful which options you disable when configuring the kernel. It's recommended you read more on configuring the kernel before you start, the kernel is NOT something you was to play carelessly with!

Most installs of Linux have relatively big kernels by default. These kernels provide you with great flexibility in regards to a wide variety of hardware driver support. They often include all of the most commonly used hardware device drivers and most of the kernel options. Generic kernels like this are created to deal with what ever type hardware you have installed, but they are usually inefficient and large. This means longer boot time, and less memory for your applications to run in. Reconfiguring the kernel is used for cleaning out, and getting rid of extra drivers and options not needed for your system. Once you have cleaned out the unused materials your kernel will be faster, cleaner and more efficient to run.

Compiling and Using the New Kernel


It is recommended to start building from a clean slate. You should first do a "make mrproper" in the directory of your kernel ( usually "/usr/src/linux" on most Linux systems. The "make mrproper" command removes any configuration files along with the remains of any previous kernel builds or scraps that may be lying about in the source tree. (Another way to start with a "clean" build is to do a "make clean") Then a "make dep" should follow the "make clean/mrproper". - This will figure out what drivers in your kernel are dependent on other drivers. T Then do: m make in "/usr/src/linux/" will give a kernel called: "vmlinux" m make bzImage in "/usr/src/linux" will give you a commpressed kernel called "bzImage" What ever name your kernel is make sure it's correct in the lilo.conf file. ( see LILO below for details ) Before rebooting after the kernel compile make sure there is an entry for the new kernel in your "/etc/lilo.conf" file, if no entry is listed there, then the new kernel will not be directly accessed by the boot loader "LILO". If you have a new kernel and want to use it you should tell LILO about it. Then we will Update LILO with the new Kernel for use. LILO: Lilo is a boot loader that most linux users use for booting there Linux boxes Example of a "lilo.conf" file ( usually located in "/etc/" ) # This line is a comment line #LILO global section boot = /dev/hda2 timeout = 500 prompt

Default = linuxbox #linuxbox is default


kernel vga = normal read-only #End of globol section ends # bootable kernel "vmlinuz-2.0.36-1" in directory "/boot/" # kernel number one image = /boot/vmlinuz-2.0.36-1 label = linuxbox vga = normal root = /dev/hda2 #end of kernel one section # bootable kernel "zImage" in directory "/usr/src/linux/" # THE NEW CUSTOM KERNEL! image = /usr/scr/linux/zImage label = customkernel vga = normal root = /dev/hda2

# End of CUSTOM KERNEL section Note: After compiling your new kernel make sure the "CUSTOM KERNEL" section is added to your LILO configuration file ( usually "/etc/lilo.conf" )

Final Thoughts
Reconfiguring the kernel can have it's advantages. As stated earlier the Kernel is the core over the whole Linux OS. It is the master of the OS who gives permissions to applications and can take those permissions away. You are able to modify the core of Linux, make it faster cleaner and in some case recompiling the kernel fixes some things. For example, if your kernel is configured for some hardware you don't have, the kernel may want to search for a hardware component to make sure it's there or not, that is if the driver for that device is compiled into the kernel. This is some cases may cause some problems or performance issues. The kernel handles memory management, system processes and controls and keeps tabs on system resource making sure things are working correctly.

You might also like