\input{gl2.slide-header-beamer}%
\errorcontextlines=99
%% Subtopic Number = '1.105.2'
%% Title from filename: 'Reconfigure, build, and install a custom
%% kernel and kernel modules'
%% Weight: 3
%% Description:
%% Candidates should be able to customize, build, and install
%%        a kernel and kernel loadable modules from source This objective includes
%%        customizing the current kernel configuration, building a new kernel, and
%%        building kernel modules as appropriate. It also includes installing the
%%        new kernel as well as any modules, and ensuring that the boot manager
%%        can locate the new kernel and associated files (generally located under
%%        /boot, see objective 1.102.2 for more details about boot manager
%%        configuration).
%% Key files, terms, and utilities include:
%%        /usr/src/linux/*
%%        /usr/src/linux/.config
%%        /lib/modules/kernel-version/*
%%        /boot/*
%%        make
%%        make targets: config, menuconfig, xconfig, oldconfig, modules, install,
%%        modules_install, depmod

% \documentclass[10pt,hyperref={implicit=true}]{beamer}

% \mode<presentation>
% {
%   %\usetheme{Warsaw}
%   \usetheme[hideothersubsections]{Goettingen}
%   % or ...

%   \setbeamercovered{transparent=80}
%   % or whatever (possibly just delete it)

%   \subject{LPIC 102}
% }
% \mode<article>
% {
%   \usepackage{url}
%   \renewcommand{\floatpagefraction}{0.75} % default is .5, to increase
%   % density.
%   \renewcommand*{\bottomfraction}{0.6} % default is 0.3
%   \renewcommand*{\topfraction}{0.85} % default is 0.7
%   \renewcommand*{\textfraction}{0.1} % default is 0.2
%   \pagestyle{fancy}
%   \fancyhf{}
%   \newlength{\markWidth}
%   \setlength{\markWidth}{0.5\textwidth}
%   \newlength{\topicnumwidth}
%   \settowidth{\topicnumwidth}{1.114.3}
%   \addtolength{\markWidth}{-0.6\topicnumwidth}
%   %\addtolength{\headheight}{1.92ex}

%   \renewcommand{\sectionmark}[1]{\markright{\thesection. #1}}
%   \lhead{\parbox[t]{\markWidth}{\raggedright\nouppercase{\rightmark}}}
%   \rhead{\thepage}
% }


% \usepackage[english]{babel}
% \usepackage{alltt,booktabs,array,cols,multicol,meta,acro}

\usepackage{acro}

% \usepackage[utf8]{inputenc}
% % or whatever

% \usepackage{times}
% \usepackage[T1]{fontenc}
% % Or whatever. Note that the encoding and the font should match. If T1
% % does not look nice, try deleting the line with the fontenc.
% \usepackage{xcolour-names}
% \usepackage[normalem]{ulem}

\title{1.105.2\\Reconfigure, build, and install a custom kernel and
  kernel modules\\Weight 3}
\subtitle{Linux Professional Institute Certification --- 102}

\author[Nick Urbanik]{Nick Urbanik \texttt{\footnotesize{}nicku@nicku.org}\\
  {\tiny This document Licensed under GPL---see slide~\pageref{sld:license}}%
}

\date{2005 September}

% Copyright (C) 2005  Nick Urbanik <nicku@nicku.org>

% You can redistribute modified or unmodified copies of this document
% provided that this copyright notice and this permission notice are
% preserved on all copies under the terms of the GNU General Public
% License as published by the Free Software Foundation--either version 2
% of the License or (at your option) any later version.

\AtBeginSubsection[]
{
  \begin{frame}<beamer>
    \frametitle{Outline}
    \footnotesize
    \begin{multicols}{2}
      \tableofcontents[currentsection,currentsubsection]
    \end{multicols}
  \end{frame}
}

% % If you wish to uncover everything in a step-wise fashion, uncomment
% % the following command: 

% %\beamerdefaultoverlayspecification{<+->}

% \newcounter{program}
% %\newcommand*{\program}[1]{\refstepcounter{program}\label{#1}\arabic{program}}
% % \newcommand*{\program}[1]{%
% %    \refstepcounter{program}\hypertarget{#1}{Program \texttt{#1}}%
% % }
% %\newcommand*{\program}[1]{\refstepcounter{program}\label{#1}\arabic{program}}
% \newcommand*{\program}[1]{%
%    \hypertarget{#1}{Program \texttt{#1}}%
% }

% \newcommand*{\linkto}[1]{\hyperlink{#1}{\texttt{#1}}}
% \providecommand*{\bs}{\texttt{\char '134}} % Backslash, no break

% \newcommand{\cmd}[1]{%
%   \texttt{\$ \textbf{#1 \(\hookleftarrow\)}}
% }

% \newcommand{\rootcmd}[1]{%
%   \texttt{\# \textbf{#1 \(\hookleftarrow\)}}
% }

% \newcommand{\opt}[1]{%
%   {\bfseries\texttt{#1}}
% }

\mode<article>{\chead{1.105.2}}

\begin{document}
\maketitle
\mode<article>{\thispagestyle{empty}}
% \begin{frame}
%   \titlepage
% \end{frame}

\begin{frame}
  \frametitle{Outline}
  \mode<presentation>
  {%
    \footnotesize
    \begin{multicols}{2}
      \tableofcontents
    \end{multicols}
    % You might wish to add the option [pausesections]
  }%
  \mode<article>
  {%
    \tableofcontents
  }%
\end{frame}

\section{Context}
\label{sec:context}

\begin{frame}
  \frametitle{Topic 105 Kernel [7]}%
  \framesubtitle{Where we are up to}%
    \begin{description}
    \item[1.105.1] Manage/Query kernel and kernel modules at runtime
      [4]
      % \uline depends on \usepackage[normalem]{ulem}:
    \item[1.105.2] \textbf{\uline{Reconfigure, build, and install a
          custom kernel and kernel modules [3]}}
    \end{description}
\end{frame}

\section{Objectives for 1.105.2}

\begin{frame}
  \frametitle{Description of Objective}%
  \framesubtitle{1.105.1\ \ Reconfigure, build, and install a custom
    kernel and kernel modules}%
  \mode<presentation>{\Large}%
  Candidates should be able to \alert{customize}, \alert{build}, and
  \alert{install} a kernel and kernel loadable modules from source.
  This objective includes customizing the current kernel
  configuration, building a new kernel, and building kernel modules as
  appropriate. It also includes installing the new kernel as well as
  any modules, and ensuring that the boot manager can locate the new
  kernel and associated files (generally located under /boot, see
  objective 1.102.2 for more details about boot manager
  configuration).
\end{frame}

\begin{frame}
  \frametitle{Key files, terms, and utilities include:}
  \framesubtitle{1.105.1\ \ Reconfigure, build, and install a custom
    kernel and kernel modules}%
  \mode<presentation>{\large}%
\begin{description}
  \item[\texttt{/usr/src/linux/*}] --- Where we traditionally put the
    kernel source (though it is better to not compile everything as
    the \texttt{root} user)
  \item[\texttt{/usr/src/linux/.config}] --- The source configuration
    file built/edited by \sloppypar\texttt{make\textbackslash~\{x,old,menu,,\}config}
  \item[\texttt{/lib/modules/kernel-version/*}] --- 
  \item[\texttt{/boot/*}] --- where the BIOS loads the kernel from
  \item[\texttt{make}] --- program used to build software, including
    the kernel
  \item[make targets:] \texttt{config}, \texttt{menuconfig},
    \texttt{xconfig}, \texttt{oldconfig}, \texttt{modules},
    \texttt{install}, \texttt{modules\_install}, \texttt{dep} --- all
    targets you can type after \texttt{make} when building a kernel
\end{description}
\end{frame}

\section{What is the kernel?}

\begin{frame}[fragile]
  \frametitle{What is the kernel?}
  \begin{itemize}
  \item The kernel consists of:
    \begin{itemize}
    \item the kernel itself:
      \begin{itemize}
      \item such as \path{/boot/vmlinuz-2.6.12-1.1447_FC4smp}
      \end{itemize}
    \item The kernel modules:
    \begin{itemize}
    \item In \texttt{/lib/modules/\$(uname -r)}
    \end{itemize}
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Kernel naming conventions}
  \begin{itemize}
  \item In a name such as \path{vmlinuz-2.6.12-1.1447_FC4smp}, there
    are the following parts of the name that identify the kernel:
    \begin{description}
    \item[major number:] here 2
      \begin{itemize}
      \item In the Makefile, called \textbf{\orange{\texttt{VERSION}}}
      \end{itemize}
    \item[minor number:] here 6
      \begin{itemize}
      \item In the Makefile, called \textbf{\orange{\texttt{PATCHLEVEL}}}
      \end{itemize}
    \item[revision:] here 12
      \begin{itemize}
      \item In the Makefile, called \textbf{\orange{\texttt{SUBLEVEL}}}
      \end{itemize}
    \item[vendor string:] here \path{-1.1447_FC4smp}
      \begin{itemize}
      \item In the Makefile, called \textbf{\red{\texttt{EXTRAVERSION}}}
      \item Always change this in the top level makefile if you
        already have an existing kernel with the same name whose
        modules you do not want to overwrite
      \end{itemize}
    \end{description}
  \item The \egreen{value that you choose for these variables}
    in the top level \eblue{Makefile} determines what you see
      when you run the program
      \textbf{\orange{\texttt{uname~-r}}}
  \item Consequently also determines the \ered{name of the modules directory}.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Types of Kernel Files}
  \begin{itemize}
  \item The main kernel file can be produced by
    \textbf{\blue{\texttt{make~zImage}}} or by
    \textbf{\blue{\texttt{make~bzImage}}}
    \begin{itemize}
    \item a \alert{zImage} kernel is limited to about 508\,kB in
      size and is loaded into lower memory
    \item zImage kernels are deprecated after 2.4.0-test3-pre3
      \begin{itemize}
      \item See \path{Documentation/i386/boot.txt}
      \end{itemize}
    \item a \alert{bzImage} kernel can be up to about 2.5\,MB in size
    \item \ered{Both} are compressed using \ered{gzip compression}
    \item the `\red{b}' in ``bzImage'' means
      ``\textbf{\red{b}\orange{ig}}'' rather than indicating
      bzip2 compression
    \item bzImage kernels are loaded into higher memory
    \end{itemize}
  \end{itemize}
\end{frame}


\begin{frame}
  \frametitle{Other Kernel Files in \texttt{/boot}}
  \begin{itemize}
  \item \textbf{\orange{\texttt{System.map}}} contains the
    addresses of kernel symbols
    \begin{itemize}
    \item Used by tools to interpret kernel error messages or
      OOPSes, to \green{translate kernel addresses into names}
      that mean more to us humans
    \item See \url{http://www.dirac.org/linux/system.map/}
    \end{itemize}
  \item The \textbf{\orange{initrd file}}, which is a compressed
    filesystem that is mounted as a \RAM disk
    \begin{itemize}
    \item It contains the drivers (\ered{kernel modules}) that the kernel
      \eblue{needs to access the hard disk}.
    \item The memory used by the initial ram disk is freed up after
      the modules have been loaded into the kernel
    \end{itemize}
  \item It is nice to have the kernel
    \textbf{\orange{\texttt{.config}}} configuration file handy
    so that the administrator knows how the kernel was built
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Kernel Modules}
  \begin{itemize}
  \item Kernel modules usually provide one of the following:
    \begin{description}
    \item[device driver:] supporting a specific kind of hardware
    \item[file system driver:] supporting the ability to read/write
      different file systems
    \item[system call extensions:] most system calls are supported by
      the base kernel, but modules can extend or add system calls
    \item[network driver:] implement particular network protocols
    \item[executable loader:] support loading and executing additional
      executable file formats
    \end{description}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Documentation}
  \begin{itemize}
  \item The directory \texttt{Documentation} under the top level contains
    lots of documentation relating to many aspects of the kernel.
  \item The file \path{Documentation/Configure.help} provides
    help with configuration for pre-2.6 kernels.
  \end{itemize}
\end{frame}

\section{Compiling a Kernel}

\subsection{Getting the sources}


\begin{frame}[fragile]
  \frametitle{Getting the sources}
\begin{alltt}\scriptsize
\cmd{lftp ftp://ftp.au.kernel.org/pub/linux/kernel/v2.6/}
cd ok, cwd=/pub/linux/kernel/v2.6
lftp ftp.au.kernel.org:/pub/linux/kernel/v2.6> \textbf{ls}
-rw-rw-r--    1 ftp      ftp         12777 Dec 18  2003 ChangeLog-2.6.0
-rw-rw-r--    1 ftp      ftp        193569 Jan 09  2004 ChangeLog-2.6.1
-rw-rw-r--    1 ftp      ftp       1552868 Dec 25  2004 ChangeLog-2.6.10
-rw-rw-r--    1 ftp      ftp       1495678 Mar 03  2005 ChangeLog-2.6.11
-rw-r--r--    1 ftp      ftp          1221 Mar 09  2005 ChangeLog-2.6.11.1
\ldots
-rw-rw-r--    1 ftp      ftp       4191691 Oct 19  2004 patch-2.6.9.gz
-rw-rw-r--    1 ftp      ftp           248 Oct 19  2004 patch-2.6.9.gz.sign
-rw-rw-r--    1 ftp      ftp           248 Oct 19  2004 patch-2.6.9.sign
drwxrwsr-x    2 ftp      ftp          8192 Dec 19  2003 pre-releases
drwxrwsr-x    4 ftp      ftp         28672 Sep 13 03:05 snapshots
drwxrwsr-x    4 ftp      ftp         24576 Sep 13 13:53 testing
{\tiny{}lftp ftp.au.kernel.org:/pub/linux/kernel/v2.6>} \textbf{mget linux-2.6.13.1.tar.bz2*}
 38375702 bytes transferred in 746 seconds (50.2K/s)
Total 2 files transferred
lftp ftp.au.kernel.org:/pub/linux/kernel/v2.6> \textbf{bye}
\cmd{tar xvjf linux-2.6.13.1.tar.bz2}
drwxr-xr-x git/git           0 2005-09-10 12:42:58 linux-2.6.13.1/
-rw-r--r-- git/git       18691 2005-09-10 12:42:58 linux-2.6.13.1/COPYING
-rw-r--r-- git/git       89317 2005-09-10 12:42:58 linux-2.6.13.1/CREDITS
drwxr-xr-x git/git           0 2005-09-10 12:42:58 linux-2.6.13.1/Documentation/
\ldots
\end{alltt}%$
\end{frame}

\begin{frame}
  \frametitle{Where to untar the source?}
  \begin{itemize}
  \item Many people untar the source below \path{/usr/src}
  \item \ldots\ but I prefer to untar it in a subdirectory below my
    home directory
  \item It is better to compile the code \ered{as a normal user}
    rather than as root
    \begin{itemize}
    \item It is a good principal to do \emph{anything} with the least
      privelege required
    \end{itemize}
  \item I will call the first directory appears when we untar the code as the
    \alert{top level directory}
    \begin{itemize}
    \item For example, if I did the untarring above in the directory
      $\sim$\texttt{/src}, then the top level directory is
      $\sim$\texttt{/src/linux-2.6.13.1}
    \end{itemize}
  \end{itemize}
\end{frame}

\subsection{Configuring the kernel}
\label{sec:configuring}


\begin{frame}
  \frametitle{editing \texttt{.config}}
  \begin{itemize}
  \item We next need to edit/create a file \texttt{.config} in the top
    level directory
  \item Could edit by hand, but easy to make a mistake
  \item We call \texttt{make} with one of the four \alert{targets}:
    \begin{description}
    \item[config] this is a method I have not used for years.  It does
      not allow you to go back: you can only move forward, answering
      questions
    \item[menuconfig] this gives you a nice text curses-based screen
      that allows you to navigate through the choices as you wish
    \item[xconfig] on 2.4 kernels, gives a nice Tk interface, and on
      2.6 kernels gives a program called \texttt{qconf}, which on my
      system is linked to a \texttt{qt} library.
    \item[oldconfig] this allows you to easily update an existing
      \texttt{.config} file, answering the configuration questions
      only for new options which are in the new source code, but which
      were not covered in the old \texttt{.config} file.
    \end{description}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Answering the questions}
  \begin{itemize}
  \item For each configuration option, we may be presented with the
    options
    \begin{description}
    \item[y] yes: means compile this right into the base kernel
    \item[m] module: means compile this as an external module that can
      be loaded into the kernel when it is needed
      \begin{itemize}
      \item It doesn't hurt to compile lots of modules, even though
        you don't need them, except that:
        \begin{itemize}
        \item it takes more time to compile,
        \item the chance of finding an error in the source code is
          increased, and
        \item the modules directory will take more hard disk space.
        \end{itemize}
      \end{itemize}
    \item[n] no: means do not compile this capability at all.
    \end{description}
  \end{itemize}
\end{frame}


\subsection{Compiling}
\label{sec:compiling}

\begin{frame}
  \frametitle{make targets}
  \begin{itemize}
  \item Here are the steps to compile the base kernel image:
    \begin{description}
    \item[\texttt{make dep}:] only needed in pre 2.6 kernels, not in
      2.6 kernels
    \item[\texttt{make clean}:] removes old object files; important if
      the source has been compiled previously
    \item[\texttt{make bzImage}:] builds the kernel image file.  You
      will find it in the location \path{arch/i386/boot/bzImage}
    \end{description}
  \item There are alternatives that I suggest you avoid, such as:
    \begin{description}
    \item[\texttt{make~zImage}]
      \path{Documentation/i386/boot.txt} says this is
      deprecated after 2.4.0.  For a very small kernel, loaded into low memory.
    \item[\texttt{make zlilo}] attempts to install the kernel directly
      using \texttt{lilo}
    \item[\texttt{make zdisk}] to create a bootable floppy.
    \end{description}
  \item It is simplest (to me) to use \texttt{make bzImage} and copy
    the kernel file to wherever you want it.
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
  \frametitle{make targets for the modules}
  \begin{description}
  \item[\texttt{make modules}:] builds the kernel modules.  Takes a
    while on a slow machine, especially if you have enabled many
    kernel modules
  \item[\texttt{sudo make modules\_install}:] install the modules under
    \texttt{/lib/modules/\meta{kernel-name}}, where \meta{kernel-name}
    is determined by how you edited the variables at the top of the
    main Makefile
  \end{description}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Other make targets}
  \begin{description}
  \item[\texttt{make mrproper}:] Clean the kernel source tree
    completely, to almost pristine condition.  This will also \blue{delete
    \texttt{.config}}.  (\texttt{make distclean} slightly cleaner).
  \end{description}
  \begin{itemize}
  %\item Geoff Robertson tells me that Jeff Waugh says the name
  \item Some people say the name means something
    \raisebox{0.1ex}{\scalebox{1}[1.3]{highly}} and
    \raisebox{-0.3ex}{\scalebox{1}[1.3]{deeply}} technical
    {\tiny\begin{tabular}[b]{@{}l@{}}(\textbf{m}aintaine\textbf{r}\\[-2ex]proper)\end{tabular}}
  \item \ldots but Linus says it's a cleaning fluid (German
    version of Mr Clean):
    \mode<article>{\\\nolinkurl{http://www.alphalinux.org/archives/axp-list/1996/October1996/1237.html}}
     \mode<beamer>{\url{http://www.alphalinux.org/archives/axp-list/1996/October1996/1237.html}}
     \mode<presentation>{\scriptsize}%
     \mode<article>{\small}%
\begin{semiverbatim}\bfseries
On Tue, 22 Oct 1996, Marc Singer wrote:
>
> > > What is mrproper? I've been wondering this for a long time.
> >
> > mrproper clears out all the config preferences.
>
> Yes, but what does it represent? Mr. Proper?

There was a silly cleaning cluid commercial over here in Finland
a few years ago with a particularly annoying jingle. "Mr Proper"
is/was the name of the cleaning fluid.

Sorry about that,

Linus      
\end{semiverbatim}
  \end{itemize}
\end{frame}

\section{Installing the kernel}

\subsection{Installing the kernel itself}

\begin{frame}
  \frametitle{Installing into \texttt{/boot}}
  \begin{itemize}
  \item All these files should have a name containing the
    version that you set in the Makefile
    \begin{itemize}
    \item In the following, replace \texttt{\$VERSION} by the
      value of \texttt{VERSION} in the Makefile,
      \texttt{\$PATCHLEVEL} by the value of PATCHLEVEL in the
      Makefile, \ldots
    \end{itemize}
  \item Manually copy it from the file
    \path{arch/i386/boot/bzImage} (relative to the top level of
    the source tree) to \texttt{/boot}
    \begin{itemize}
    \item Copy it to the name

      \mode<article>{\texttt{/boot/vmlinuz-\$VERSION.\$PATCHLEVEL.\linebreak\$SUBLEVEL\$EXTRAVERSION}}%
      \mode<presentation>{\path{/boot/vmlinuz-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION}}
    \end{itemize}
  \item Copy the \texttt{System.map} file into \texttt{/boot}
    \begin{itemize}
    \item Call it
      \mode<article>{\texttt{/boot/System.map-\$VERSION.\$PATCHLEVEL.\$SUBLEVEL\linebreak\$EXTRAVERSION}}%
      \mode<presentation>{\path{/boot/System.map-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION}}
    \end{itemize}
  \item Copy \texttt{.config} to \texttt{/boot} as
    \mode<article>{\texttt{/boot/config-\$VERSION.\$PATCHLEVEL.\linebreak\$SUBLEVEL\$EXTRAVERSION}}%
    \mode<presentation>{\path{/boot/config-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION}}
  \end{itemize}
\end{frame}

\subsection{Make the initial RAM disk file}

\begin{frame}[fragile]
  \frametitle{Make the initial RAM disk file}
  \begin{itemize}
  \item If you did not compile all the modules that your kernel
    needs to access the hard disk right into the kernel (not as
    modules), then you need an initial ram disk file
  \item Let us represent the value of the kernel version --- \mode<article>{\texttt{\$VERSION.\$PATCHLEVEL.\linebreak\$SUBLEVEL\$EXTRAVERSION}}%
    \mode<presentation>{\path{$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION}} as \meta{kernel version}.
  \item On Red Hat systems you create this with a command like
    this:
{
  %\mode<presentation>{\scriptsize}
\begin{alltt}\scriptsize
$ \textbf{sudo mkinitrd -v /boot/initrd-\meta{kernel version}.img \meta{kernel version}}
$ \textbf{mkinitrd --help}
usage: mkinitrd [--version] [-v] [-f] [--preload <module>]
       [--omit-scsi-modules] [--omit-raid-modules] [--omit-lvm-modules]
       [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]
       [--builtin=<module>] [--nopivot] <initrd-image> <kernel-version>

       (ex: mkinitrd /boot/initrd-2.2.5-15.img 2.2.5-15)
\end{alltt}%$
}
  \end{itemize}
\end{frame}


\subsection{Having Grub start the kernel}
\label{sec:grub}

\begin{frame}[fragile]
  \frametitle{Having Grub start the kernel}
  \begin{itemize}
  \item edit \acro{GRUB}'s configuration file
    \path{/boot/grub/menu.lst} or \path{/boot/grub/grub.conf}
  \item Add a new section for your kernel, telling \acro{GRUB}
    about the initrd file if you need one:
  \end{itemize}
{
  \mode<presentation>{\footnotesize}
\begin{alltt}
title Latest kernel (2.6.13.2)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.13.2 ro root=/dev/hda1
        initrd /boot/initrd-2.6.13.2.img
\end{alltt}
}
\end{frame}

\begin{frame}
  \frametitle{Test it}
  \begin{itemize}
  \item Do not remove your old kernel from
    \path{/boot/grub/menu.lst} before you have tested your new kernel
  \item Boot the new kernel on a test system and give it a good
    try out before you install it on your production systems
  \end{itemize}
\end{frame}


\section{Building an external module without all the source}
\label{sec:external-modules}


\begin{frame}
  \frametitle{Building an external module}
  \begin{itemize}
  \item You may need to compile a module to support special hardware,
    \begin{itemize}
    \item for example: a WinModem, or the
      \href{http://labjack.com/}{LabJack} data acquisition system 
    \end{itemize}
  \item You get the source code for the module; you don't want to have
    to install all the source code for your kernel.
  \item Much easier with 2.6 kernels than with 2.4
  \end{itemize}
\end{frame}

\subsection{Building an external module on Fedora/Red Hat}
\label{sec:fedora}

\begin{frame}[fragile]
  \frametitle{Building an external module on Fedora/Red Hat}
  \begin{itemize}
  \item Install the appropriate \texttt{kernel-\meta{type-}devel}
    software package; for example, do
    \begin{itemize}
    \item \mbox{\cmd{yum -y install kernel-devel}} for an ordinary
      kernel, \mbox{\cmd{yum -y install kernel-smp-devel}} for a
      multiprocessor kernel.
    \end{itemize}
  \item In the directory where you have the source code \texttt{foo.c}
    for the module \texttt{foo.ko}, you need a \texttt{Makefile}
    containing
\begin{semiverbatim}
obj-m := foo.o

KDIR  := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) M=$(PWD) modules
\end{semiverbatim}%$
  \item Then type \cmd{make} where your \texttt{foo.c} is
  \item Then load it with \mbox{\cmd{sudo insmod foo.ko}}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Resources for Building Modules}
  \begin{itemize}
  \item Excellent instructions are provided in the
    \href{http://fedora.redhat.com/docs/release-notes/}{Release Notes}
  \item See also \path{Documentation/kbuild/modules.txt} in the kernel
    source code.
  \end{itemize}
\end{frame}

\subsection{Building External Modules on Debian/Ubuntu}
\label{sec:ubuntu}


\begin{frame}
  \frametitle{Building External Modules on Debian/Ubuntu}
  \begin{itemize}
  \item install the package \texttt{linux-headers-\$(uname -r)}:
    {\mode<presentation>{\small}%
    \mbox{\cmd{sudo apt-get update}}
    \par%
    \mbox{\cmd{sudo apt-get install linux-headers-\$(uname -r)}}}
  \item Then follow the instructions in
    \path{Documentation/kbuild/modules.txt}
  \item Note:
    \begin{itemize}
    \item I was not successful with Breezy and
      \texttt{labjack.ko}
    \item any suggestions welcome.
    \end{itemize}
  \end{itemize}
\end{frame}

\mode<presentation>
{%
\begin{frame}
  \frametitle{Topics Covered}
  %\footnotesize
  %\begin{multicols}{2}
    \tableofcontents[pausesections,pausesubsections]
  %\end{multicols}
  % You might wish to add the option [pausesections]
\end{frame}
}

\section{License covering this document}
\label{sec:license}


\begin{frame}
  \frametitle{License covering this document}%
  \label{sld:license}%
  \raggedright%
  Copyright \copyright{} 2005  Nick Urbanik <nicku@nicku.org>
  \par
  You can redistribute modified or unmodified copies of this document
  provided that this copyright notice and this permission notice are
  preserved on all copies under the terms of the GNU General Public
  License as published by the Free Software Foundation --- either
  version 2 of the License or (at your option) any later version.
\end{frame}
\end{document}
