1
<!-- retain these comments for translator revision tracking -->
2
<!-- original version: 16990 untranslated -->
4
<sect1 id="kernel-baking"><title>Compiling a New Kernel</title>
7
Why would someone want to compile a new kernel? It is often not
8
necessary since the default kernel shipped with Debian handles most
9
configurations. However, it is useful to compile a new kernel in order
15
handle special hardware needs, or hardware conflicts with the pre-supplied
21
handle hardware or options not included in the stock kernel, such as
26
<listitem arch="i386"><para>
28
The compact and idepci flavors don't come with sound. Although
29
the vanilla kernel does, it might not work for other reasons.
34
optimize the kernel by removing useless drivers to speed up boot
40
use options of the kernel which are not supported by the default
41
kernel (such as network firewalling)
46
run a updated or development kernel
51
impress your friends, try new things
58
<sect2><title>Kernel Image Management</title>
61
Don't be afraid to try compiling the kernel. It's fun and profitable.
65
To compile a kernel the Debian way, you need some packages:
66
<classname>kernel-package</classname>,
67
<classname>kernel-source-&kernelversion;</classname> (the most recent version
68
at the time of this writing), <classname>fakeroot</classname> and a
69
few others which are probably already installed (see
70
<filename>/usr/share/doc/kernel-package/README.gz</filename> for the
75
This method will make a .deb of your kernel source, and, if you have
76
non-standard modules, make a synchronized dependent .deb of those
77
too. It's a better way to manage kernel images;
78
<filename>/boot</filename> will hold the kernel, the System.map, and a
79
log of the active config file for the build.
83
Note that you don't <emphasis>have</emphasis> to compile your kernel
84
the ``Debian way''; but we find that using the packaging system to
85
manage your kernel is actually safer and easier. In fact, you can get
86
your kernel sources right from Linus instead of
87
<classname>kernel-source-&kernelversion;</classname>, yet still use the
88
<classname>kernel-package</classname> compilation method.
92
Note that you'll find complete documentation on using
93
<classname>kernel-package</classname> under
94
<filename>/usr/share/doc/kernel-package</filename>. This section just
95
contains a brief tutorial.
97
</para><para arch="sparc">
99
If you are compiling a kernel for UltraSPARC you will need to be sure
100
you have installed the <classname>egcs64</classname> package. This is
101
the preferred compiler for 64bit SPARC kernels. The default
102
<command>gcc</command> will also compile 64bit kernels, but is not as
103
stable. Plus, if you do not use <classname>egcs64</classname> and you
104
encounter kernel problems, you will most likely be asked to recompile
105
the kernel using <classname>egcs64</classname> in order to verify your
106
problem still exists. After installing <classname>egcs64</classname>
107
be sure to run <userinput>update-alternatives --config
108
sparc64-linux-gcc</userinput> as root, and be sure that
109
<classname>egcs64</classname> is being used for this program.
113
Hereafter, we'll assume your kernel source will be located in
114
<filename>/usr/local/src</filename> and that your kernel version is
115
&kernelversion;. As root, create a directory under
116
<filename>/usr/local/src</filename> and change the owner of that
117
directory to your normal non-root account. As your normal non-root
118
account, change your directory to where you want to unpack the kernel
119
sources (<userinput>cd /usr/local/src</userinput>), extract the kernel
120
sources (<userinput>tar xjf
121
/usr/src/kernel-source-&kernelversion;.tar.bz2</userinput>), change your
122
directory to it (<userinput>cd
123
kernel-source-&kernelversion;/</userinput>).
127
Now, you can configure your kernel. Run <userinput>make
128
xconfig</userinput> if X11 is installed, configured and being run,
129
<userinput>make menuconfig</userinput> otherwise (you'll need
130
<classname>ncurses-dev</classname> installed). Take the time to read
131
the online help and choose carefully. When in doubt, it is typically
132
better to include the device driver (the software which manages
133
hardware peripherals, such as Ethernet cards, SCSI controllers, and so
134
on) you are unsure about. Be careful: other options, not related to a
135
specific hardware, should be left at the default value if you do not
136
understand them. Do not forget to select ``Kernel module loader'' in
137
``Loadable module support''
139
<phrase arch="alpha"> and ``Enhanced Real Time
140
Clock Support'' in ``Character devices'' (they are </phrase>
141
<phrase arch="not-alpha"> (it is </phrase>
143
not selected by default). If not included, your Debian installation
144
will experience problems.
148
Clean the source tree and reset the <classname>kernel-package</classname>
149
parameters. To do that, do <userinput>make-kpkg clean</userinput>.
153
Now, compile the kernel:
154
<userinput>fakeroot make-kpkg --revision=custom.1.0 kernel_image</userinput>.
155
The version number of ``1.0'' can be changed at will; this is just a
156
version number that you will use to track your kernel builds.
157
Likewise, you can put any word you like in place of ``custom'' (e.g.,
158
a host name). Kernel compilation may take quite a while, depending on
159
the power of your machine.
161
</para><para condition="supports-pcmcia">
163
If you require PCMCIA support, you'll also need to install the
164
<classname>pcmcia-source</classname> package. Unpack the gzipped tar file
165
as root in the directory <filename>/usr/src</filename> (it's important that
166
modules are found where they are expected to be found, namely,
167
<filename>/usr/src/modules</filename>). Then, as root, do <userinput>make-kpkg
168
modules_image</userinput>.
172
Once the compilation is complete, you can install your custom kernel
173
like any package. As root, do <userinput>dpkg -i
174
../kernel-image-&kernelversion;-<replaceable>subarchitecture</replaceable>_custom.1.0_&architecture;.deb</userinput>.
175
The <replaceable>subarchitecture</replaceable> part is an optional
177
<phrase arch="i386"> such as ``i586'', </phrase>
178
depending on what kernel options you set.
179
<userinput>dpkg -i kernel-image...</userinput> will install the
180
kernel, along with some other nice supporting files. For instance,
181
the <filename>System.map</filename> will be properly installed
182
(helpful for debugging kernel problems), and
183
<filename>/boot/config-&kernelversion;</filename> will be installed,
184
containing your current configuration set. Your new
185
<classname>kernel-image-&kernelversion;</classname> package is also clever
186
enough to automatically use your platform's boot-loader to run an
187
update on the booting, allowing you to boot without re-running the
188
boot loader. If you have created a modules package, e.g., if you have
189
PCMCIA, you'll need to install that package as well.
193
It is time to reboot the system: read carefully any warning that the
194
above step may have produced, then <userinput>shutdown -r now</userinput>.
198
For more information on <classname>kernel-package</classname>, read
199
the fine documentation in <filename>/usr/share/doc/kernel-package</filename>.