% CVSId: $Id: kernel_compilation.tex,v 1.2 2003/07/12 22:48:44 mulix Exp $

\documentclass[final, total, pdf, colorBG, slideColor]{prosper}

\title{Linux Kernel Compilation}
\subtitle{from source to running} 
\author{Muli Ben-Yehuda}
\email{mulix@mulix.org}
\institution{IBM Haifa Research Labs}

\slideCaption{Linux Kernel Development, TAU Linux Workshop, July 2003}

\begin{document}

\maketitle

\begin{slide}{introduction} % 1

In this talk, I will talk about and demonstrate compiling the Linux
kernel. Topics inlcude: 

\begin{itemize} 

\item overview of kernel compilation
\item configuring the kernel 
\item dep, clean and mrproper 
\item make bzImage - build the kernel image
\item make modules - build the modules
\item make modules\_install and final installation 
\item problem solving 

\end{itemize} 

\end{slide} 

\begin{slide}{overview} % 2 

\begin{itemize}

\item compiling the kernel is composed of three stages: configuration,
building (compiling) and installing
\item it's really quite simpler than it appears, and it's very hard to
cause damage and end with a non booting system 
\item we will go over the steps together, configuring, building and
installing the latest 2.4 kernel (2.4.22-pre5 as I write this)

\end{itemize} 

\end{slide} 

\begin{slide}{configuration} % 3

\begin{itemize}

\item configuring the kernel can be non trivial, since you have to
include support for your hardware for things to work 
\item if you've done it before and saved the .config, just do 'make
oldconfig'. 'make oldconfig' will only asked about new configuration
choices and use your old choices for everything else
\item otherwise, run 'make menuconfig' or 'make xconfig', and start
going through the options, based on your computer's hardware 
\item alternatives include 'make defconfig', for a ``default''
configuration, and copying a distribution's .config for a
configuration that should fit almost everything

\end{itemize} 

\end{slide} 

\begin{slide}{dep, clean, and mrproper} % 4 

\begin{itemize}

\item after configuring the kernel, you need to do 'make dep', in
order to generate dependency information and cause various build magic
to occur. 
\item occasionally, you might want or need to clean up the sources
before beginning from scratch. 'make clean' will delete object files,
'make mrproper' will delete {\bf everything} except the sources,
including your .config! be sure to save it elsewhere, not in the
kernel source directory, as 'make mrproper' will delete all files
matching .config*
\item neither 'make clean' nor 'make mrproper' are needed if this is
the first time compiling the kernel from pristine sources, only 'make
dep'. 

\end{itemize} 

\end{slide} 

\begin{slide}{make bzImage} % 5 

Not much to say here, really... 'make bzImage' will build a
compressed, ready to be installed kernel image. Alternatives include
'make vmlinux', which will create a debuggable (but not runnable)
kernel image. 

\end{slide} 

\begin{slide}{make modules} % 6

'make modules' will built the various components which we chose to
build as modules. Why would we want to build something as a module? 

\begin{itemize}

\item to save space in the kernel image (for embedded systems)
\item for easier debugging of drivers and kernel code 
\item to support new peripherals without requiring a kernel reboot. 

\end{itemize} 

\end{slide} 

\begin{slide}{install and make modules\_install} % 7 

\begin{itemize}

\item 'make modules\_install', which must be run as root, ivileges)
will create /lib/modules/`uname -r` and copy the modules there. 
\item the bzImage file, found at arch/i386/boot/bzImage, needs to be
copied somewhere the boot loader will find it. The System.map file
should be copied along with it, for debugging later, if necessary. 
\item The boot loader (lilo, grub, else) should be updated to reflect
the old kernel. {\bf Never} replace a working kernel with a newly
compiled one without verifying that it works first! 

\end{itemize} 

\end{slide} 

\begin{slide}{problem solving}

So you compiled your first kernel, and it doesn't
work. Congratulations! you aren't the first one, and certainly won't
be the last one. 

\begin{itemize}

\item did you install the bzImage and modules properly? did you update
the boot loader? 
\item if hardware that used to work no longer works, check the .config
for appropriate support
\item if you compiled your disk drivers as modules, you need to create
an initrd (initial ram disk). Read the documentation for more
information. 
\item enjoy your new kernel! 

\end{itemize} 

\end{slide} 

\end{document}