old-www/LDP/LG/issue75/piszcz.html

163 lines
12 KiB
HTML

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.79 [en] (X11; U; Linux 2.4.17 i686) [Netscape]">
<title>Why I wrote Install Kernel (ik) and How It Works LG #75</title>
<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#0000AF" alink="#FF0000">
<!-- *** END HTML header *** -->
<center><a href="http://www.linuxgazette.com/"><img SRC="../gx/lglogo.png" ALT="LINUX GAZETTE" BORDER=0 height=124 width=600></a>
<br>
<!-- *** BEGIN navbar *** -->
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="peda.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue75/piszcz.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="spiel.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
<!-- *** END navbar *** -->
</center>
<!--endcut ============================================================-->
<center>
<h4>
"Linux Gazette...<i>making Linux just a little more fun!</i>"</h4></center>
<hr>
<p><!--===================================================================-->
<center>
<h1>
<font color="#800000">Why I wrote Install Kernel (ik) and How It Works</font></h1></center>
<center>
<h4>
By <a href="mailto:war@starband.net">Justin Piszcz</a></h4></center>
<hr>
<p><!-- END header -->
<p>ik (Install Kernel) is available at
<a href="http://freshmeat.net/projects/ik">http://freshmeat.net/projects/ik</a>
and <a href="http://www.ramdown.com/war/ik">http://www.ramdown.com/war/ik</a>.
<p>In December 2000, after four years of using Linux, compiling and installing
kernels became a waste of my time. I chose to write my own kernel installation
and setup script called Install Kernel, because no other scripts existed
at the time, and I needed something that would install the Linux kernel
and automatically setup my bootloader configuration file with no user intervention.
Install Kernel interfaces with the Linux operating system by moving and
editing files. When not using ik, the majority of time consumed when updating
a kernel mainly consists of moving files around and setting up configuration
files. The ik script has three basic parts: dependency checks, compiling
the kernel and moving the files to their proper locations, and editing
boot loader configuration files. Install Kernel aims to help&nbsp; people
who are either new to installing the kernel or people who choose to use
their time efficiently.
<p>Every operating system has some type of kernel; the kernel is the core
of the operating system. The current kernel version as of this writing
is Linux 2.4.17. Most users either recompile or upgrade their kernels.
One may choose to upgrade his or her kernel in order to add support for
a certain device attached to his or her computer. For instance, if one
bought a Universal Serial Bus (USB) scanner, he or she would have to make
the appropriate changes to the kernel configuration file, and recompile
and install the new kernel. Reasons for upgrading the kernel may include
a better virtual memory subsystem, or important security fixes. An example
would be Linux kernel version 2.4.11. This kernel was vulnerable to a symlink
denial of service attack, prompting users running 2.4.11 to immediately
upgrade to 2.4.12 when it became available due to this vulnerability. These
are the fundamental reasons of why one may want to either recompile or
upgrade his or her kernel.
<p>Install Kernel interfaces with the Linux operating system by running
a series of functions or groups of commands that automate the compiling
or recompiling and installation process. It consists of three groups of
functions: checking dependencies, building the kernel and moving files,
and editing the boot loader configuration file. Grouping all of the functions
in these three groups makes maintaining and altering the script much easier.
Install Kernel can also be considered a program, because a program does
checking and makes choices accordingly. A script is usually a file, which
contains a certain number of commands with no logic in mind. Therefore,
while ik is technically a script, it can also be called a program.
<p>Dependency checks are to make sure the current system configuration
and settings are properly setup before proceeding with the kernel build.
There are seven dependency checks, they are: a root check, space check,
link check, boot check, boot loader check, configuration check, and a module
check. First, the root check makes sure the user is a super user; which
means they are capable of editing important system files only accessible
to the root account. The space check makes sure there is at least 200 megabytes
available. The kernel source these days is around 150 megabytes just for
the source code. When one compiles the kernel, it may increase the size
to 50 megabytes or more. Therefore, ik checks for at least 200MB available
in order to successfully compile the kernel without running out of space.
Next, it is not required, but it is standard to have a symbolic link of
/usr/src/linux pointing to /usr/src/linux-x.y.z. The fourth check makes
sure the user has a /boot directory, this is where the Linux kernel files
will be installed to. The fifth check determines the bootloader that will
be used. There are two main boot loaders in Linux. LILO and GRUB are the
two most popular for booting the operating system. This check accurately
finds whether the kernel was booted from either LILO or GRUB by checking
which bootloader was used last. It then tells the rest of the script to
edit the correct one accordingly. The sixth configuration check is to make
sure users have created a proper kernel configuration file, which is used
in the process of building the Linux kernel. The final check is a module
check, if modules are turned off, the script will determine this and alter
the installation process to install with no module support. The main idea
behind the depdency checks is to make sure the user cannot damage his or
her system if they do not do something right.
<p>The installation process also contains seven functions. The installation
process is usually several commands. However, because of the differences
that can occur in a user's configuration file, each part of the building
process must be checked and the building process may need to be altered.
The first function makes sure the dependencies are setup correctly for
all files in the kernel source tree. The second function deletes stale
object files and or old kernel files. Next, the third function is the kernel
build function; this function runs a command to build the Linux kernel.
Next, functions four and five make and install modules if the user had
specified module support in his or her kernel configuration file. The sixth
function moves the Linux kernel and its System dependency map to the boot
partition. The last function of the build process sets up module dependencies
for the new kernel if modules were defined. The installation process also
includes a small error check for each part of the kernel build process.
If any part of the kernel build process fails; the script will abort, not
modifying any boot loader configuration files. This is important; because
if it did not abort, it may alter the boot loader configuration files,
thus rendering the system unbootable. It is important to support every
Linux configuration possible because of the wide use of this script.
<p>The boot loader configuration and setup process is probably the most
important aspect of installing a new kernel. An improper boot loader configuration
may leave one with system that does not boot; or simply does not boot the
new kernel. It is also important, as some systems may have two or more
boot loaders installed. There are four functions defined for this process.
The first function uses the boot loader, which was defined during the configuration
checks. The second function defines where the LILO or GRUB configuration
files are located. Next, depending on which boot loader is found, either
LILO or GRUB configuration files are edited automatically by sed. Sed is
a stream editor, which edits a file with no user intervention. If user
intervention were required, the user would have to be present between certain
parts of the kernel installation. With ik, it makes efficient use of a
user's time because only one command needs to be entered to complete the
entire installation and setup process.
<p>Install Kernel is a useful tool for those who are new to Linux, rebuild
their kernel often, or value their time. It reduces the commands for installing
the kernel from about thirteen to one. Users new to Linux may find this
attractive. This is because the entire process is automated; and if something
is not correct, in most cases ik will notify the user what is incorrect,
and how to fix the error. On the other side, for experienced users who
do not wish to spend valuable time installing a new kernel, this is also
very handy. Install Kernel is efficient by requiring no user intervention
and reducing time spent on kernel installs, and effective by giving new
to Linux the option for an easy kernel upgrade.&nbsp;<!-- *** BEGIN bio *** --><!-- *** END bio *** --><!-- *** BEGIN copyright *** -->
<p>
<hr><!-- P -->
<center>
<h5>
Copyright &copy; 2002, Justin Piszcz.<br>
Copying license <a href="../copying.html">http://www.linuxgazette.com/copying.html<br>
</a>Published in Issue 75 of <i>Linux Gazette</i>, February 2002</h5></center>
<!-- *** END copyright *** --><!--startcut ==========================================================-->
<hr>
<center>
<p>
<!-- *** BEGIN navbar *** -->
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="peda.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue75/piszcz.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="spiel.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
<!-- *** END navbar *** -->
</center>
</body>
<!--endcut ============================================================-->
</html>