\chapter{Getting Started}\label{bootup}

\begin{quote}
This login session: \$13.99, but for you \$11.88.
\end{quote}

\section{Starting to Use Your Computer}

You may have previous experience with MS-DOS\index{MS-DOS} or other
single user operating systems, such as OS/2\index{OS/2} or the
Macintosh.\index{Macintosh}  In these operating systems, you didn't
have to identify yourself to the computer before using it; it was
assumed that you were the only user of the system and could access
everything. Well, \unix\ is a multi-user operating system---not only
can more than one person use it at a time, different people are
treated differently.\footnote{Discrimination?  Perhaps.  You decide.}

To tell people apart, \unix\ needs a user to identify him or
herself\footnote{From here on in this book, I shall be using the
masculine pronouns to identify all people.  This is the standard
English convention, and people shouldn't take it as a statement that
only men can use computers.} by a process called {\bf logging
in}.\index{login} You see, when you first turn on the computer,
several things happen.  Since this guide is geared towards \linux,
I'll tell you what happens during the \linux\ boot-up
sequence.\glossary{boot-up}

Please note that if you're using \linux\ on some type of computer
besides an Intel\index{Intel} PC, some things in this chapter won't
apply to you.  Mostly, they'll be in Section~\ref{intel-powerup} and
Section~\ref{linux-powerup}. (Some parts of Section~\ref{linux-powerup} will
pertain.)

\subsection{Power to the Computer}\label{intel-powerup}

The first thing that happens when you turn an Intel\index{Intel} PC on
is that the BIOS\index{BIOS}\glossary{BIOS} executes. BIOS\index{BIOS}
stands for {\bf B}asic {\bf I}nput/{\bf O}utput {\bf S}ystem.  It's a
program permenantly stored in the computer on read-only chips,
normally.  For our purposes, the BIOS can never be changed. It
performs some minimal tests, and then looks for a floppy disk in the
first disk drive.  If it finds one, it looks for a ``boot sector'' on
that disk, and starts executing code from it, if any.  If there is a
disk, but no boot sector, the BIOS will print a message like:
\begin{screen}
Non-system disk or disk error
\end{screen}
Removing the disk and pressing a key will cause the boot process to
continue.

% Graphics? ***

If there isn't a floppy disk in the drive, the BIOS\index{BIOS} looks
for a master boot record\glossary{master boot record}
\index{master boot record} (MBR) on the hard disk.  It will start
executing  the code
found there, which loads the operating system.  On \linux\ systems,
LILO\index{LILO}, the {\bf LI}nux {\bf LO}ader, can occupy the MBR
position, and will load \linux.  For now, we'll assume that happens
and that \linux\ starts to load. (Your particular distribution may
handle booting from the hard disk differently.  Check with the
documentation included in that distribution. Another good reference is
the LILO\index{LILO} documentation,~\cite{Al:LILO}.)

\subsection{\linux\ Takes Over}\label{linux-powerup}

Before reading this section, you should know that nothing in it is
needed to actually {\em use\/} \linux.  It is only here for your own
enjoyment and interest, but if you find it boring or overly technical,
skip over it!

