%% $Header: /cvsroot/lcdp/lpic/general-linux-1/slides/gl1.102.2.slides.tex,v 1.2 2003/05/30 05:01:31 waratah Exp $

\input{gl1.slide-header.tex}
\usepackage{epsfig}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----10->|-----20->|-----30->|-----40->|-----50->|-----60->|-----70->|-----80->
\begin{slide} %================================================================
\begin{center} \LARGE \textsf{-- General Linux 1 -- \\
 Install a boot manager [1]} \\[2mm]
\large  \textsf{(Linux Professional Institute Certification)}\\[1mm]

\normalsize\end{center}

\footnote{Copyright \copyright\ 2002 Geoffrey Robertson. Permission is granted to make and distribute verbatim copies or modified versions 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.}
 
\scriptsize
\begin{verbatim} 
   .~.    
   /V\     by: geoffrey robertson        
  // \\        geoffrey@zip.com.au
  @._.@ 
\end{verbatim} 
\tiny
\begin{verbatim}
$Id: gl1.102.2.slides.tex,v 1.2 2003/05/30 05:01:31 waratah Exp $ 
\end{verbatim} 
\normalsize  
\vfill \end{slide} %-----------------------------------------------------------
%----10->|-----20->|-----30->|-----40->|-----50->|-----60->|-----70->|-----80->


%==============================================================================
%==============================================================================
\begin{slide} %ghr
\slideheading{Install a boot manager [1]}
\slidesubheading{(1.1) 101 Hardware \& Architecture [11]}
\begin{description}
  \item[2.102.1] Design hard disk layout [5]
  \item[2.102.2] {\bf \underline{Install a boot manager [1]}}
  \item[2.102.3] Make \& install programs from source [5]
  \item[2.102.4] Manage shared libraries [3]
  \item[2.102.5] Use Debian package management [8]
  \item[2.102.6] Use Red Hat Package Manager (RPM) [8]
\end{description}
\vfill \end{slide} %-----------------------------------------------------------
 

%==============================================================================
%==============================================================================
\begin{slide} %ghr
\slideheading{Install a boot manager [1] }
\slidesubheading{Objective} 

Candidate should be able to select, install and configure a boot
manager. This objective includes providing alternative boot locations
and backup boot options (for example, using a boot floppy).

\vfill \end{slide} %-----------------------------------------------------------
 
%==============================================================================
\begin{slide} %ghr
\slideheading{Install a boot manager [1]}
\slidesubheading{Key files, terms, and utilities}
\begin{alltt}
/etc/lilo.conf
lilo
/boot/grub/grub.conf
grub-install
MBR
superblock 
first stage boot loader
\end{alltt} 
\vfill \end{slide} %-----------------------------------------------------------
 
%==============================================================================
\begin{slide} %ghr
\slideheading{}
\slidesubheading{Resources of interest}
\begin{description} 
  \item[LinuxGazette GRUB article]: 
  \begin{alltt}
http://www.linuxgazette.com/issue64/kohli.html:    
  \end{alltt}
  \item[The GNU Grub Site]:
\begin{alltt}
http://www.gnu.org/software/grub/
\end{alltt}
\end{description}
\vfill \end{slide} %-----------------------------------------------------------
 
%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{Disk Organisation}
  \begin{itemize}
  \item A disk is organised into:
  \begin{itemize}
    \item Cylinders
    \item Heads
    \item Sectors
\end{itemize}
\item All sectors of Cyl 0, Head 0 are reserved:
\end{itemize}
\fbox{\epsfig{file=../images/lilo1.eps,height=.25\textwidth}}
\vfill \end{slide} %-----------------------------------------------------------
 
%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{Disk Organisation}
\begin{itemize}
\item Fdisk on a floppy confirms this:
\end{itemize}
\begin{alltt}
Disk /dev/fd0: 2 heads, 18 sectors, 80 cylinders
Units = cylinders of 36 * 512 bytes

    Device   Start       End    Blocks   
/dev/fd0p1       1         1         9   
/dev/fd0p2       2         2        18   
/dev/fd0p3       3         3        18   
/dev/fd0p4      80        80        18   
\end{alltt}
\begin{itemize}
\item Note the first partition is smaller than the rest
\end{itemize}
\vfill \end{slide} %-----------------------------------------------------------
 
%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{The DOS Boot Process}
  \begin{itemize}
  \item A Power On Self Test is performed.
  \item Control is passed to the boot device
  \item The first sector on disk is loaded into memory
  \item The MBR code is executed:
    \begin{itemize}
    \item It reads the partition table
    \item Looks for an active partition
    \item Loads the boot sector of active partition
    \item Executes the code in that boot sector
    \end{itemize}
  \end{itemize}
  \vfill \end{slide} %-----------------------------------------------------------

