1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--Converted with LaTeX2HTML 96.1-h (September 30, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->
<HTML>
<HEAD>
<TITLE>The boot process in closer look</TITLE>
<META NAME="description" CONTENT="The boot process in closer look">
<META NAME="keywords" CONTENT="sag">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<LINK REL=STYLESHEET HREF="sag.css">
</HEAD>
<BODY LANG="EN" >
<A NAME="tex2html1170" HREF="node69.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html1168" HREF="node66.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html1162" HREF="node67.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html1172" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html1173" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html1171" HREF="node69.html">More about shutdowns</A>
<B>Up:</B> <A NAME="tex2html1169" HREF="node66.html">Boots And Shutdowns</A>
<B> Previous:</B> <A NAME="tex2html1163" HREF="node67.html">An overview of boots </A>
<BR> <P>
<H1><A NAME="SECTION00720000000000000000">The boot process in closer look</A></H1>
<P>
<A NAME="secbootcloseup"> </A>
<P>
You can boot Linux either from a floppy or from the hard
disk. The installation section in the Installation and
Getting Started guide ([<A HREF="node113.html#getting-started">Wel</A>])
tells you how to install Linux so you can boot it the way
you want to.
<P>
When a PC is booted, the BIOS will do various tests to
check that everything looks all right,<A NAME="tex2html30" HREF="footnode.html#2102"><IMG ALIGN=BOTTOM ALT="gif" SRC="./foot_motif.gif"></A> and
will then start the actual booting. It will choose a disk
drive (typically the first floppy drive, if there is a floppy
inserted, otherwise the first hard disk, if one is installed
in the computer; the order might be configurable, however)
and will then read its very first sector. This is
called the <b>boot sector</b>; for a hard disk, it is also
called the <b>master boot record</b>, since a hard disk can
contain several partitions, each with their own boot sectors.
<A NAME="1980"> </A>
<A NAME="1981"> </A>
<A NAME="1982"> </A>
<A NAME="1983"> </A>
<A NAME="2103"> </A>
<A NAME="2104"> </A>
<P>
The boot sector contains a small program (small enough to fit into
one sector) whose responsibility is to read the actual operating
system from the disk and start it. When booting Linux from
a floppy disk, the boot sector contains code that just reads
the first few hundred blocks (depending on the actual
kernel size, of course) to a predetermined place in memory.
On a Linux boot floppy, there is no filesystem, the kernel
is just stored in consecutive sectors, since this simplifies
the boot process. It is possible, however, to boot from a
floppy with a filesystem, by using LILO, the LInux LOader.
<A NAME="1986"> </A>
<A NAME="2105"> </A>
<P>
When booting from the hard disk, the code in the master boot
record will examine the partition table (also in the master boot
record), identify the active
partition (the partition that is marked to be bootable), read
the boot sector from that partition, and then start the code
in that boot sector. The code in the partition's boot sector
does what a floppy disk's boot sector does: it will read in
the kernel from the partition and start it. The details vary,
however, since it is generally not useful to have a separate
partition for just the kernel image, so the code in the
partition's boot sector can't just read the disk in sequential
order, it has to find the sectors wherever the filesystem has
put them. There are several ways around this problem, but the
most common way is to use LILO. (The details about how to do
this are irrelevant for this discussion, however; see the LILO
documentation for more information; it is most thorough.)
<A NAME="1988"> </A>
<A NAME="2106"> </A>
<A NAME="1990"> </A>
<A NAME="1991"> </A>
<A NAME="1992"> </A>
<P>
When booting with LILO, it will normally go right ahead and
read in and boot the default kernel. It is also possible to
configure LILO to be able to boot one of several kernels, or
even other operating systems than Linux, and it is possible
for the user to choose which kernel or operating system is to
be booted at boot time. LILO can be configured so that if one
holds down the <TT>alt</TT>, <TT>shift</TT>, or <TT>ctrl</TT> key at
boot time (when LILO is loaded), LILO will ask what is to
be booted and not boot the default right away. Alternatively,
LILO can be configured so that it will always ask, with an
optional timeout that will cause the default kernel to be
booted.
<P>
With LILO, it is also possible to give a <b>kernel command
line argument</b>, after the name of the kernel or operating
system.
<P>
<b>META: </b> The are other boot loaders than LILO. Information about
them will be added in some future version. loadlin.
<P>
Booting from floppy and from hard disk have both their
advantages, but generally booting from the hard disk is
nicer, since it avoids the hassle of playing around with
floppies. It is also faster. However, it can be more
troublesome to install the system to boot from the hard
disk, so many people will first boot from floppy, then, when
the system is otherwise installed and working well, will
install LILO and start booting from the hard disk.
<P>
After the Linux kernel has been read into the memory, by
whatever means, and is started for real, roughly the following
things happen:
<P>
<UL>
<LI>
<P>
The Linux kernel is installed compressed, so it will first
uncompress itself. The beginning of the kernel image
contains a small program that does this.
<A NAME="1998"> </A>
<A NAME="1999"> </A>
<LI>
<P>
If you have a super-VGA card that Linux
recognizes and that has some special text modes (such as 100
columns by 40 rows), Linux asks you which mode
you want to use. During the kernel compilation, it is
possible to preset a video mode, so that this is never asked.
This can also be done with LILO or <tt>rdev</tt><A NAME="2125"> </A>.
<A NAME="2001"> </A>
<A NAME="2002"> </A>
<A NAME="2003"> </A>
<A NAME="2004"> </A>
<LI>
<P>
After this, the kernel checks what other hardware there is
(hard disks, floppies, network adapters...), and configures
some of its device drivers appropriately; while it does this,
it outputs messages about its findings. For example, when I
boot, I it looks like this:
<A NAME="2005"> </A>
<A NAME="2006"> </A>
<A NAME="2007"> </A>
<A NAME="2008"> </A>
<BLOCKQUOTE> <PRE>LILO boot:
Loading linux.
Console: colour EGA+ 80x25, 8 virtual consoles
Serial driver version 3.94 with no serial options enabled
tty00 at 0x03f8 (irq = 4) is a 16450
tty01 at 0x02f8 (irq = 3) is a 16450
lp_init: lp1 exists (0), using polling driver
Memory: 7332k/8192k available (300k kernel code, 384k reserved, 176k data)
Floppy drive(s): fd0 is 1.44M, fd1 is 1.2M
Loopback device init
Warning WD8013 board not found at i/o = 280.
Math coprocessor using irq13 error reporting.
Partition check:
hda: hda1 hda2 hda3
VFS: Mounted root (ext filesystem).
Linux version 0.99.pl9-1 (root@haven) 05/01/93 14:12:20</PRE></BLOCKQUOTE>
The exact texts are different on different systems, depending
on the hardware, the version of Linux being used, and how
it has been configured.
<LI>
<P>
Then the kernel will try to mount the root filesystem. The
place is configurable at
compilation time, or any time with <tt>rdev</tt><A NAME="2127"> </A>
or LILO. The filesystem type is detected
automatically. If the mounting of the root filesystem fails,
for example because you didn't remember to include the corresponding
filesystem driver in the kernel,
the kernel panics and halts the system (there isn't much it
can do, anyway).
<A NAME="2012"> </A>
<A NAME="2013"> </A>
<A NAME="2014"> </A>
<A NAME="2015"> </A>
<A NAME="2016"> </A>
<A NAME="2017"> </A>
<P>
The root filesystem is usually mounted read-only (this can
be set in the same way as the place). This makes it possible
to check the filesystem while it is mounted; it is not a good
idea to check a filesystem that is mounted read-write.
<A NAME="2018"> </A>
<A NAME="2019"> </A>
<A NAME="2020"> </A>
<LI>
<P>
After this, the kernel starts the program <tt>init</tt><A NAME="2129"> </A>
(located in <tt>/sbin/init</tt><A NAME="2131"> </A>) in
the background (this will always become process number 1).
<tt>init</tt><A NAME="2133"> </A> does various startup chores. The exact things it does
depends on how it is configured; see
chapter <A HREF="node73.html#chinit">7</A> for more information (not yet written). It will at least
start some essential background daemons.
<A NAME="2025"> </A>
<LI>
<P>
<tt>init</tt><A NAME="2135"> </A> then switches to multi-user mode, and starts
a <tt>getty</tt><A NAME="2137"> </A> for virtual consoles and serial lines.
<tt>getty</tt><A NAME="2139"> </A> is the program which lets people log in
via virtual consoles and serial terminals. <tt>init</tt><A NAME="2141"> </A>
may also start some other programs, depending on how
it is configured.
<A NAME="2030"> </A>
<A NAME="2031"> </A>
<A NAME="2032"> </A>
<A NAME="2033"> </A>
<LI>
<P>
After this, the boot is complete, and the system is up and
running normally.
<P>
</UL><HR><A NAME="tex2html1170" HREF="node69.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html1168" HREF="node66.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html1162" HREF="node67.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html1172" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html1173" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html1171" HREF="node69.html">More about shutdowns</A>
<B>Up:</B> <A NAME="tex2html1169" HREF="node66.html">Boots And Shutdowns</A>
<B> Previous:</B> <A NAME="tex2html1163" HREF="node67.html">An overview of boots </A>
<P><ADDRESS>
<I>Lars Wirzenius <BR>
Sat Nov 15 02:32:11 EET 1997</I>
</ADDRESS>
</BODY>
</HTML>
|