401 lines
8.7 KiB
HTML
401 lines
8.7 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Bootdisks and the boot process</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.63
|
|
"><LINK
|
|
REL="HOME"
|
|
TITLE="The Linux Bootdisk HOWTO"
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Introduction"
|
|
HREF="x68.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Building a root filesystem"
|
|
HREF="buildroot.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>The Linux Bootdisk HOWTO</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x68.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="buildroot.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="AEN88"
|
|
>3. Bootdisks and the boot process</A
|
|
></H1
|
|
><P
|
|
>A bootdisk is basically a miniature, self-contained Linux system on a
|
|
diskette. It must perform many of the same functions that a complete
|
|
full-size Linux system performs. Before trying to build one you should
|
|
understand the basic Linux boot process. Here we present the basics, which
|
|
are sufficient for understanding the rest of this document. Many details and
|
|
alternative options have been omitted.</P
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="AEN93"
|
|
>3.1. The boot process</A
|
|
></H2
|
|
><P
|
|
>
|
|
|
|
All PC systems start the boot process by executing code in ROM
|
|
(specifically, the <EM
|
|
>BIOS</EM
|
|
>) to load the sector from
|
|
sector 0, cylinder 0 of the boot drive. The boot drive is usually the
|
|
first floppy drive (designated <TT
|
|
CLASS="FILENAME"
|
|
>A:</TT
|
|
> in DOS and
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/dev/fd0</TT
|
|
> in Linux). The BIOS then tries to execute
|
|
this sector. On most bootable disks, sector 0, cylinder 0 contains either:
|
|
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>code from a boot loader such as LILO, which locates the kernel,
|
|
loads it and executes it to start the boot proper; or </P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>the start of an operating system kernel, such as Linux. </P
|
|
></LI
|
|
></UL
|
|
> </P
|
|
><P
|
|
>If a Linux kernel has been raw-copied to a diskette, the first sector of the
|
|
disk will be the first sector of the Linux kernel itself. This first sector
|
|
will continue the boot process by loading the rest of the kernel from the boot
|
|
device.</P
|
|
><P
|
|
>When the kernel is completely loaded, it initializes device drivers and its
|
|
internal data structures. Once it is completely initialized, it consults a
|
|
special location in its image called the <EM
|
|
>ramdisk word</EM
|
|
>.
|
|
This word tells it how and where to find its <EM
|
|
>root
|
|
filesystem</EM
|
|
>. A root filesystem is simply a filesystem that will be
|
|
mounted as ``<TT
|
|
CLASS="FILENAME"
|
|
>/</TT
|
|
>''. The kernel has to be told where to
|
|
look for the root filesystem; if it cannot find a loadable image there, it
|
|
halts.</P
|
|
><P
|
|
>In some boot situations — often when booting from a diskette
|
|
— the root filesystem is loaded into a <EM
|
|
>ramdisk</EM
|
|
>,
|
|
which is RAM accessed by the system as if it were a disk. RAM is several
|
|
orders of magnitude faster than a floppy disk, so system operation is fast
|
|
from a ramdisk. Also, the kernel can load a <EM
|
|
>compressed
|
|
filesystem</EM
|
|
> from the floppy and uncompress it onto the ramdisk,
|
|
allowing many more files to be squeezed onto the diskette. </P
|
|
><P
|
|
>Once the root filesystem is loaded and mounted, you see a message like:
|
|
<TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
> VFS: Mounted root (ext2 filesystem) readonly.</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
><P
|
|
>Once the system has loaded a root filesystem successfully, it tries to
|
|
execute the <TT
|
|
CLASS="FILENAME"
|
|
>init</TT
|
|
> program (in <TT
|
|
CLASS="FILENAME"
|
|
>/bin</TT
|
|
> or
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/sbin</TT
|
|
>). <TT
|
|
CLASS="FILENAME"
|
|
>init</TT
|
|
> reads its
|
|
configuration file <TT
|
|
CLASS="FILENAME"
|
|
>/etc/inittab</TT
|
|
>, looks for a line
|
|
designated <TT
|
|
CLASS="LITERAL"
|
|
>sysinit</TT
|
|
>, and executes the named script. The
|
|
<TT
|
|
CLASS="LITERAL"
|
|
>sysinit</TT
|
|
> script is usually something like
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/etc/rc</TT
|
|
> or <TT
|
|
CLASS="FILENAME"
|
|
>/etc/init.d/boot</TT
|
|
>. This
|
|
script is a set of shell commands that set up basic system services, such as
|
|
running <B
|
|
CLASS="COMMAND"
|
|
>fsck</B
|
|
> on hard disks, loading necessary kernel
|
|
modules, initializing swapping, initializing the network, and mounting disks
|
|
mentioned in <TT
|
|
CLASS="FILENAME"
|
|
>/etc/fstab</TT
|
|
>.</P
|
|
><P
|
|
>This script often invokes various other scripts to do modular
|
|
initialization. For example, in the common SysVinit structure, the directory
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/etc/rc.d/</TT
|
|
> contains a complex structure of subdirectories
|
|
whose files specify how to enable and shut down most system services. However,
|
|
on a bootdisk the sysinit script is often very simple.</P
|
|
><P
|
|
>When the sysinit script finishes control returns to <B
|
|
CLASS="COMMAND"
|
|
>init</B
|
|
>,
|
|
which then enters the <EM
|
|
>default runlevel</EM
|
|
>, specified in
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>inittab</TT
|
|
> with the <TT
|
|
CLASS="LITERAL"
|
|
>initdefault</TT
|
|
> keyword.
|
|
The runlevel line usually specifies a program like <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
>,
|
|
which is responsible for handling commununications through the console and
|
|
ttys. It is the <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> program which prints the familiar
|
|
``<TT
|
|
CLASS="PROMPT"
|
|
>login:</TT
|
|
>'' prompt. The <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> program in
|
|
turn invokes the <B
|
|
CLASS="COMMAND"
|
|
>login</B
|
|
> program to handle login validation
|
|
and to set up user sessions.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="AEN159"
|
|
>3.2. Disk types</A
|
|
></H2
|
|
><P
|
|
>Having reviewed the basic boot process, we can now define various
|
|
kinds of disks involved. We classify disks into four types. The
|
|
discussion here and throughout this document uses the term ``disk'' to
|
|
refer to floppy diskettes unless otherwise specified, though most of
|
|
the discussion could apply equally well to hard disks.</P
|
|
><P
|
|
><P
|
|
></P
|
|
><DIV
|
|
CLASS="VARIABLELIST"
|
|
><DL
|
|
><DT
|
|
>boot</DT
|
|
><DD
|
|
><P
|
|
>A disk containing a kernel which can be booted. The disk
|
|
can be used to boot the kernel, which then may load a root file system on
|
|
another disk. The kernel on a bootdisk usually must be told where to find
|
|
its root filesystem.</P
|
|
><P
|
|
>Often a bootdisk loads a root filesystem from another diskette, but it is
|
|
possible for a bootdisk to be set up to load a hard disk's root filesystem
|
|
instead. This is commonly done when testing a new kernel (in fact,
|
|
``<B
|
|
CLASS="COMMAND"
|
|
>make zdisk</B
|
|
>'' will create such a bootdisk automatically
|
|
from the kernel source code).</P
|
|
></DD
|
|
><DT
|
|
>root</DT
|
|
><DD
|
|
><P
|
|
>A disk with a filesystem containing files
|
|
required to run a Linux system. Such a disk does not necessarily
|
|
contain either a kernel or a boot loader. </P
|
|
><P
|
|
>A root disk can be used to run the system independently of any other
|
|
disks, once the kernel has been booted. Usually the root disk is
|
|
automatically copied to a ramdisk. This makes root disk accesses much
|
|
faster, and frees up the disk drive for a utility disk.</P
|
|
></DD
|
|
><DT
|
|
>boot/root</DT
|
|
><DD
|
|
><P
|
|
>A disk which contains both the kernel and a root filesystem. In other
|
|
words, it contains everything necessary to boot and run a Linux system
|
|
without a hard disk. The advantage of this type of disk is that is it
|
|
compact — everything required is on a single disk. However, the gradually
|
|
increasing size of everything means that it is increasingly difficult to
|
|
fit everything on a single diskette, even with compression.</P
|
|
></DD
|
|
><DT
|
|
>utility</DT
|
|
><DD
|
|
><P
|
|
>A disk which contains a filesystem, but is not
|
|
intended to be mounted as a root file system. It is an additional data
|
|
disk. You would use this type of disk to carry additional utilities where
|
|
you have too much to fit on your root disk. </P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></P
|
|
><P
|
|
>In general, when we talk about ``building a bootdisk'' we mean
|
|
creating both the boot (kernel) and root (files) portions. They may
|
|
be either together (a single boot/root disk) or separate (boot + root
|
|
disks). The most flexible approach for rescue diskettes is probably
|
|
to use separate boot and root diskettes, and one or more utility
|
|
diskettes to handle the overflow.</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x68.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="buildroot.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Introduction</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Building a root filesystem</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |