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
|
<!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>init comes first</TITLE>
<META NAME="description" CONTENT="init comes first">
<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="tex2html1245" HREF="node75.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html1243" HREF="node73.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html1237" HREF="node73.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html1247" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html1248" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html1246" HREF="node75.html">Configuring init to start </A>
<B>Up:</B> <A NAME="tex2html1244" HREF="node73.html">init</A>
<B> Previous:</B> <A NAME="tex2html1238" HREF="node73.html">init</A>
<BR> <P>
<A NAME="2327"> </A><H1><A NAME="SECTION00810000000000000000"><tt>init</tt> comes first</A></H1>
<P>
<tt>init</tt><A NAME="2329"> </A> is one of those programs that are absolutely essential
to the operation of a Linux system, but that you still can mostly
ignore. A good Linux distribution will come with a configuration
for <tt>init</tt><A NAME="2331"> </A> that will work for most systems, and on these
systems there is nothing you need to do about <tt>init</tt><A NAME="2333"> </A>. Usually,
you only need to worry about <tt>init</tt><A NAME="2335"> </A> if you hook up serial
terminals, dial-in (not dial-out) modems, or if you want to change
the default run level.
<P>
When the kernel has started itself (has been loaded into memory,
has started running, and has initialized all device drivers and
data structures and such), it finishes its own part of the boot
process by starting a user level program, <tt>init</tt><A NAME="2337"> </A>. Thus,
<tt>init</tt><A NAME="2339"> </A> is always the first process (its process number is
always 1).
<P>
The kernel looks for <tt>init</tt><A NAME="2341"> </A> in a few locations that have
been historically used for it, but the proper location for it
(on a Linux system) is <tt>/sbin/init</tt><A NAME="2343"> </A>. If the kernel can't
find <tt>init</tt><A NAME="2345"> </A>, it tries to run <tt>/bin/sh</tt><A NAME="2347"> </A>, and if that
also fails, the startup of the system fails.
<P>
When <tt>init</tt><A NAME="2349"> </A> starts, it finishes the boot process by doing
a number of administrative tasks, such as checking filesystems,
cleaning up <tt>/tmp</tt><A NAME="2351"> </A>, starting various services, and starting
a <tt>getty</tt><A NAME="2353"> </A> for each terminal and virtual console where users
should be able to log in (see chapter <A HREF="node79.html#chlogins">8</A>).
<P>
After the system is properly up, <tt>init</tt><A NAME="2355"> </A> restarts
<tt>getty</tt><A NAME="2357"> </A> for each terminal after a user has logged out (so
that the next user can log in). <tt>init</tt><A NAME="2359"> </A> also adopts orphan
processes: when a process starts a child process and dies before
its child, the child immediately becomes a child of <tt>init</tt><A NAME="2361"> </A>.
This is important for various technical reasons, but it is good
to know it, since it makes it easier to understand process lists
and process tree graphs.<A NAME="tex2html32" HREF="footnode.html#2308"><IMG ALIGN=BOTTOM ALT="gif" SRC="./foot_motif.gif"></A>
<P>
There are a few variants of <tt>init</tt><A NAME="2367"> </A> available. Most Linux
distributions use <tt>sysvinit</tt><A NAME="2369"> </A> (written by Miquel van
Smoorenburg), which is based on the System V <tt>init</tt><A NAME="2371"> </A> design.
The BSD versions of Unix have a different <tt>init</tt><A NAME="2373"> </A>. The primary
difference is run levels: System V has them, BSD does not
(at least traditionally). This difference is not essential.
We'll look at <tt>sysvinit</tt><A NAME="2375"> </A> only.
<P>
<HR><A NAME="tex2html1245" HREF="node75.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html1243" HREF="node73.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html1237" HREF="node73.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html1247" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html1248" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html1246" HREF="node75.html">Configuring init to start </A>
<B>Up:</B> <A NAME="tex2html1244" HREF="node73.html">init</A>
<B> Previous:</B> <A NAME="tex2html1238" HREF="node73.html">init</A>
<P><ADDRESS>
<I>Lars Wirzenius <BR>
Sat Nov 15 02:32:11 EET 1997</I>
</ADDRESS>
</BODY>
</HTML>
|