-
Notifications
You must be signed in to change notification settings - Fork 7
/
ch03.xml
221 lines (187 loc) · 7.61 KB
/
ch03.xml
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
<chapter id="LKN-chapter-retrieve-source">
<title>
Retrieving the kernel source
</title>
<!--
AO: I tried to add some simple but meaningful introductory
text. Feel free to substitute your own opinions.
gkh: looks good to me.
-->
<para>
When you're building your own kernel, you want the latest stable
release. Many distributions provide their own packages of kernel
sources, but these are rarely the most cutting-enge, recent
versions. The distribution packages have the advantage of being built
to be compatible with the compiler and other tools provided by the
distribution
(<xref linkend="LKN-chapter-requirements" /> explains the importance
of their being compatible) but they may not end up providing the
functionality or performance you want. If you can create your own
environment with the latest kernel, compiler, and other tools, you
will be able to build exactly what you want. This chapter focuses on
determining which kernel sources to download, and how to obtain them.
</para>
<sect1>
<title>What tree to use</title>
<para>
In the past, the Linux kernel was split into only two trees, the
"development" branch and the "stable" branch. The development branch was
denoted by an odd number for the second release number, while the
stable branch used even numbers. So, as an example, the 2.5.25 release was
a development kernel, while the 2.4.25 release is a stable release.
</para>
<para>
But after the 2.6 series was created, the kernel developers decided to
abandon this method of having two separate trees, and declared that all
2.6 kernel releases would be considered "stable", no matter how quickly
development was happening. The few months between the major 2.6
releases would allow kernel developers the time to add new features and
then stabilize them in time for the next release. Combined with this, a
"-stable" kernel branch has been created that releases bugfixes and
security updates for the past kernel release, before the next major 2.6
release happens.
</para>
<para>
This is all best explained with some examples, illustrated in <xref
linkend="kernel_releases-screenshot" />.
The kernel team released the 2.6.17 kernel as a stable release. Then the
developers started working on new features and started releasing the
<literal>-rc</literal> versions as development kernels so that people could
help test and debug the changes. After everyone agreed that the
development release was stable enough, it was released as the 2.6.18 kernel.
This whole cycle usually takes about two to three months, depending on a
variety of factors.
</para>
<figure id="kernel_releases-screenshot">
<title>Kernel development release cycle</title>
<graphic fileref="images/kernel_releases.png" scalefit="1"/>
</figure>
<para>
While the development of the new features was happening, the
2.6.17.1, 2.6.17.2, and other stable kernel versions were released,
containing bug fixes and security updates.
</para>
<para>
If you wish to just use the latest kernel for your work, it is recommended that
you use the stable kernel releases. If you wish to help the kernel
developers test the features of the next kernel release and give them
feedback, use the development kernel release. For the purpose of this
chapter, we will assume that you are using a stable kernel release.
</para>
</sect1>
<sect1>
<title>Where to find the kernel source</title>
<para>
All of the source code for the Linux kernel can be found on one of the
<emphasis>kernel.org</emphasis> sites, a worldwide network of servers that mirror the Linux
source code, enabling everyone to find a local server
close to him. This allows the main kernel servers to be
responsive to the mirror sites, and lets users download the needed files as
quickly as possible.
</para>
<para>
The main <systemitem role="url">http://www.kernel.org</systemitem>.
site shows all of the current kernel versions for the various different
kernel trees, as shown in <xref linkend="kernel.org-screenshot" />.
<figure id="kernel.org-screenshot">
<title>The main kernel.org web site</title>
<graphic fileref="images/kernel.org.png" scalefit="1"/>
</figure>
</para>
<para>
To download the latest stable kernel version, click on the
<emphasis>F</emphasis> character on the line for the kernel version. This
will download the full source tree. Or you can navigate to the proper
subdirectory for all of the 2.6 kernel versions,
<systemitem
role="url">http://www.us.kernel.org/pub/linux/kernel/v2.6/</systemitem>,
shown in <xref linkend="kernel.org-v2.6-screenshot" />.
<figure id="kernel.org-v2.6-screenshot">
<title>The 2.6 kernel source directory</title>
<graphic fileref="images/kernel.org.v2.6.png" scalefit="1"/>
</figure>
</para>
<para>
It is also possible to download the kernel source from the command line,
using the <command>wget</command> or <command>curl</command> utilities,
both of which should come with your Linux distribution.
</para>
<para>
To download the 2.6.17.8 kernel version using <command>wget</command>,
enter:
<screen>
$ <userinput>wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.8.tar.gz</userinput>
--17:44:55-- http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.8.tar.gz
=> `linux-2.6.17.8.tar.gz'
Resolving www.kernel.org... 204.152.191.5, 204.152.191.37
Connecting to www.kernel.org|204.152.191.5|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 51,707,742 (49M) [application/x-gzip]
100%[=============================================>] 51,707,742 35.25K/s ETA 00:00
18:02:48 (47.12 KB/s) - `linux-2.6.17.8.tar.gz' saved [51707742/51707742]
</screen>
To download it using <command>curl</command>:
<screen>
$ <userinput>curl http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.8.tar.gz -o linux-2.6.17.8.tar.gz</userinput>
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 49.3M 100 49.3M 0 0 50298 0 0:17:08 0:17:08 --:--:-- 100k
</screen>
</para>
<para>
For a quick and easy way to determine the latest kernel versions, use
the information available at
<systemitem
role="url">http://www.kernel.org/kdist/finger_banner</systemitem>,
illustrated by <xref linkend="kernel.org-finger_banner-screenshot" />.
<figure id="kernel.org-finger_banner-screenshot">
<title>Latest kernel version</title>
<graphic fileref="images/kernel.org_finger_banner.png" scalefit="1"/>
</figure>
</para>
</sect1>
<sect1>
<title>What to do with the source</title>
<para>
<!--
AO: I actually think a couple sentences are all you need
here. People who can't even manipulate a directory on a Linux system
can't hope to understand the kernel.
gkh: that's fine.
-->
Now that you have downloaded the proper kernel source, where is it supposed
to go? We suggest creating a local directory in your home directory called
<filename>linux/</filename> to hold all of the different kernel source
files:
<screen>
$ <userinput>mkdir ~/linux</userinput>
</screen>
Now move the source code into this directory:
<screen>
$ <userinput>mv ~/linux-2.6.17.8.tar.gz ~/linux/</userinput>
</screen>
And go into the <filename>linux/</filename> directory:
<screen>
$ <userinput>cd ~/linux</userinput>
$ <userinput>ls</userinput>
linux-2.6.17.8.tar.gz
</screen>
Now that the source code is in the proper directory, we need to uncompress
the tree:
<screen>
$ <userinput>tar -xzvf linux-2.6.17.8.tar.gz</userinput>
</screen>
The screen will be filled with files that are uncompressed, and you
will be left with the following in the <filename>linux/</filename>
directory:
<screen>
$ <userinput>ls</userinput>
linux-2.6.17.8.tar.gz
linux-2.6.17.8/
</screen>
</para>
<para>
</para>
</sect1>
</chapter>
<!-- vim: set ai tw=75 : -->