\section{Module Utilities}

\begin{frame}
   {Module Utilities}

   \begin{itemize}
      \item \textbf{lsmod}

      list loaded modules
      \item \textbf{insmod}

      directly load modules
      \item \textbf{rmmod}

      directly remove modules
      \item \textbf{modprobe}

      load or unload modules using a pre-built database with dependency
      and location information
      \item \textbf{depmod}

      rebuild the module dependency database

      \item \textbf{modinfo}

      display information about a module
   \end{itemize}

\end{frame}

\cprotect\note{

   Use \textbf{modprobe} to load a module:
   \begin{cmd}
$ modprobe e1000e
   \end{cmd}
   Use \texttt{modprobe -r} to unload or
   remove a module:
   \begin{cmd}
$ modprobe -r e1000e
   \end{cmd}
   \textbf{modprobe} requires a module
   dependency database be updated. Use
   \textbf{depmod} to generate or update the file
   \texttt{/lib/modules/\$(uname -r)/modules.dep}.

   Use \textbf{insmod} to directly load a
   module (requires fully qualified module name):
   \begin{cmd}
$ insmod /lib/modules/$(uname -r)/kernel/drivers/net/ethernet/intel/e1000e.ko
   \end{cmd}
   Use  \textbf{rmmod} to directly remove a
   module:
   \begin{cmd}
$ rmmod e1000e
   \end{cmd}
   Use \textbf{lsmod} to list the loaded
   modules:
   \begin{cmd}
$ lsmod
   \end{cmd}
   Use \textbf{modinfo} to display
   information about a module (including parameters):
   \begin{cmd}
$ modinfo e1000e
   \end{cmd}
}
\begin{frame}
   {Some Considerations with Modules}

   \begin{itemize}
      \item
      It is impossible to unload a module:
      \begin{itemize}
         \item In use by another module
         \item In use by a running process
      \end{itemize}
      \item
      It is impossible to load a module:
      \begin{itemize}
         \item Compiled for a different kernel, or with different
         options
         \item That conflicts with a currently running module
      \end{itemize}
      \item
      Modules are usually loaded with \textbf{modprobe}, not
      \textbf{insmod}
      \item
      Modules loaded with non-acceptable open source licenses
      mark the kernel as \textbf{tainted}

   \end{itemize}

\end{frame}

\cprotect\note {

   There are some important things to keep in mind when
   loading and unloading modules:
   \begin{itemize}

      \item

      It is impossible to unload a module being used by one or
      more other \textbf{modules}, which one can ascertain
      from the \textbf{lsmod} listing.

      \item

      It is impossible to unload a module that is being used
      by one or more \textbf{processes}, which can also be
      seen from the \textbf{lsmod} listing. However, there are
      modules which do not keep track of this reference count,
      such as network device driver modules, as it would make
      it too difficult to temporarily replace a module without
      shutting down and restarting much of the whole network
      stack.

      \item

      When a module is loaded with \textbf{modprobe}, the
      system will automatically load any other modules that
      need to be loaded first.

      \item

      When a module is unloaded with \textbf{modprobe -r}, the
      system will automatically unload any other modules being
      used by the module, if they are not being simultaneously
      used by any other loaded modules.

   \end{itemize}

}

\section{modinfo}
\begin{frame}
   {modinfo Example}

   \begin{figure}[H]
      \includegraphics[width=5.5in]{IMAGES/modinfo}
      \caption{modinfo}
   \end{figure}

\end{frame}

\cprotect\note{

   \textbf{modinfo} can be used to find out information about
   kernel modules (whether or not they are currently loaded) as shown
   in the above screenshot,
   which displays information about version, file name, which
   hardware devices the device driver module can handle, and
   what parameters can be supplied on loading.

   Much information about modules can also be seen in the
   \filelink{/sys} pseudo-filesystem directory tree; in the
   above example one would look under
   \filelink{/sys/module/e1000} and some if not all parameters
   can be read and/or written under
   \filelink{/sys/module/e1000/parameters}.  We will show how
   to set them next.

   Many modules can be loaded while specifying parameter
   values, such as in:
   \begin{cmd}
$ sudo /sbin/insmod <pathto>/e1000e.ko debug=2 copybreak=256
   \end{cmd}
   or, for a module already in the proper system location,
   it is easier with:
   \begin{cmd}
$ sudo /sbin/modprobe e1000e debug=2 copybreak=256
   \end{cmd}
}




