Compiling a New Kernel
Why would someone want to compile a new kernel? It is often not
necessary since the default kernel shipped with Debian handles most
configurations. However, it is useful to compile a new kernel in order
handle special hardware needs, or hardware conflicts with the pre-supplied
handle hardware or options not included in the stock kernel, such as
APM or SMP
The compact and idepci flavors don't come with sound. Although
the vanilla kernel does, it might not work for other reasons.
optimize the kernel by removing useless drivers to speed up boot
use options of the kernel which are not supported by the default
kernel (such as network firewalling)
run a updated or development kernel
impress your friends, try new things
Kernel Image Management
Don't be afraid to try compiling the kernel. It's fun and profitable.
To compile a kernel the Debian way, you need some packages:
kernel-source-&kernelversion; (the most recent version
at the time of this writing), fakeroot and a
few others which are probably already installed (see
/usr/share/doc/kernel-package/README.gz for the
This method will make a .deb of your kernel source, and, if you have
non-standard modules, make a synchronized dependent .deb of those
too. It's a better way to manage kernel images;
/boot will hold the kernel, the System.map, and a
log of the active config file for the build.
Note that you don't have to compile your kernel
the ``Debian way''; but we find that using the packaging system to
manage your kernel is actually safer and easier. In fact, you can get
your kernel sources right from Linus instead of
kernel-source-&kernelversion;, yet still use the
kernel-package compilation method.
Note that you'll find complete documentation on using
/usr/share/doc/kernel-package. This section just
contains a brief tutorial.
If you are compiling a kernel for UltraSPARC you will need to be sure
you have installed the egcs64 package. This is
the preferred compiler for 64bit SPARC kernels. The default
gcc will also compile 64bit kernels, but is not as
stable. Plus, if you do not use egcs64 and you
encounter kernel problems, you will most likely be asked to recompile
the kernel using egcs64 in order to verify your
problem still exists. After installing egcs64
be sure to run update-alternatives --config
sparc64-linux-gcc as root, and be sure that
egcs64 is being used for this program.
Hereafter, we'll assume your kernel source will be located in
/usr/local/src and that your kernel version is
&kernelversion;. As root, create a directory under
/usr/local/src and change the owner of that
directory to your normal non-root account. As your normal non-root
account, change your directory to where you want to unpack the kernel
sources (cd /usr/local/src), extract the kernel
sources (tar xjf
/usr/src/kernel-source-&kernelversion;.tar.bz2), change your
directory to it (cd
Now, you can configure your kernel. Run make
xconfig if X11 is installed, configured and being run,
make menuconfig otherwise (you'll need
ncurses-dev installed). Take the time to read
the online help and choose carefully. When in doubt, it is typically
better to include the device driver (the software which manages
hardware peripherals, such as Ethernet cards, SCSI controllers, and so
on) you are unsure about. Be careful: other options, not related to a
specific hardware, should be left at the default value if you do not
understand them. Do not forget to select ``Kernel module loader'' in
``Loadable module support''
and ``Enhanced Real Time
Clock Support'' in ``Character devices'' (they are
not selected by default). If not included, your Debian installation
will experience problems.
Clean the source tree and reset the kernel-package
parameters. To do that, do make-kpkg clean.
Now, compile the kernel:
fakeroot make-kpkg --revision=custom.1.0 kernel_image.
The version number of ``1.0'' can be changed at will; this is just a
version number that you will use to track your kernel builds.
Likewise, you can put any word you like in place of ``custom'' (e.g.,
a host name). Kernel compilation may take quite a while, depending on
the power of your machine.
If you require PCMCIA support, you'll also need to install the
pcmcia-source package. Unpack the gzipped tar file
as root in the directory /usr/src (it's important that
modules are found where they are expected to be found, namely,
/usr/src/modules). Then, as root, do make-kpkg
Once the compilation is complete, you can install your custom kernel
like any package. As root, do dpkg -i
The subarchitecture part is an optional
such as ``i586'',
depending on what kernel options you set.
dpkg -i kernel-image... will install the
kernel, along with some other nice supporting files. For instance,
the System.map will be properly installed
(helpful for debugging kernel problems), and
/boot/config-&kernelversion; will be installed,
containing your current configuration set. Your new
kernel-image-&kernelversion; package is also clever
enough to automatically use your platform's boot-loader to run an
update on the booting, allowing you to boot without re-running the
boot loader. If you have created a modules package, e.g., if you have
PCMCIA, you'll need to install that package as well.
It is time to reboot the system: read carefully any warning that the
above step may have produced, then shutdown -r now.
For more information on kernel-package, read
the fine documentation in /usr/share/doc/kernel-package.