%==============================================================================
%==============================================================================
\begin{slide}{} %Andrew Eager
  \slideheading{The Master boot record}
  \begin{itemize}
  \item The MBR is the first block (sector) on the disk
  \item It contains:
    \begin{itemize}
    \item Boot Code:         446 bytes
    \item Partition Table     64 bytes
    \item MBR Signature        2 bytes      (0x55AA)
    \item TOTAL              512 bytes
    \end{itemize}
  \end{itemize}
  \vfill \end{slide} %-----------------------------------------------------------

\begin{slide}{} %Andrew Eager
  \slideheading{The Master boot record}
\begin{tabular}{r|c|}
  \cline{2-2}
  \tt 0x000 & \\
  & Program code \\
  & \\
  & \\
  \cline{2-2}
  \tt 0x1BE & Partition table \\
  & \\
  \cline{2-2}
  \tt 0x1FE & Magic number (0xAA55) \\
  \cline{2-2}
\end{tabular}

\vfill \end{slide} %-----------------------------------------------------------

%==============================================================================
\begin{slide}{} %Andrew Eager
  \slideheading{Boot Loaders} 
  \slidesubheading{}
  A boot loader is a program that is responsible for selecting the operating system
  to be booted. Once the desired OS is selected for boot, the boot loader must transfer
  control to it.  Typical boot loaders are: 
  \begin{itemize}
  \item The DOS boot loader.  Not interactive
  \item LILO: An interactive boot loader
  \item GRUB: An interactive boot loader
  \item Boot Manager:  An interactive boot loader

\end{itemize}
\vfill \end{slide}


%==============================================================================
\begin{slide}{} %Andrew Eager
  \slideheading{LILO - The Linux Loader} 
  \slidesubheading{} 

  \begin{itemize}
  \item LILO is a two stage loader:
  \item Stage 1 is 446 bytes long \& is located in \textit{either}
    \begin{itemize}
    \item The MBR (Master boot record. Eg in /dev/hda)
    \textit{OR}
    \item The VBR (Volume boot record. Eg in /dev/hda1)
    \end{itemize}
  \item Stage 2 is a file (/boot.b) located in /boot
    it contains the bulk of the lilo functionality
  \end{itemize}
  \vfill \end{slide} %-----------------------------------------------------------

%==============================================================================
%==============================================================================

\begin{slide}{} %Andrew Eager
\slideheading{LILO Boot sequence} 
\slidesubheading{LILO in the VBR}

When LILO is installed in the VBR, it is up to the MBR to transfer control
to it.  This is normally done by setting the partition where LILO is installed
to 'active'.  You would use fdisk (either dos or linux) to do this:

\fbox{\epsfig{file=../images/lilo2.eps,width=0.9\textwidth}}

\vfill \end{slide} %-----------------------------------------------------------

%==============================================================================

\begin{slide}{} %Andrew Eager
\slideheading{LILO Boot sequence} 
\slidesubheading{LILO in the MBR}

When LILO is installed in the MBR, the BIOS transfers control directly to LILO's 
1st stage boot loader.  In this case, the VBR is not used and it does not matter
which partition is marked active in the partition table:

 
\fbox{\epsfig{file=../images/lilo3.eps,width=0.9\textwidth}}

\vfill \end{slide} %-----------------------------------------------------------
%==============================================================================

\begin{slide}{} %Andrew Eager
\slideheading{LILO} 
\slidesubheading{LILO and the BIOS}

LILO uses the BIOS INT13 calls to read the following files:
\begin{itemize}
\item /boot/boot.b - The second stage loader
\item /boot/map - The map file 
\item All kernels
\item The Volume Boot sectors of all OS's it boots
\item The boot message if one has been set
\end{itemize}
\vfill \end{slide}

%==============================================================================

\begin{slide}{} %Andrew Eager
\slideheading{LILO} 
\slidesubheading{Configuring LILO}

LILO is entirely configured within the file /etc/lilo.conf.  This file contains
three areas.
\begin{itemize}
\item Global Options (eg signon message, delay time etc)
\item General 'per operating system' options
\item Linux kernel options (Linux only - eg root device, ro etc)
\end{itemize}
\vfill \end{slide}

%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{LILO} 
  \slidesubheading{Installing LILO}

  Once LILO has been configured, it can be installed by running \textbf{/sbin/lilo}
  as root from the command line.  This will do the following:
  \begin{itemize}
\item Make a backup copy of the boot sector (MBR or VBR)
  \item Create a /boot/map file with the locations of:
    \begin{itemize}
    \item /boot/boot.b
    \item The kernel
    \item /boot/message
    \item /boot/chain.b
    \end{itemize}

  \item Make a boot sector containing the location of the map file
  \item Write the boot sector to either the MBR or VBR.
  \end{itemize}
  \vfill \end{slide}


