linux kernel basics

Upload: cluelessuser

Post on 05-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Linux Kernel Basics

    1/5

    Linux Kernel Basics

  • 8/2/2019 Linux Kernel Basics

    2/5

    Linux Kernel Basics

    The Linux Kernel is the core of what makes the Linux operating systems. The kernel is whatcontrols how your system interacts with hardware and software.

    As the core of the system, the kernel has direct access to certain services that communicatewith the systems hardware that no other program has access to. If a program wants to performa 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 thekernel for permission first. The kernel analyzes the program's request and proceeds to doseveral 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 punishedfor its actions.

    If an application that got the "ok" from the kernel decides to write some data to a memorylocation outside its allocated block(s), the kernel will be forced to kill that application and do acore 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 thatthe application was using to the hard drive just before the kernel kills that application.

    A Conversation with the Kernel

    (application) Hello Mr. Kernel, Could have some memory to run and play in?H

    (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 pay!w

    (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 theentire Linux operating system, it just kills the application or process that has stepped out side itsmemory the kernel initially allocated for it. After a core dump the kernel just goes about itsbusiness as usual answering requests from other processes on the system.

  • 8/2/2019 Linux Kernel Basics

    3/5

    Configuring the KernelThe kernel is usually compiled like other C programs using the "make" command. Make is asmart program that does most of the compilation processing using configuration information youprovide via ( xconfig, config, and menuconfig -- see below for more details.). So you canactually 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 withyour kernel, you have the options of:

    1. Make config

    A text based interactive program that helps you config the kernel by answering Y-yes N-no 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/disabledwith radio buttons and other common GUI interactions. ( very user friendly )w

    There is help inside the xconfig program, just use the "help" button. if you need help.T

    Be careful which options you disable when configuring the kernel.B

    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 greatflexibility in regards to a wide variety of hardware driver support. They often include all of themost commonly used hardware device drivers and most of the kernel options. Generic kernelslike this are created to deal with what ever type hardware you have installed, but they areusually inefficient and large. This means longer boot time, and less memory for yourapplications to run in. Reconfiguring the kernel is used for cleaning out, and getting rid of extradrivers and options not needed for your system. Once you have cleaned out the unusedmaterials your kernel will be faster, cleaner and more efficient to run.

  • 8/2/2019 Linux Kernel Basics

    4/5

    Compiling and Using the New KernelIt is recommended to start building from a clean slate. You should first do a "make mrproper" inthe directory of your kernel ( usually "/usr/src/linux" on most Linux systems. The "makemrproper" command removes any configuration files along with the remains of any previouskernel 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 driversin your kernel are dependent on other drivers.

    Then do:T

    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"m

    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 accessedby the boot loader "LILO". If you have a new kernel and want to use it you should tell LILOabout 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/hda2timeout = 500prompt

    Default = linuxbox #linuxbox is default

    kernelvga = normalread-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-1label = linuxboxvga = 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/zImagelabel = customkernelvga = normalroot = /dev/hda2

  • 8/2/2019 Linux Kernel Basics

    5/5

    # End of CUSTOM KERNEL section

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

    Final ThoughtsReconfiguring the kernel can have it's advantages. As stated earlier the Kernel is the core overthe whole Linux OS. It is the master of the OS who gives permissions to applications and cantake those permissions away. You are able to modify the core of Linux, make it faster cleanerand in some case recompiling the kernel fixes some things. For example, if your kernel isconfigured for some hardware you don't have, the kernel may want to search for a hardwarecomponent to make sure it's there or not, that is if the driver for that device is compiled into thekernel. This is some cases may cause some problems or performance issues.

    The kernel handles memory management, system processes and controls and keeps tabs onsystem resource making sure things are working correctly.