OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man7 / boot.7
1 .\" Written by Oron Peled <oron@actcom.co.il>.
2 .\"
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" May be distributed subject to the GPL.
5 .\" %%%LICENSE_END
6 .\"
7 .\" I tried to be as much generic in the description as possible:
8 .\" - General boot sequence is applicable to almost any
9 .\" OS/Machine (DOS/PC, Linux/PC, Solaris/SPARC, CMS/S390)
10 .\" - kernel and init(8) is applicable to almost any UNIX/Linux
11 .\" - boot scripts are applicable to SYSV-R4 based UNIX/Linux
12 .\"
13 .\" Modified 2004-11-03 patch from Martin Schulze <joey@infodrom.org>
14 .\"
15 .TH BOOT 7 2010-09-19 "Linux" "Linux Programmer's Manual"
16 .SH NAME
17 boot-scripts \- general description of boot sequence
18 .SH DESCRIPTION
19 .LP
20 The boot sequence varies in details among systems
21 but can be roughly divided to the following steps:
22 (i) hardware boot, (ii) operating system (OS) loader,
23 (iii) kernel startup, (iv) init and inittab,
24 (v) boot scripts.
25 We will describe each of these in more detail below.
26 .SS Hardware-boot
27 After power-on or hard reset, control is given
28 to a program stored on read-only memory (normally
29 PROM).
30 In PC we usually call this program the \fBBIOS\fR.
31
32 This program normally makes a basic self-test of the
33 machine and accesses nonvolatile memory to read
34 further parameters.
35 This memory in the PC is
36 battery-backed CMOS memory, so most people
37 refer to it as the \fBCMOS\fR, although outside
38 of the PC world, it is usually called \fBnvram\fR
39 (nonvolatile ram).
40
41 The parameters stored in the nvram vary between
42 systems, but as a minimum, the hardware boot program
43 should know what is the boot device, or which devices
44 to probe as possible boot devices.
45
46 Then the hardware boot stage accesses the boot device,
47 loads the OS loader, which is located on a fixed position
48 on the boot device, and transfers control to it.
49 .TP
50 Note:
51 We do not cover here booting from network.
52 Those who want
53 to investigate this subject may want to research:
54 DHCP, TFTP, PXE, Etherboot.
55 .SS OS loader
56 In PC, the OS loader is located in the first sector
57 of the boot device \- this is the \fBMBR\fR
58 (Master Boot Record).
59
60 In most systems, this primary loader is very
61 limited due to various constraints.
62 Even on non-PC systems
63 there are some limitations to the size and complexity
64 of this loader, but the size limitation of the PC MBR
65 (512 bytes including the partition table) makes it
66 almost impossible to squeeze a full OS loader into it.
67
68 Therefore, most operating systems make the primary loader
69 call a secondary OS loader which may be located on
70 a specified disk partition.
71
72 In Linux the OS loader is normally
73 .BR lilo (8)
74 or
75 .BR grub (8).
76 Both of them may install either as secondary loaders
77 (where the DOS installed MBR points to them), or
78 as a two part loader where they provide special MBR
79 containing the bootstrap code to load the second part
80 of the loader from the root partition.
81
82 The main job of the OS loader is to locate the kernel
83 on the disk, load it and run it.
84 Most OS loaders allow
85 interactive use, to enable specification of alternative
86 kernel (maybe a backup in case the last compiled one
87 isn't functioning) and to pass optional parameters
88 to the kernel.
89 .SS Kernel startup
90 When the kernel is loaded, it initializes the devices (via
91 their drivers), starts the swapper (it is a "kernel process",
92 called kswapd in modern Linux kernels), and mounts the root
93 filesystem (/).
94
95 Some of the parameters that may be passed to the kernel
96 relate to these activities (e.g: You can override the
97 default root filesystem).
98 For further information
99 on Linux kernel parameters read
100 .BR bootparam (7).
101
102 Only then the kernel creates the first (user land)
103 process which is numbered 1.
104 This process executes the
105 program
106 .IR /sbin/init ,
107 passing any parameters that weren't handled by the kernel already.
108 .SS init and inittab
109 When init starts it reads
110 .I /etc/inittab
111 for further instructions.
112 This file defines what should be run in different \fIrun-levels\fR.
113
114 This gives the system administrator an easy management scheme, where
115 each run-level is associated with a set of services (e.g,
116 \fBS\fR is \fIsingle-user\fR, on \fB2\fR most network
117 services start).
118 The administrator may change the current
119 run-level via
120 .BR init (8)
121 and query the current run-level via
122 .BR runlevel (8).
123
124 However, since it is not convenient to manage individual services
125 by editing this file, inittab only bootstraps a set of scripts
126 that actually start/stop the individual services.
127 .SS Boot scripts
128 .TP
129 Note:
130 The following description applies to System V release 4-based systems, which
131 currently covers most commercial UNIX systems (Solaris, HP-UX, Irix, Tru64)
132 as well as the major Linux distributions (Red Hat, Debian, Mandriva,
133 SUSE, Ubuntu).
134 Some systems (Slackware Linux, FreeBSD, OpenBSD)
135 have a somewhat different scheme of boot scripts.
136 .LP
137 For each managed service (mail, nfs server, cron, etc.) there is
138 a single startup script located in a specific directory
139 .RI ( /etc/init.d
140 in most versions of Linux).
141 Each of these scripts accepts as a single argument
142 the word "start" \-\- causing it to start the service, or the word
143 \&"stop" \-\- causing it to stop the service.
144 The script may optionally
145 accept other "convenience" parameters (e.g: "restart", to stop and then
146 start, "status" to display the service status).
147 Running the script
148 without parameters displays the possible arguments.
149 .SS Sequencing directories
150 To make specific scripts start/stop at specific run-levels and in
151 specific order, there are \fIsequencing directories\fR.
152 These
153 are normally in \fI/etc/rc[0\-6S].d\fR.
154 In each of these directories
155 there are links (usually symbolic) to the scripts in the \fI/etc/init.d\fR
156 directory.
157
158 A primary script (usually \fI/etc/rc\fR) is called from
159 .BR inittab (5)
160 and calls the services scripts via the links in the sequencing directories.
161 All links with names that begin with \(aqS\(aq are being called with
162 the argument "start" (thereby starting the service).
163 All links with
164 names that begin with \(aqK\(aq are being called with the argument "stop"
165 (thereby stopping the service).
166
167 To define the starting or stopping order within the same run-level,
168 the names of the links contain order-numbers.
169 Also, to make the names clearer, they usually
170 end with the name of the service they refer to.
171 Example:
172 the link \fI/etc/rc2.d/S80sendmail\fR starts the sendmail service on
173 runlevel 2.
174 This happens after \fI/etc/rc2.d/S12syslog\fR is run
175 but before \fI/etc/rc2.d/S90xfs\fR is run.
176
177 To manage the boot order and run-levels, we have to manage these links.
178 However, on many versions of Linux, there are tools to help with this task
179 (e.g:
180 .BR chkconfig (8)).
181 .SS Boot configuration
182 Usually the daemons started may optionally receive command-line options
183 and parameters.
184 To allow system administrators to change these
185 parameters without editing the boot scripts themselves,
186 configuration files are used.
187 These are located in a specific
188 directory (\fI/etc/sysconfig\fR on Red Hat systems) and are
189 used by the boot scripts.
190
191 In older UNIX systems, these files contained the actual command line
192 options for the daemons, but in modern Linux systems (and also
193 in HP-UX), these files just contain shell variables.
194 The boot scripts in \fI/etc/init.d\fR
195 \fBsource\fR the configuration
196 files, and then use the variable values.
197 .SH FILES
198 .LP
199 .IR /etc/init.d/ ,
200 .IR /etc/rc[S0\-6].d/ ,
201 .I /etc/sysconfig/
202 .SH SEE ALSO
203 .BR inittab (5),
204 .BR bootparam (7),
205 .BR init (8),
206 .BR runlevel (8),
207 .BR shutdown (8)
208 .SH COLOPHON
209 This page is part of release 3.68 of the Linux
210 .I man-pages
211 project.
212 A description of the project,
213 information about reporting bugs,
214 and the latest version of this page,
215 can be found at
216 \%http://www.kernel.org/doc/man\-pages/.