Linus s Baby: The Linux Kernel


Linus's Baby: The Linux Kernel

At the bottom of most Linux-related web pages and at the front of this (and just about every other) Linux book, there is a notice: Linux is a registered trademark by Linus Torvalds. In most cases in the larger world, posting such a notice is just another silly requirement imposed by lawyers on publishers and web designers. For this book, at least, it is but one way to acknowledge the debt we all owe to the Finnish programmer who started it all.

While the GNU Project to develop a free Unix-based operating system had been working on a functioning kernel for years, Torvalds wanted to do his computer science homework at home. So in August 1991, he ported the teaching operating system called Minix to the Intel 80386 platform and offered the code to readers of the Usenet newsgroup, comp.os.minix.

The Linux Source Tree

The kernel source code lives in a group of directories called the kernel source tree. This tree's structure is important because the process of compiling the kernel is automated.

When you compile a kernel, make is actually running a series of scripts. The scripts, make-files, expect to find pieces of the kernel code in specific places. If they are not there, the makefile breaks, and the kernel is incomplete. You will learn how to compile a kernel with make later in the chapter.

You don't need the kernel source code on your system for Linux to run you just need the compiled kernel binaries for that. If you ever want to compile a kernel, you need to install the kernel-sources package from YaST.

The sources are stored in /usr/src/linux, which contains several directories; the most important for you is the Documentation directory. In these files, you should find just about everything you need to know about the kernel and its various modules. In the subdirectories, you'll find text files with detailed information about all the various drivers for peripherals, file systems, and networking tasks patched into the kernel. These documents are written for programmers, but the advanced user can often glean much useful information as well.

Types of Kernels

There was a time when Linux kernels were monolithic a single block of code with all the instructions for the processor, motherboard, and other hardware specified within.

When changing hardware, you had to recompile the kernel to include the drivers for the new piece and remove the old drivers. This was important because unnecessary kernel modules took up memory, which was at a premium.

As the kernel code grew larger and the number of devices that you could add to a computer increased, recompiling became a nearly unbearable chore. So kernel hackers developed a new building method to solve the problem. Device drivers became modules that could be loaded and unloaded into the kernel when you needed them. With this modular approach, all the kernel code could be compiled at once, with most of the code compiled into modules. Adding new hardware involved loading a module in place of rebuilding the whole kernel.

The standard SUSE Linux kernel has some drivers compiled inline, as part of the kernel itself. These are the drivers required during the boot process. Kernel modules are loaded after login.

Note

Commonly, drivers for SCSI disk drives that you intend to boot are inline. If they aren't, you couldn't access the drive.

Ingenuity has gotten around this problem of needing inline drivers, however. You can use initrd to start a RAM disk. This creates a small kernel and the appropriate device driver, which accesses the device and loads the actual kernel. More about this later in the chapter.


Some code can be only inline or in a module (for technical reasons), but most code can be compiled either way. With fast modern processors and cheap memory, the performance differences are negligible, but they are of concern when installing Linux on an older, slower machine.

When compiling a kernel, you select inline or modular loading during the make config step that you'll learn more about later. Unless you have a specific reason to do otherwise, you should always choose modular loading when asked.



SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net