LPIC2 Chap 1
The Linux Kernel
The kernel is the core software of the Linux operating system. It is responsible for communication with hardware using device drivers, scheduling (prioritizing tasks) and providing a common software interface for programmers. The kernel file zImage or bzImage is typically located in the /boot directory. The zImage file format is not commonly used and has been almost completely replace by a compressed version bzImage.
Compiling a Kernel
One of the great advantages of using Linux over other operating systems is the kernel can be customized for various needs from building clusters to small embedded devices used in house hold appliances. Recompiling the kernel is typically done to support new hardware devices. The current version can be downloaded from http://www.kernel.org. There are three numbers in a kernel version major, minor and patch level.
2.6.14
(Diagram arrows point to numbers with labels)
The major version (first number) rarely changes usually after a complete architecture change. The second number minor version indicates whether it is a production or testing kernel. Stable kernels have even numbers and testing kernels have odd numbers. The last number in the kernel version is the patch level. New patches some out often, sometimes even weekly.
Once the kernel is downloaded it should be extracted to the /usr/src directory.
cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.10.tar.bz2
(wget is a utility for non-interactive downloading from the Internet)
tar –jxvf linux-2.6.10.tar.bz2
ln –s linux linux-2.6.10
The third command tar an extraction utility can use some of the following switches:
-j, --bzip2 --- Decompress file with bzip2, used for files with .bz2 extensions
-z, --gzip --- Decompress file with gzip, use for files with .gz extensions
-x --- Extract the archive
-v --- Be verbose, list files du -v --- Be verbose, list files during extraction
-f --- Precedes archive file name or device
The last command ln creates a symbolic link (shortcut) to the kernel source code at /usr/src/linux. Many programs will look for kenerl source files in this location first. Once the kernel has been extracted you need to configure its settings. There are three basic commands you can configure a kenrel using.
make config
make menuconfig
make xconfig
Using make config is not recommended, it will display options to add to your new kernel one item at a time. If you make a mistake you can't go back and make changes. By running the make menuconfig command you will get a graphical menu that you can use to add drivers and select modules.
In the kernel configuration menu you will be able to navigate using arrow keys to move up or down and the enter to select sub menus. You will have three options on most items to select (X), (M) and (). These represent install, install as a module and do not install respectively. Use the space bar to toggle though the various options.
Installing a device driver as a modules as opposed to making it part of the core kernel allows you to be able to dynamically load and unload that particular driver during run time. This can keep your kernel image small and make sure that you load only needed drivers. However, in many situations it can be better to not to use modules. For example, if your modules were located on a SCSI drive you may need to have the kernel recognize the drive to load modules without needed to have the modules loaded.
Page 2
