| 1 |
<!-- retain these comments for translator revision tracking -->
|
| 2 |
<!-- original version: 28672 untranslated -->
|
| 3 |
|
| 4 |
<sect1 id="kernel-baking"><title>Compiling a New Kernel</title>
|
| 5 |
<para>
|
| 6 |
|
| 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
|
| 10 |
to:
|
| 11 |
|
| 12 |
<itemizedlist>
|
| 13 |
<listitem><para>
|
| 14 |
|
| 15 |
handle special hardware needs, or hardware conflicts with the pre-supplied
|
| 16 |
kernels
|
| 17 |
|
| 18 |
</para></listitem>
|
| 19 |
<listitem><para>
|
| 20 |
|
| 21 |
handle hardware or options not included in the stock kernel, such as
|
| 22 |
APM or SMP
|
| 23 |
|
| 24 |
</para></listitem>
|
| 25 |
<listitem><para>
|
| 26 |
|
| 27 |
optimize the kernel by removing useless drivers to speed up boot
|
| 28 |
time
|
| 29 |
|
| 30 |
</para></listitem>
|
| 31 |
<listitem><para>
|
| 32 |
|
| 33 |
use options of the kernel which are not supported by the default
|
| 34 |
kernel (such as high memory support)
|
| 35 |
|
| 36 |
</para></listitem>
|
| 37 |
<listitem><para>
|
| 38 |
|
| 39 |
run an updated or development kernel
|
| 40 |
|
| 41 |
</para></listitem>
|
| 42 |
<listitem><para>
|
| 43 |
|
| 44 |
impress your friends, try new things
|
| 45 |
|
| 46 |
</para></listitem>
|
| 47 |
</itemizedlist>
|
| 48 |
|
| 49 |
</para>
|
| 50 |
|
| 51 |
<sect2><title>Kernel Image Management</title>
|
| 52 |
<para>
|
| 53 |
|
| 54 |
Don't be afraid to try compiling the kernel. It's fun and profitable.
|
| 55 |
|
| 56 |
</para><para>
|
| 57 |
|
| 58 |
To compile a kernel the Debian way, you need some packages:
|
| 59 |
<classname>kernel-package</classname>,
|
| 60 |
<classname>kernel-source-&kernelversion;</classname> (the most recent version
|
| 61 |
at the time of this writing), <classname>fakeroot</classname> and a
|
| 62 |
few others which are probably already installed (see
|
| 63 |
<filename>/usr/share/doc/kernel-package/README.gz</filename> for the
|
| 64 |
complete list).
|
| 65 |
|
| 66 |
</para><para>
|
| 67 |
|
| 68 |
This method will make a .deb of your kernel source, and, if you have
|
| 69 |
non-standard modules, make a synchronized dependent .deb of those
|
| 70 |
too. It's a better way to manage kernel images;
|
| 71 |
<filename>/boot</filename> will hold the kernel, the System.map, and a
|
| 72 |
log of the active config file for the build.
|
| 73 |
|
| 74 |
</para><para>
|
| 75 |
|
| 76 |
Note that you don't <emphasis>have</emphasis> to compile your kernel
|
| 77 |
the <quote>Debian way</quote>; but we find that using the packaging system
|
| 78 |
to manage your kernel is actually safer and easier. In fact, you can get
|
| 79 |
your kernel sources right from Linus instead of
|
| 80 |
<classname>kernel-source-&kernelversion;</classname>, yet still use the
|
| 81 |
<classname>kernel-package</classname> compilation method.
|
| 82 |
|
| 83 |
</para><para>
|
| 84 |
|
| 85 |
Note that you'll find complete documentation on using
|
| 86 |
<classname>kernel-package</classname> under
|
| 87 |
<filename>/usr/share/doc/kernel-package</filename>. This section just
|
| 88 |
contains a brief tutorial.
|
| 89 |
|
| 90 |
</para><para>
|
| 91 |
|
| 92 |
Hereafter, we'll assume you have free rein over your machine and will
|
| 93 |
extract your kernel source to somewhere in your home directory<footnote>
|
| 94 |
|
| 95 |
<para>
|
| 96 |
|
| 97 |
There are other locations where you can extract kernel sources and build
|
| 98 |
your custom kernel, but this is easiest as it does not require special
|
| 99 |
permissions.
|
| 100 |
|
| 101 |
</para>
|
| 102 |
|
| 103 |
</footnote>. We'll also assume that your kernel version is
|
| 104 |
&kernelversion;. Make sure you are in the directory to where you want to
|
| 105 |
unpack the kernel sources, extract them using <userinput>tar xjf
|
| 106 |
/usr/src/kernel-source-&kernelversion;.tar.bz2</userinput> and change
|
| 107 |
to the directory <filename>kernel-source-&kernelversion;</filename>
|
| 108 |
that will have been created.
|
| 109 |
|
| 110 |
</para><para>
|
| 111 |
|
| 112 |
Now, you can configure your kernel. Run <userinput>make
|
| 113 |
xconfig</userinput> if X11 is installed, configured and being run; run
|
| 114 |
<userinput>make menuconfig</userinput> otherwise (you'll need
|
| 115 |
<classname>libncurses5-dev</classname> installed). Take the time to read
|
| 116 |
the online help and choose carefully. When in doubt, it is typically
|
| 117 |
better to include the device driver (the software which manages
|
| 118 |
hardware peripherals, such as Ethernet cards, SCSI controllers, and so
|
| 119 |
on) you are unsure about. Be careful: other options, not related to a
|
| 120 |
specific hardware, should be left at the default value if you do not
|
| 121 |
understand them. Do not forget to select <quote>Kernel module loader</quote>
|
| 122 |
in <quote>Loadable module support</quote> (it is not selected by default).
|
| 123 |
If not included, your Debian installation will experience problems.
|
| 124 |
|
| 125 |
</para><para>
|
| 126 |
|
| 127 |
Clean the source tree and reset the <classname>kernel-package</classname>
|
| 128 |
parameters. To do that, do <userinput>make-kpkg clean</userinput>.
|
| 129 |
|
| 130 |
</para><para>
|
| 131 |
|
| 132 |
Now, compile the kernel:
|
| 133 |
<userinput>fakeroot make-kpkg --revision=custom.1.0 kernel_image</userinput>.
|
| 134 |
The version number of <quote>1.0</quote> can be changed at will; this is just
|
| 135 |
a version number that you will use to track your kernel builds.
|
| 136 |
Likewise, you can put any word you like in place of <quote>custom</quote>
|
| 137 |
(e.g., a host name). Kernel compilation may take quite a while, depending on
|
| 138 |
the power of your machine.
|
| 139 |
|
| 140 |
</para><para condition="supports-pcmcia">
|
| 141 |
|
| 142 |
If you require PCMCIA support, you'll also need to install the
|
| 143 |
<classname>pcmcia-source</classname> package. Unpack the gzipped tar file
|
| 144 |
as root in the directory <filename>/usr/src</filename> (it's important that
|
| 145 |
modules are found where they are expected to be found, namely,
|
| 146 |
<filename>/usr/src/modules</filename>). Then, as root, do <userinput>make-kpkg
|
| 147 |
modules_image</userinput>.
|
| 148 |
|
| 149 |
</para><para>
|
| 150 |
|
| 151 |
Once the compilation is complete, you can install your custom kernel
|
| 152 |
like any package. As root, do <userinput>dpkg -i
|
| 153 |
../kernel-image-&kernelversion;-<replaceable>subarchitecture</replaceable>_custom.1.0_&architecture;.deb</userinput>.
|
| 154 |
The <replaceable>subarchitecture</replaceable> part is an optional
|
| 155 |
sub-architecture,
|
| 156 |
<phrase arch="i386"> such as <quote>i586</quote>, </phrase>
|
| 157 |
depending on what kernel options you set.
|
| 158 |
<userinput>dpkg -i kernel-image...</userinput> will install the
|
| 159 |
kernel, along with some other nice supporting files. For instance,
|
| 160 |
the <filename>System.map</filename> will be properly installed
|
| 161 |
(helpful for debugging kernel problems), and
|
| 162 |
<filename>/boot/config-&kernelversion;</filename> will be installed,
|
| 163 |
containing your current configuration set. Your new
|
| 164 |
<classname>kernel-image-&kernelversion;</classname> package is also clever
|
| 165 |
enough to automatically use your platform's boot-loader to run an
|
| 166 |
update on the booting, allowing you to boot without re-running the
|
| 167 |
boot loader. If you have created a modules package, e.g., if you have
|
| 168 |
PCMCIA, you'll need to install that package as well.
|
| 169 |
|
| 170 |
</para><para>
|
| 171 |
|
| 172 |
It is time to reboot the system: read carefully any warning that the
|
| 173 |
above step may have produced, then <userinput>shutdown -r now</userinput>.
|
| 174 |
|
| 175 |
</para><para>
|
| 176 |
|
| 177 |
For more information on <classname>kernel-package</classname>, read
|
| 178 |
the fine documentation in <filename>/usr/share/doc/kernel-package</filename>.
|
| 179 |
|
| 180 |
</para>
|
| 181 |
</sect2>
|
| 182 |
</sect1>
|