slackware-current/slackbook/html/system-configuration-kernel.html
Patrick J Volkerding 75a4a592e5 Slackware 13.37
Mon Apr 25 13:37:00 UTC 2011
Slackware 13.37 x86_64 stable is released!

Thanks to everyone who pitched in on this release: the Slackware team,
the folks producing upstream code, and linuxquestions.org for providing
a great forum for collaboration and testing.

The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a
dual-sided
32-bit/64-bit x86/x86_64 DVD.  Please consider supporting the Slackware
project by picking up a copy from store.slackware.com.  We're taking
pre-orders now, and offer a discount if you sign up for a subscription.

As always, thanks to the Slackware community for testing, suggestions,
and feedback.  :-)

Have fun!
2018-05-31 22:45:18 +02:00

354 lines
14 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>Selecting a Kernel</title>
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" />
<link rel="HOME" title="Slackware Linux Essentials" href="index.html" />
<link rel="UP" title="System Configuration" href="system-configuration.html" />
<link rel="PREVIOUS" title="System Configuration" href="system-configuration.html" />
<link rel="NEXT" title="Network Configuration" href="network-configuration.html" />
<link rel="STYLESHEET" type="text/css" href="docbook.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"
alink="#0000FF">
<div class="NAVHEADER">
<table summary="Header navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<th colspan="3" align="center">Slackware Linux Essentials</th>
</tr>
<tr>
<td width="10%" align="left" valign="bottom"><a href="system-configuration.html"
accesskey="P">Prev</a></td>
<td width="80%" align="center" valign="bottom">Chapter 4 System Configuration</td>
<td width="10%" align="right" valign="bottom"><a href="network-configuration.html"
accesskey="N">Next</a></td>
</tr>
</table>
<hr align="LEFT" width="100%" />
</div>
<div class="SECT1">
<h1 class="SECT1"><a id="SYSTEM-CONFIGURATION-KERNEL"
name="SYSTEM-CONFIGURATION-KERNEL">4.2 Selecting a Kernel</a></h1>
<p>The kernel is the part of the operating system that provides hardware access, process
control, and overall system control. The kernel contains support for your hardware
devices, so picking one for your system is an important setup step.</p>
<p>Slackware provides more than a dozen precompiled kernels that you can pick from, each
with a standard set of drivers and additional specific drivers. You can run one of the
precompiled kernels or you can build your own kernel from source. Either way, you need to
make sure that your kernel has the hardware support your system needs.</p>
<div class="SECT2">
<h2 class="SECT2"><a id="AEN1581" name="AEN1581">4.2.1 The <tt
class="FILENAME">/kernels</tt> Directory on the Slackware CD-ROM</a></h2>
<p>The precompiled Slackware kernels are available in the <tt
class="FILENAME">/kernels</tt> directory on the Slackware CD-ROM or on the FTP site in
the main Slackware directory. The available kernels change as new releases are made, so
the documentation in that directory is always the authoritative source. The <tt
class="FILENAME">/kernels</tt> directory has subdirectories for each kernel available.
The subdirectories have the same name as their accompanying boot disk. In each
subdirectory you will find the following files:</p>
<div class="INFORMALTABLE"><a id="AEN1587" name="AEN1587"></a>
<table border="0" frame="void" width="100%" class="CALSTABLE">
<col width="33%" />
<col width="67%" />
<thead>
<tr>
<th>File</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td><tt class="FILENAME">System.map</tt></td>
<td>The system map file for this kernel</td>
</tr>
<tr>
<td><tt class="FILENAME">bzImage</tt></td>
<td>The actual kernel image</td>
</tr>
<tr>
<td><tt class="FILENAME">config</tt></td>
<td>The source configuration file for this kernel</td>
</tr>
</tbody>
</table>
</div>
<p>To use a kernel, copy the <tt class="FILENAME">System.map</tt> and <tt
class="FILENAME">config</tt> files to your <tt class="FILENAME">/boot</tt> directory and
copy the kernel image to <tt class="FILENAME">/boot/vmlinuz</tt>. Run <tt
class="COMMAND">/sbin/lilo</tt>(8) to install LILO for the new kernel, and then reboot
your system. That's all there is to installing a new kernel.</p>
<p>The kernels that end with a .i are IDE kernels. That is, they include no SCSI support
in the base kernel. The kernels that end with .s are SCSI kernels. They include all the
IDE support in .i kernels, plus SCSI support.</p>
</div>
<div class="SECT2">
<h2 class="SECT2"><a id="SYSTEM-CONFIGURATION-KERNEL-COMPILE"
name="SYSTEM-CONFIGURATION-KERNEL-COMPILE">4.2.2 Compiling a Kernel from Source</a></h2>
<p>The question &#8220;Should I compile a kernel for my system?&#8221; is often asked by
new users. The answer is a definite maybe. There are few instances where you will need to
compile a kernel specific to your system. Most users can use a precompiled kernel and the
loadable kernel modules to achieve a fully working system. You will want to compile a
kernel for your system if you are upgrading kernel versions to one that we do not
currently offer in Slackware, or if you have patched the kernel source to get special
device support that is not in the native kernel source. Anyone with an SMP system will
definitely want to compile a kernel with SMP support. Also, many users find a custom
compiled kernel runs much faster on their machine. You may find it useful to compile the
kernel with optimizations for the specific processor in your machine.</p>
<p>Building your own kernel is not that hard. The first step is to make sure you have the
kernel source installed on your system. Make sure that you installed the packages from
the K series during the installation. You will also want to make sure you have the D
series installed, specifically the C compiler, GNU make, and GNU binutils. In general,
it's a good idea to have the entire D series installed if you plan on doing any kind of
development. You can also download the latest kernel source from <a
href="http://www.kernel.org/mirrors" target="_top">http://www.kernel.org/mirrors</a>.</p>
<div class="SECT3">
<h3 class="SECT3"><a id="AEN1624" name="AEN1624">4.2.2.1 Linux Kernel version 2.4.x
Compilation</a></h3>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">su -</kbd>
Password:
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /usr/src/linux</kbd>
</pre>
</td>
</tr>
</table>
<p>The first step is to bring the kernel source into its base state. We issue this
command to do that (note, you may wish to back-up the <tt class="FILENAME">.config</tt>
file as this command will delete it without warning):</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">make mrproper</kbd>
</pre>
</td>
</tr>
</table>
<p>Now you can configure the kernel for your system. The current kernel offers three ways
of doing this. The first is the original text-based question and answer system. It asks a
bunch of questions and then builds a configuration file. The problem with this method is
that if you mess up, you must start over. The method that most people prefer is the menu
driven one. Lastly, there is an X-based kernel configuration tool. Pick the one you want
and issue the appropriate command:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">#</samp> <kbd
class="USERINPUT">make config</kbd> (text-based Q&amp;A version)
<samp class="PROMPT">#</samp> <kbd
class="USERINPUT">make menuconfig</kbd> (menu driven, text-based version)
<samp class="PROMPT">#</samp> <kbd
class="USERINPUT">make xconfig</kbd> (X-based version, make sure you are in X first)
</pre>
</td>
</tr>
</table>
<div class="FIGURE"><a id="SYSTEM-CONFIGURATION-MAKE-MENUCONFIG"
name="SYSTEM-CONFIGURATION-MAKE-MENUCONFIG"></a>
<p><b>Figure 4-1. Kernel Configuration Menu</b></p>
<p><img src="system-configuration/make-menuconfig-w.png" /></p>
</div>
<p>New users will probably find <tt class="COMMAND">menuconfig</tt> to be the easiest to
use. Help screens are provided that explain the various parts of the kernel. After
configuring your kernel, exit the configuration program. It will write the necessary
configuration files. Now we can prepare the source tree for a build:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">make dep</kbd>
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">make clean</kbd>
</pre>
</td>
</tr>
</table>
<p>The next step is to compile the kernel. First try issuing the <tt
class="COMMAND">bzImage</tt> command below.</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">make bzImage</kbd>
</pre>
</td>
</tr>
</table>
<p>This may take a while, depending on your CPU speed. During the build process, you will
see the compiler messages. After building the kernel image, you will want to build any
parts of the kernel that you flagged as modular.</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">make modules</kbd>
</pre>
</td>
</tr>
</table>
<p>We can now install the kernel and modules that you compiled. To install the kernel on
a Slackware system, these commands should be issued:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">#</samp> <kbd
class="USERINPUT">mv /boot/vmlinuz /boot/vmlinuz.old</kbd>
<samp class="PROMPT">#</samp> <kbd
class="USERINPUT">cat arch/i386/boot/bzImage &#62; /vmlinuz</kbd>
<samp class="PROMPT">#</samp> <kbd
class="USERINPUT">mv /boot/System.map /boot/System.map.old</kbd>
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">cp System.map /boot/System.map</kbd>
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">make modules_install</kbd>
</pre>
</td>
</tr>
</table>
<p>You will want to edit <tt class="FILENAME">/etc/lilo.conf</tt> and add a section to
boot your old kernel in case your new one does not work. After doing that, run <tt
class="COMMAND">/sbin/lilo</tt> to install the new boot block. You can now reboot with
your new kernel.</p>
</div>
<div class="SECT3">
<h3 class="SECT3"><a id="AEN1686" name="AEN1686">4.2.2.2 Linux Kernel Version
2.6.x</a></h3>
<p>The compilation of a 2.6 kernel is only slightly different from a 2.4 or a 2.2 kernel,
but it is important that you understand the differences before delving in. It's no longer
necessary to run <tt class="COMMAND">make dep</tt> and <tt class="COMMAND">make
clean</tt>. Also, the kernel compilation process is not as verbose in the 2.6 kernel
series. This results in a build process that is easier to understand, but has some short
comings as well. If you have trouble building the kernel, it's highly recommended that
you turn verbosity back up. You do this simply by appending <var class="OPTION">V=1</var>
to the build. This allows you to log more information that could help a kernel developer
or other friendly geek aid you in resolving the issue.</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">make bzImage V=1</kbd>
</pre>
</td>
</tr>
</table>
</div>
</div>
<div class="SECT2">
<h2 class="SECT2"><a id="SYSTEM-CONFIGURATION-KERNEL-MODULES"
name="SYSTEM-CONFIGURATION-KERNEL-MODULES">4.2.3 Using Kernel Modules</a></h2>
<p>Kernel modules are another name for device drivers that can be inserted into a running
kernel. They allow you to extend the hardware supported by your kernel without needing to
pick another kernel or compile one yourself.</p>
<p>Modules can also be loaded and unloaded at any time, even when the system is running.
This makes upgrading specific drivers easy for system administrators. A new module can be
compiled, the old one removed, and the new one loaded, all without rebooting the
machine.</p>
<p>Modules are stored in the <tt class="FILENAME">/lib/modules/<var
class="REPLACEABLE">kernel version</var></tt> directory on your system. They can be
loaded at boot time through the <tt class="FILENAME">rc.modules</tt> file. This file is
very well commented and offers examples for major hardware components. To see a list of
modules that are currently active, use the <tt class="COMMAND">lsmod</tt>(1) command:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">lsmod</kbd>
Module Size Used by
parport_pc 7220 0
parport 7844 0 [parport_pc]
</pre>
</td>
</tr>
</table>
<p>You can see here that I only have the parallel port module loaded. To remove a module,
you use the <tt class="COMMAND">rmmod</tt>(1) command. Modules can be loaded by the <tt
class="COMMAND">modprobe</tt>(1) or <tt class="COMMAND">insmod</tt>(1) command. <tt
class="COMMAND">modprobe</tt> is usually safer because it will load any modules that the
one you're trying to load depends on.</p>
<p>A lot of users never have to load or unload modules by hand. They use the kernel
autoloader for module management. By default, Slackware includes <var
class="OPTION">kmod</var> in its kernels. <var class="OPTION">kmod</var> is a kernel
option that enables the kernel to automatically load modules as they are requested. For
more information on <var class="OPTION">kmod</var> and how it is configured, see <tt
class="FILENAME">/usr/src/linux/Documentation/kmod.txt</tt>. You'll have needed to have
the kernel source package, or downloaded kernel source from <a href="http://kernel.org"
target="_top">http://kernel.org</a>.</p>
<p>More information can be found in the man pages for each of these commands, plus the
<tt class="FILENAME">rc.modules</tt> file.</p>
</div>
</div>
<div class="NAVFOOTER">
<hr align="LEFT" width="100%" />
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="system-configuration.html"
accesskey="P">Prev</a></td>
<td width="34%" align="center" valign="top"><a href="index.html"
accesskey="H">Home</a></td>
<td width="33%" align="right" valign="top"><a href="network-configuration.html"
accesskey="N">Next</a></td>
</tr>
<tr>
<td width="33%" align="left" valign="top">System Configuration</td>
<td width="34%" align="center" valign="top"><a href="system-configuration.html"
accesskey="U">Up</a></td>
<td width="33%" align="right" valign="top">Network Configuration</td>
</tr>
</table>
</div>
</body>
</html>