| 1 |
<!-- retain these comments for translator revision tracking -->
|
| 2 |
<!-- $Id: kernel-baking.xml 11648 2004-03-22 00:37:46Z joeyh $ -->
|
| 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 |
|
| 26 |
<listitem arch="i386"><para>
|
| 27 |
|
| 28 |
The compact and idepci flavors don't come with sound. Although
|
| 29 |
the vanilla kernel does, it might not work for other reasons.
|
| 30 |
|
| 31 |
</para></listitem>
|
| 32 |
<listitem><para>
|
| 33 |
|
| 34 |
optimize the kernel by removing useless drivers to speed up boot
|
| 35 |
time
|
| 36 |
|
| 37 |
</para></listitem>
|
| 38 |
<listitem><para>
|
| 39 |
|
| 40 |
use options of the kernel which are not supported by the default
|
| 41 |
kernel (such as network firewalling)
|
| 42 |
|
| 43 |
</para></listitem>
|
| 44 |
<listitem><para>
|
| 45 |
|
| 46 |
run a updated or development kernel
|
| 47 |
|
| 48 |
</para></listitem>
|
| 49 |
<listitem><para>
|
| 50 |
|
| 51 |
impress your friends, try new things
|
| 52 |
|
| 53 |
</para></listitem>
|
| 54 |
</itemizedlist>
|
| 55 |
|
| 56 |
</para>
|
| 57 |
|
| 58 |
<sect2><title>Kernel Image Management</title>
|
| 59 |
<para>
|
| 60 |
|
| 61 |
Don't be afraid to try compiling the kernel. It's fun and profitable.
|
| 62 |
|
| 63 |
</para><para>
|
| 64 |
|
| 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
|
| 71 |
complete list).
|
| 72 |
|
| 73 |
</para><para>
|
| 74 |
|
| 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.
|
| 80 |
|
| 81 |
</para><para>
|
| 82 |
|
| 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.
|
| 89 |
|
| 90 |
</para><para>
|
| 91 |
|
| 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.
|
| 96 |
|
| 97 |
</para><para arch="sparc">
|
| 98 |
|
| 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.
|
| 110 |
|
| 111 |
</para><para>
|
| 112 |
|
| 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 xIf
|
| 121 |
/usr/src/kernel-source-&kernelversion;.tar.bz2</userinput>), change your
|
| 122 |
directory to it (<userinput>cd
|
| 123 |
kernel-source-&kernelversion;/</userinput>).
|
| 124 |
|
| 125 |
</para><para>
|
| 126 |
|
| 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''
|
| 138 |
|
| 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>
|
| 142 |
|
| 143 |
not selected by default). If not included, your Debian installation
|
| 144 |
will experience problems.
|
| 145 |
|
| 146 |
</para><para>
|
| 147 |
|
| 148 |
Clean the source tree and reset the <classname>kernel-package</classname>
|
| 149 |
parameters. To do that, do <userinput>make-kpkg clean</userinput>.
|
| 150 |
|
| 151 |
</para><para>
|
| 152 |
|
| 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.
|
| 160 |
|
| 161 |
</para><para condition="supports-pcmcia">
|
| 162 |
|
| 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>.
|
| 169 |
|
| 170 |
</para><para>
|
| 171 |
|
| 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
|
| 176 |
sub-architecture,
|
| 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.
|
| 190 |
|
| 191 |
</para><para>
|
| 192 |
|
| 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>.
|
| 195 |
|
| 196 |
</para><para>
|
| 197 |
|
| 198 |
For more information on <classname>kernel-package</classname>, read
|
| 199 |
the fine documentation in <filename>/usr/share/doc/kernel-package</filename>.
|
| 200 |
|
| 201 |
</para>
|
| 202 |
</sect2>
|
| 203 |
</sect1>
|