After the BIOS\index{BIOS} passes control to LILO\index{LILO}, LILO
passes control to \linux. (This is assuming you have configured
\linux\ to boot by default.  It is also possible for LILO to call
DOS\index{DOS} or some other PC operating system.) The first thing
that \linux\ does once it starts executing is to change to protected
mode.\glossary{protected mode} The 80386\footnote{When I refer to the
  80386, I am also talking about the 80486 unless I specifically say
  so.  Also, I'll be abbreviating 80386 as 386.} CPU that controls
your computer has two modes (for our purposes) called real
mode\glossary{real mode} and protected mode.  DOS\index{DOS} runs in
real mode, as does the BIOS.\index{BIOS} However, for more advanced
operating systems, it is necessary to run in protected mode.
Therefore, when \linux\ boots, it discardes the BIOS.

\linux\ then looks at the type of hardware it's running on.  It wants
to know what type of hard disks you have, whether or not you have a
bus mouse, whether or not you're on a network, and other bits of
trivia like that.  \linux\ can't remember things between boots, so it
has to ask these questions each time it starts up.  Luckily, it isn't
asking {\em you\/} these questions---it is asking the hardware!
During boot-up, the \linux\ kernel will print variations on several
messages. You can read about the messages in
Section~\ref{kernel-messages}.

The kernel merely manages other programs, so once it is satisfied
everything is okay, it must start another program to do anything
useful. The program the kernel starts is called {\tt init} 
\ttindex{init}. (Notice the difference in font.  Things in that font are
usually the names of programs, files, directories, or other computer
related items.) After the kernel starts {\tt init}\ttindex{init}, it
never starts another program. The kernel becomes a manager and a
provider, not an active program.

So to see what the computer is doing after the kernel boots up, we'll
have to examine {\tt init}\ttindex{init}. {\tt init}\ttindex{init}
goes through a complicated startup sequence that isn't the same for
all computers.  For \linux\ there are many versions of {\tt
init}\ttindex{init}, and each does things its own way. It also
matters whether your computer is on a network, or what distribution
you used to install \linux. Some things that might happen once {\tt
init}\ttindex{init} is started:

\begin{itemize}
\item The file systems\glossary{file system} might be checked. What is
a file system, you might ask? A file system is the layout of files on
the hard disk.  It let's \unix\ know which parts of the disk are
already used, and which aren't.  Unfortunately, due to various factors
such as power losses, what the file system information thinks is going
on in the rest of the disk and the actually layout of the rest of the
disk are in conflict. A special program, called {\tt fsck}, can find
these situations and hopefully correct them.
\item Special routing\glossary{route} programs for
networks\glossary{network} are run.
\item Temporary files left by some programs may be deleted.
\item The system clock can be correctly updated.  This is trickier
then one might think, since \unix, by default, wants the time in GMT
and your CMOS clock, a battery powered clock in your computer, is
probably set on local time.
\end{itemize}

After {\tt init}\ttindex{init} is finished with its duties at boot-up,
it goes on to its regularly scheduled activities. {{\tt init}}
\ttindex{init} can be called the parent of all processes
\index{process}\glossary{process} on a \unix\ system.  A process is
simple a running program; since any one program can be running more
than once, there can be two or more processes for any particular
program. (Processes can also be sub-programs, but that isn't important
right now.)  There are as many processes operating as there are
programs.

In \unix, a process\index{process}, an instance of a program, is
created by a system call\glossary{system call}, a service provided by
the kernel, called {\tt fork}\index{process!forking}\ttindex{fork}.
{\tt init}\ttindex{init} {\tt fork}s a couple of processes, which in
turn {\tt fork} some of their own. On your \linux\ system, what {\tt
init} runs are several instances of a program called {\tt
getty}.\ttindex{getty} {\tt getty} will be covered in\ldots

\subsection{The User Acts}

This section actually contains information needed to know how to use
\linux.

The first thing you have to do to use a \unix\ machine is to identify
yourself. This process, knowing as ``logging in'', is \unix's way of
knowing that users are authorized to use the system.  It asks for an
account name\index{account} and password.\index{password} An account
name is normally similar to your regular name; you should have already
received one from your system administrator, or created your own if
you are the system administrator. (Information on doing this should be
available in \ldpgs\ or \ldpsa.)

You should see, after all the boot-up procedures are done, something
like the following:

\begin{screen}\begin{verbatim}
Welcome to the mousehouse. Please, have some cheese.

mousehouse login:
\end{verbatim}\end{screen}

\blackdiamond However, it's possible that what the system presents you
with does {\em not\/} look like this. Instead of a boring text mode
screen, it is graphical. However, it will still ask you to login, and
will function mostly the same way.  If this is the case on your
system, you are going to be using The X Window System\index{X Window System}. 
This means that you will be presented with a windowing
system.  Chapter~\ref{x-chapter} will discuss some of the differences
that you'll be facing. However, logging in will be similar. If you are
using X, look for a giant X is the margin.

This is, of course, your invitation to {\bf login}.\index{login}
Throughout this manual, we'll be using the fictional (or not so
fictional, depending on your machine) user {\tt larry}.  Whenever you
see {\tt larry}, you should be substituting your own account name.
Account names are usually based on real names; bigger, more serious
\unix\ systems will have accounts using the user's last name, or some
combination of first and last name, or even some numbers. Possible
accounts for Larry Greenfield\index{Greenfield, Larry!account names for} 
might be: {\tt larry}, {\tt greenfie}, {\tt lgreenfi}, {\tt lg19}.

