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