1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
<!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 “Should I compile a kernel for my system?” 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&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 > /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>
|