\documentclass{ictlab}

\RCS $Revision: 1.3 $

\usepackage{alltt,key}
\ifx\pdftexversion\undefined \else
  \usepackage[pdfpagemode=None,pdfauthor={Nick Urbanik}]{hyperref}
\fi

\renewcommand*{\subject}{Operating Systems and Systems Integration}
\newcommand*{\labTitle}{Using LILO to Boot Another Operating System}

\begin{document}

\section{Aim}
\label{sec:aim}

It is often useful to be able to boot more than one operating system
from one hard disk.  There are some commercial packages to achieve
this examples include the boot selector with \emph{Partition Magic}
and \emph{System Commander}\e.  There are a number of free software
packages also, such as \texttt{grub} and \acro{OSBS}.  However, we
will use \acro{LILO}, simply because we need it to start Linux, so it
is already available, and it can do the job.  Today we see how to use
\acro{LILO} to boot Linux and one or more additional operating
systems.


\section{Background}
\label{sec:background}
\acro{LILO} stands for \textbf{Li}nux \textbf{lo}der, but it is very
flexible and can start many other operating systems besides Linux\@.

You can read the user manual for \acro{LILO} by typing:
\begin{alltt}
xdvi /usr/share/doc/lilo-21.4.4/doc/user &
\end{alltt}
or
\begin{alltt}
gv /usr/share/doc/lilo-21.4.4/doc/User_Guide.ps &
\end{alltt}

I assume that you have set up the \texttt{sudo} command, and
understand how to use it.  If not, please read the document I have
written about it first.

Note that setting up \acro{LILO} involves two steps:
\begin{itemize}
\item edit the configuration file, \texttt{/etc/lilo.conf}
\item run the installer, \texttt{/sbin/lilo}, which reads the
  configuration file and actually installs the boot loader.
\end{itemize}
Note that the boot loader code installed by \acro{LILO} runs before
any operating system is started.

\section{Procedure}
\label{sec:procedure}

Before you begin:
\begin{itemize}
\item Linux should be installed
  
\item \emph{All} the operating systems you want to boot must be
  installed.  If the operating system is not installed, then you
  cannot configure \acro{LILO} to boot them later on after you install
  the new \OS.
  
\item You need a custom boot disk for your system.  I do not mean the
  installation disk.  You should have created one when you installed
  Linux\e.  If you didn't, you can create a custom boot disk for your
  system like this:
  \begin{itemize*}
  \item Put a floppy disk into the machine.
    
  \item Enter this command:
    \begin{alltt}
$ sudo mkbootdisk -v --device /dev/fd0 2.4.3-12
    \end{alltt}%$
    where the last number is the version of your kernel, found by
    typing the command \texttt{uname -r}
    
    Use this bootdisk to start the computer if \acro{LILO} fails to
    boot the computer because the installation of a Microsoft \OS has
    overwritten \acro{LILO} in the \acro{MBR} (master boot record).
  \end{itemize*}
\end{itemize}

Here I am going to assume that you have installed Windows 98 in
partition \texttt{/dev/hda1}.

\subsection{If Linux is already started:}
\label{sec:alreadyStarted}

\begin{enumerate}
\item At a shell prompt, type:
  \begin{alltt}
$ sudo emacs /etc/lilo.conf
  \end{alltt}%$
and enter your own password if necessary.
  
\item You should see something like this:
  \begin{alltt}
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
linear
default=linux

image=/boot/vmlinuz-2.4.3-12
        label=linux
        read-only
        root=/dev/hda8
  \end{alltt}

\item Add the following at the end:
  \begin{alltt}
other=/dev/hda1
         label=win98
  \end{alltt}

\item Change the line
  \begin{alltt}
linear
  \end{alltt}
to
\begin{alltt}
lba32
\end{alltt}
Note: the option \texttt{lba32} is very important to ensure that your
system can boot, since this enables support for extended \BIOS disk
functions that can read past the cylinder 1024.  This issue about the
\acro{BIOS} limitations is discussed in the worksheet about
partitioning.  Please read that again if the 1024 cylinder limit
puzzles you.

So your \texttt{lilo.conf} should look something like this:
  \begin{alltt}
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
lba32
default=linux

image=/boot/vmlinuz-2.4.3-12
        label=linux
        read-only
        root=/dev/hda8

other=/dev/hda1
         label=win98
  \end{alltt}


\item Save the file by typing \key{Control-x}\,\key{Control-s}

\item Exit from Emacs by typing \key{Control-x}\,\key{Control-c}

\item Type the following at the bash prompt:
  \begin{alltt}
$ sudo /sbin/lilo
  \end{alltt}%$
  If you see any error messages that you do not understand, ask the
  technician or your lecturer for help.
\item If there are no error messages, then restart the computer by
  typing:
  \begin{alltt}
$ sudo shutdown -r now
  \end{alltt}%$

\item Boot both Linux and Windows and make sure that they start
  correctly.


% \item A few seconds after the \BIOS messages have finished, you will
%   see the LILO prompt, which looks like this:
%   \begin{alltt}
% LILO boot:
%   \end{alltt}

% \item Within 5 seconds, press the \key{Tab} key.  You will see
%   something like this:
%   \begin{alltt}
% LILO boot:
% linux           win98
%   \end{alltt}
% Start Windows 98 by typing:
% \begin{alltt}
% win98 \key{Enter}
% \end{alltt}
% and check that it boots okay.
  
\item Shutdown Windows and reboot.  At the \acro{LILO} prompt, press
  \key{Enter} (or just leave it alone).  Linux should boot.
\end{enumerate}

\subsection{If Linux is not already started:}
\label{sec:singleUserMode}

You can save a few seconds by starting Linux in \emph{single user
  mode}, or ``runlevel 1''.  This is similar to Windows' ``Safe mode (command prompt).''
You also do not need to type in your root password---great if you
forgot your password from last week, and haven't set up \texttt{sudo} yet.
\begin{enumerate}
\item To start Linux in single user mode, at the \acro{LILO} prompt, type:
\begin{alltt}
\key{Control-X}
\end{alltt}
to get to the \acro{LILO} boot prompt.

\item At that prompt type:
\begin{alltt}
LILO boot: linux 1
\end{alltt}

\item The remaining steps are as in section~\vref{sec:alreadyStarted}.
\end{enumerate}

\section{How do I\ldots?}
\label{sec:whatif}
\begin{enumerate}
\item What should I do if I haven't installed Linux but I have
  partitioned the hard disk and I want to install Windows 98 in
  \texttt{/dev/hda1}?
  
  \textbf{Answer:} \quad Just go ahead and install Windows 98 in the
  primary partition; you can set up mulitple boot as part of the Linux
  installation process.

\item How do I start Windows as the default instead of Linux?
  
  \textbf{Answer:}
  \begin{enumerate}
  \item Start Linux, edit \texttt{/etc/lilo.conf} and change the line
    \begin{alltt}
default=linux
  \end{alltt}
to
  \begin{alltt}
default=win98
  \end{alltt}

  \item Execute lilo by typing
    \begin{alltt}
$ sudo lilo
    \end{alltt}%$
at a bash prompt.
  \end{enumerate}
  
\end{enumerate}
\end{document}