{\tt mousehouse} is, by the way, the ``name'' of the machine I'm
working on. It is possible that when you installed \linux, you were
prompted for some very witty name. It isn't very important, but
whenever it comes up, I'll be using {\tt mousehouse} or, rarely, {\tt
lionsden}.

After entering {\tt larry}, I'm faced with the following:

\begin{screen}\begin{verbatim}
mousehouse login: larry
Password:
\end{verbatim}\end{screen}

What \linux\ is asking for is your {\bf password}. When you type in
your password, you won't be able to see what you type. Type carefully:
it is possible to delete, but you won't be able to see what you are
editing. Don't type too slowly if people are watching---they'll be
able to learn your password.  If you mistype, you'll be presented with
another chance to login.
\glossary{password}\index{password}

If you've typed your login name and password correctly, a short
message will appear, called the message of the day.  
\ttindex{/etc/motd} This could say anything---the system adminstrator
decides what it should be.  After that, a {\bf prompt}
appears.\index{shell!prompt} A prompt is just that, something
prompting you for the next command to give the system. It should look
like this:

\begin{screen}\begin{verbatim}
/home/larry#
\end{verbatim}\end{screen}

\xwarn If you've already determined you're using X Windows, you'll
probably see a prompt like the one above in a ``window'' somewhere on
the screen. (A ``window'' is simply a rectangular box.) To type into
the prompt, move the mouse cursor (it probably looks like a big ``x'')
using the mouse into the window.

\section{Leaving the Computer}

\blackdiamond Do not just turn off the computer! You risk losing
valuable data!

Unlike most versions of DOS\index{DOS}, it's a bad thing to just hit
the power switch when you're done using the computer.  It is also bad
to reboot the machine (with the reset button) without first taking
proper precautions.  \linux, in order to improve performance,
caches\glossary{cache} the disk.  This means it temporarily stores
part of the permanent storage in RAM\@.  The idea of what \linux\ thinks
the disk should be and what the disk actually contains is syncronized
every 30 seconds.  In order to turn off or reboot the computer, you'll
have to go through a procedure telling it to stop caching disk
information.

If you're done with the computer, but are logged in (you've entered a
username and password), first you must logout. To do so, enter the
command {\tt logout}. All commands are sent by pressing the key marked
``Enter'' or ``Return''. Until you hit enter, nothing will happen, and
you can delete what you've done and start over.

\begin{screen}\begin{verbatim}
/home/larry# logout

Welcome to the mousehouse. Please, have some cheese.

mousehouse login:
\end{verbatim}\end{screen}

Now another user can login.

\subsection{Turning the Computer Off}

If this is a single user system, you might want to turn the computer
off when you're done with it.\footnote{To avoid possibly weakening
  some hardware components, only turn off the computer when you're
  done for the day.} To do so, you'll have to log into a
special account called {\tt root}. The {\tt root} account is the
system adminstrator's account and can access any file on the system.
If you're going to turn the computer off, get the password from the
system adminstrator. (In a single user system, that's {\em you\/}!
Make sure you know the default {\tt root} password.) Login as {\tt
  root}:

\begin{screen}\begin{verbatim}
mousehouse login: root
Password:

Linux, version 0.99pl10.
/# shutdown now

************ GET THE SHUTDOWN MESSAGE CORRECT ***********
\end{verbatim}\end{screen}

The command {\tt shutdown now} prepares the system to be reset or
turned off.  Wait for a message saying it is safe to and then reset or
turn off the system. You must go through this procedure, however.  You
risk losing your work if you don't.

A quick message to the lazy: an alternative to the logout/login
approach is to use the command {\tt su}. As a normal user, from your
prompt, type {\tt su} and \ret. It should prompt you for the root
password, and then give you root privileges. Now you can shutdown the
system.

\section{Kernel Messages}\label{kernel-messages}