%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{LILO } 
  \slidesubheading{LILO diagnostics}

  When LILO runs, it prints the word 'L I L O' in the top left hand corner of the
  screen, one letter at a time:
  \begin{itemize}
  \item 'L' - Stage 1 loaded \& running.
  \item 'LI' - Stage 2 was loaded but could not run
  \item 'LIL' - Stage 2 was loaded but could not locate the descriptor table
  \item 'LIL?' - Stage 2 was loaded at an incorrect address
  \item 'LIL-' - Stage 2 was loaded but descriptor table is corrupt
  \item 'LILO' - LILO has started up correctly.
  \end{itemize}

  \vfill \end{slide} %-----------------------------------------------------------

%==============================================================================


\begin{slide}{} %Andrew Eager
  \slideheading{GRUB } 
  \slidesubheading{}

GRUB operates in a similar manner to LILO.  It is a two stage loader that can load
stage 1 into either the MBR or VBR.

The main differences between LILO and GRUB are:
\begin{itemize}
\item Stage 2 can be located beyond the 1024 cylinder limit.
\item GRUB can boot from network devices using tftp
\item GRUB has many more configuration options
\item GRUB is effectively a mini shell and can be configured 'on-the-fly' by
    giving it commands directly at boot time.

  \end{itemize}

  \vfill \end{slide} %-----------------------------------------------------------


%==============================================================================


\begin{slide}{} %Andrew Eager
  \slideheading{GRUB } 
  \slidesubheading{Hard Disk Naming Conventions}

GRUB uses a different naming convention to that of the rest of the Linux world.
In general, the syntax used is:
       hdN,X
where:
      N is the hard disk number (0 for the first, 1 for the second...)
      X is the partition number (0 for the first, 1 for the second...)

Examples:
    (hd0,1)  refers to the 1st physical drive, 2nd primary partition
    (hd1,6)  refers to the 2nd physical drive, 3rd logical partition
    (fd0)    refers to the floppy drive

A file within a partition can be referred to by appending a path to it:
EG:
    (hd0,0)/boot/vmlinuz, refers to the file /boot/vmlinuz on the 1st drive, 1st partition

  \vfill \end{slide} %-----------------------------------------------------------

%==============================================================================


\begin{slide}{} %Andrew Eager
  \slideheading{GRUB } 
  \slidesubheading{Installing GRUB}

Once the configuration file has been created, there are two ways to install GRUB:

Option 1: Run grub from the command line:
\begin{alltt}
[root@cds grub]# /sbin/grub
grub> root (hd0,6)
grub> setup (hd0)
       or;
grub> setup (hd0,4)
\end{alltt}

\vfill \end{slide}

%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{GRUB} 
  \slidesubheading{Installing GRUB}

Option 2: Use the grub-install command:
To install into the MBR:

\begin{alltt}
[root@cds grub]# grub-install /dev/hda
\end{alltt}

To install into the VBR:
\begin{alltt}
[root@cds grub]# grub-install /dev/hda5
\end{alltt}

If you have a separate /boot partition, then you need to specify boot directory:
\begin{alltt}
[root@cds grub]# 
grub-install --root-directory=/boot /dev/hda5
\end{alltt}

\vfill \end{slide} %-----------------------------------------------------------




%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{Sample Installation } 
  \slidesubheading{}

The diagram below shows the disk layout used for the sample configuration scripts.

\fbox{\epsfig{file=../images/lilo4.eps,height=2in}}

\vfill \end{slide}

%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{Sample Installation } 
  \slidesubheading{LILO configuration}
\begin{alltt}

# Global configuration options
boot=/dev/hda
timeout=20              
message=/boot/message   
prompt                  
default=linux           
vga=normal              
map=/boot/map           
install=/boot/boot.b

# Per image options
other=/dev/hda3                 
    label=WIN98

other=/dev/hda2
    label=QNX

other=/dev/hda1
    label=DOS

image=/boot/vmlinuz     
    label=linux         
    root=/dev/hda7      
    read-only           

\end{alltt}

\vfill \end{slide}
%==============================================================================

\begin{slide}{} %Andrew Eager
  \slideheading{Sample Installation } 
  \slidesubheading{GRUB configuration}
\begin{alltt}

default=0
timeout=10
fallback=1
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title RedHat 7.2
        root (hd0,4) 
        kernel /vmlinuz ro root=/dev/hda7
        initrd /initrd.img

title Windows   
        root (hd0,2)
        makeactive
        chainloader +1

title QNX
        root  (hd0,1)
        makeactive
        chainloader +1

title DOS
        root  (hd0,0)
        makeactive
        chainloader +1

\end{alltt}

\vfill \end{slide}

%==============================================================================


\end{document}

