old-www/HOWTO/From-PowerUp-To-Bash-Prompt...

115 lines
5.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>From Power Up To Bash Prompt: The Linux Kernel</TITLE>
<LINK HREF="From-PowerUp-To-Bash-Prompt-HOWTO-5.html" REL=next>
<LINK HREF="From-PowerUp-To-Bash-Prompt-HOWTO-3.html" REL=previous>
<LINK HREF="From-PowerUp-To-Bash-Prompt-HOWTO.html#toc4" REL=contents>
</HEAD>
<BODY>
<A HREF="From-PowerUp-To-Bash-Prompt-HOWTO-5.html">Next</A>
<A HREF="From-PowerUp-To-Bash-Prompt-HOWTO-3.html">Previous</A>
<A HREF="From-PowerUp-To-Bash-Prompt-HOWTO.html#toc4">Contents</A>
<HR>
<H2><A NAME="s4">4. The Linux Kernel</A></H2>
<P>
<P>The kernel does quite a lot really. I think a fair way of summing it up is that it makes the hardware do what the programs want, fairly and efficiently.
<P>
<P>The processor can only execute one instruction at a time, but Linux systems
appear to be running lots of things simultaneously. The kernel acheives this by
switching from task to task really quickly. It makes the best use of the processor
by keeping track of which processes are ready to go, and which ones are waiting
for something like a record from a hard disk file, or some keyboard input.
This kernel task is called scheduling.
<P>
<P>If a program isn't doing anything, then it doesn't need to be in RAM. Even a
program that is doing something, might have parts that aren't doing anything.
The address space of each process is divided into pages. The Kernel keeps track of
which pages of which processes are being used the most. The pages that aren't
used so much can be moved out to the swap partition. When they are needed again,
another unused page can be paged out to make way for it. This is virtual memory
management.
<P>
<P>If you have ever compiled your own Kernel, you will have noticed that there are
many many options for specific devices. The kernel contains a lot of specific
code to talk to diverse kinds of hardware, and present it all in a nice uniform
way to the application programs.
<P>
<P>The Kernel also manages the filesystem, interprocess communication, and a lot
of networking stuff.
<P>
<P>Once the kernel is loaded, the first thing it does is look for an <CODE>init</CODE> program to run.
<P>
<H2><A NAME="ss4.1">4.1 Configuration</A>
</H2>
<P>Most of the configuration of the kernel is done when you build it, using
<CODE>make menuconfig</CODE>, or <CODE>make xconfig</CODE> in <CODE>/usr/src/linux/</CODE>
(or wherever your Linux kernel source is). You can reset the default video
mode, root filesystem, swap device and RAM disk size using <CODE>rdev</CODE>. These
parameters and more can also be passed to the kernel from lilo. You can give lilo
parameters to pass to the kernel either in lilo.conf, or at the lilo prompt.
For example if you wanted to use hda3 as your root file system instead of hda2,
you might type
<P>
<PRE>
LILO: linux root=/dev/hda3
</PRE>
<P>
<P>If you are building a system from source, you can make life a lot simpler by
creating a ``monolithic'' kernel. That is one with no modules. Then you don't
have to copy kernel modules to the target system.
<P>
<P>NOTE: The <CODE>System.map</CODE> file is used by the kernel logger to determine
the module names generating messages. The program <CODE>top</CODE> also uses this
information. When you copy the kernel to the target system, copy
<CODE>System.map</CODE> too.
<P>
<H2><A NAME="ss4.2">4.2 Exercises</A>
</H2>
<P>Think about this: <CODE>/dev/hda3</CODE> is a special type of file that
describes a hard disk partition. But it lives on a file system just like all
other files. The kernel wants to know which partition to mount as the root
filesystem - it doesn't have a file system yet. So how can it read
<CODE>/dev/hda3</CODE> to find out which partition to mount?
<P>
<P>If you haven't already: build your own kernel. Read all the help information
for each option.
<P>
<P>See how small a kernel you can make that still works. You can learn a lot by leaving the wrong things out!
<P>
<P>Read ``The Linux Kernel'' (URL below) and as you do, find the parts of the source code that it refers to. The book (as I write) refers to kernel version 2.0.33, which is pretty out of date. It might be easier to follow if you download this old version and read the source there. Its amazing to find bits of C code called ``process'' and ``page''.
<P>
<P>Hack! See if you can make it spit out some extra messages or something.
<P>
<P>
<H2><A NAME="Kernel"></A> <A NAME="ss4.3">4.3 More Information</A>
</H2>
<P>
<UL>
<LI><CODE>/usr/src/linux/README</CODE> and the contents of
<CODE>/usr/src/linux/Documentation/</CODE>
(These may be in some other place on your system)</LI>
<LI>
<A HREF="http://mirror.aarnet.edu.au/linux/LDP/HOWTO/Kernel-HOWTO.html">The Kernel HOWTO</A> </LI>
<LI>The help available when you configure a kernel using
<CODE>make menuconfig</CODE> or <CODE>make xconfig</CODE> </LI>
<LI>
<A HREF="http://mirror.aarnet.edu.au/linux/LDP/LDP/">The Linux Kernel (and other LDP Guides)</A></LI>
<LI> source code, see
<A HREF="http://www.netspace.net.au/~gok/power2bash">Building a Minimal Linux System from Source Code</A>
for urls</LI>
</UL>
<P>
<P>
<HR>
<A HREF="From-PowerUp-To-Bash-Prompt-HOWTO-5.html">Next</A>
<A HREF="From-PowerUp-To-Bash-Prompt-HOWTO-3.html">Previous</A>
<A HREF="From-PowerUp-To-Bash-Prompt-HOWTO.html#toc4">Contents</A>
</BODY>
</HTML>