% perhaps this section will be moved to another chapter

The messages printed by the kernel vary from machine to machine, and
from kernel version to version.  The version of \linux\ that is
discussed in {\em this\/} section is ``0.99.10''. (Please note that
this is a big book, and \linux\ develops quickly. Versions in other
sections might be different. Usually, this distinction is
unimportant.)

\subsection{Starting Messages}

When \linux\ first starts up, it writes many messages to the screen
which you might not be able to see. \linux\ maintains a special file,
called {\tt /proc/kmsg}, which stores all these messages for later
viewing, and I've included a sample startup sequence here.

\index{\linux\ kernel!starting messages}
\begin{itemize}
\item The first thing \linux\ does is decides what type of video card
and screen you have, so it can pick a good font size. (The smaller the
font, the more that can fit on the screen on any one time.) \linux\
may ask you if you want a special font, or it might have had a choice
compiled in.\footnote{``Compiled'' is the process by which a computer
program that a human writes gets translated into something the
computer understands.  A feature that has been ``compiled in'' has
been included in the program.}
\begin{screen}\begin{verbatim}
Console: colour EGA+ 80x25, 8 virtual consoles Serial driver version
\end{verbatim}\end{screen}
In this example, the machine owner decided he wanted the standard,
large font at compile time.\glossary{compile}\glossary{binary} Also,
note the misspelling of the word ``color.'' Linus evidentally learned
the wrong version of English.\index{Torvalds, Linus!English
  usage}\footnote{An editor has scolded me for my United States
  chauvinism, so you don't have to send me mean mail messages!}

\item \linux\ has now switched to protected mode, and the serial
\index{serial ports}
driver\glossary{driver} has started to ask questions about the
hardware.  A driver is a part of the kernel that controls a device,
usually a peripheral.
\begin{screen}\begin{verbatim}
Serial driver version 3.95 with no serial options enabled
tty00 at 0x03f8 (irq = 4) is a 16450
tty01 at 0x02f8 (irq = 3) is a 16450
tty02 at 0x03e8 (irq = 4) is a 16450
\end{verbatim}\end{screen}
Here, it found 3 serial ports.  A serial port is the equivalent of
a DOS\index{DOS} {\tt COM} port, and is a device normally used with
modems and mice.

What it is trying to say is that serial port 0 ({\tt COM1}) has an
address of {\tt 0x03f8}. When it interrupts the kernel,
usually to say that it has data, it uses IRQ 4. An IRQ is another
means of a peripheral talking to the software.  Each serial port also
has a controller chip.  The usual one for a port to have is a 16450;
other values possible are 8250 and 16550. The differences are beyond
the scope of this book.

\item Next comes the parallel port driver.  A parallel port is
\index{parallel ports}
normally connected to a printer, and the names for the parallel ports
(in \linux) start with {\tt lp}. {\tt lp} stands for {\bf L}ine {\bf
P}rinter, although it could be a laser printer.
\begin{screen}\begin{verbatim}
lp_init: lp0 exists (0), using polling driver
\end{verbatim}\end{screen}
That message says it has found one parallel port, and is using the
standard driver for it.

\item The \linux\ kernel also tells you a little about memory usage:
  \begin{screen}\begin{verbatim}
Memory: 7296k/8192k available (384k kernel code, 384k reserved, 128k data)
\end{verbatim}\end{screen}
This said that the machine had 8 megabytes\glossary{megabyte} of
memory. Some of this memory was reserved for the kernel---just the
operating system.  The rest of it could be used by programs.

The other type of ``memory'' is general called a hard
disk.\glossary{hard disk} It's like a large floppy disk permenantly in
your computer---the contents stay around even when the power is off.

\item The kernel now moves onto looking at your floppy drives. In this
example, the machine has two drives. In DOS\index{DOS}, drive ``A'' is
a $5\ {1/4}$ inch drive, and drive ``B'' is a $3\ {1/2}$ inch drive.
\linux\ calls drive ``A'' {\tt fd0}, and drive ``B'' {\tt fd1}.
\begin{screen}\begin{verbatim}
Floppy drive(s): fd0 is 1.2M, fd1 is 1.44M
floppy: FDC version 0x90
\end{verbatim}\end{screen}
\item Now \linux\ moves onto less needed things, such as network
  cards.\glossary{network} The following should be described in
  \ldpng, and is beyond the scope of this document.\footnote{This may
    change in latter `versions' of this book.}
\begin{screen}\begin{verbatim}
SLIP: version 0.7.5 (4 channels): OK
plip.c:v0.04 Mar 19 1993 Donald Becker (becker@super.org)
plip0: using parallel port at 0x3bc, IRQ 5.
plip1: using parallel port at 0x378, IRQ 7.
plip2: using parallel port at 0x278, IRQ 2.
8390.c:v0.99-10 5/28/93 for 0.99.6+ Donald Becker (becker@super.org)
WD80x3 ethercard probe at 0x280: FF FF FF FF FF FF not found (0x7f8).
3c503 probe at 0x280:  not found.
8390 ethercard probe at 0x280 failed.
HP-LAN ethercard probe at 0x280: not found (nothing there).
No ethernet device found.
dl0: D-Link pocket adapter: probe failed at 0x378.
\end{verbatim}\end{screen}
\item The next message you normally won't see as the machine boots up.
  \linux\ supports a FPU\index{FPU}, a floating point unit. This is a
  special chip (or part of a chip, in the case of a
  80486DX CPU\glossary{floating point unit}) that performs arithmetic
  dealing with non-whole numbers. Some of these chips are bad, and
  when \linux\ tries to identify these chips, the machine ``crashes''.
  That is to say, the machine stops functioning. If this happens,
  you'll see:
\begin{screen}\begin{verbatim}
You have a bad 386/387 coupling.
\end{verbatim}\end{screen}\index{error!bad 386/387 coupling}
Otherwise, you'll see:
\begin{screen}\begin{verbatim}
Math coprocessor using exception 16 error reporting.
\end{verbatim}\end{screen}
if you're using a 486DX\@.  If you are using a 386 with a 387, you'll see:
\begin{screen}\begin{verbatim}
Math coprocessor using irq13 error reporting.
\end{verbatim}\end{screen}

If you don't have any type of math coprocessor at all, you'll see:
\begin{screen}\begin{verbatim}
What will they see?
\end{verbatim}\end{screen}
% Something about math emulation probably. ***** -M
% LG: I don't think it even prints these messages anymore. Should be
% updated with the kernel source in hand

\item The kernel also scans for any hard disks you might have.  If it
  finds any (and it should) it'll look at what partitions you have on
  them.  A partition is a logical separation on a drive that is used
  to keep operating systems from interfering with each other. In this
  example, the computer had one hard disk ({\tt hda}) with four
  partitions.\index{partition!disk}
\begin{screen}\begin{verbatim}
Partition check:
  hda: hda1 hda2 hda3 hda4
\end{verbatim}\end{screen}

\item Finally, \linux\ {\bf mounts}\glossary{mount}\index{mount} the
  root partition.  The root partition is the disk partition where the
  \linux\ operating system resides.\index{partition!root}  When
  \linux\ ``mounts'' this partition, it is making the partition
  available for use by the user.
\begin{screen}\begin{verbatim}
VFS: Mounted root (ext filesystem).
\end{verbatim}\end{screen}
\end{itemize} % kernel start-up messages

\subsection{Run-time Messages}

The \linux\ kernel occasionally sends messages to your screen.  The
following is a list of some of these messages and what they mean.
Frequently, these messages indicate something is wrong.  Some of these
messages are {\bf critical}, which means the operating system (and all
your programs!) stops working.  When these messages occur, you should
write them down and what you where doing at the time, and send them to
Linus. See Section~\ref{error-reporting}.

Luckily, some of these messages are merely informational---hopefully,
you'll see them more often!

\index{\linux\ kernel!running messages}
\begin{itemize}
\item
\begin{screen}\begin{verbatim}
Adding Swap: 10556k swap-space
lp0 on fire
******** OBVIOUSLY INCOMPLETE
\end{verbatim}\end{screen}

\end{itemize} % running messages
% Local Variables: 
% mode: latex
% TeX-master: "guide"
% End: 
