]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Written by Oron Peled <oron@actcom.co.il>. |
2297bf0e | 2 | .\" |
b55e2bb3 | 3 | .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE) |
fea681da | 4 | .\" May be distributed subject to the GPL. |
b55e2bb3 | 5 | .\" %%%LICENSE_END |
fea681da MK |
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) | |
e8906093 | 10 | .\" - kernel and init(1) is applicable to almost any UNIX/Linux |
008f1ecc | 11 | .\" - boot scripts are applicable to SYSV-R4 based UNIX/Linux |
6891999e | 12 | .\" |
e17d909d | 13 | .\" Modified 2004-11-03 patch from Martin Schulze <joey@infodrom.org> |
6891999e | 14 | .\" |
a879ea43 | 15 | .TH BOOT 7 2015-03-11 "Linux" "Linux Programmer's Manual" |
d4438ce6 | 16 | .SH NAME |
a879ea43 | 17 | boot \- System bootup process based on UNIX System V Release 4 |
d4438ce6 | 18 | .SH DESCRIPTION |
c13182ef | 19 | .LP |
a879ea43 MW |
20 | The \fBbootup process\fR (or "\fBboot sequence\fR") varies in details |
21 | among systems, but can be roughly divided into phases controlled by | |
22 | the following components: | |
23 | .IP 1. 4 | |
24 | hardware | |
25 | .IP 2. 4 | |
26 | operating system (OS) loader | |
27 | .IP 3. 4 | |
28 | kernel | |
29 | .IP 4. 4 | |
30 | root user-space process (\fIinit\fR and \fIinittab\fR) | |
31 | .IP 5. 4 | |
32 | boot scripts | |
33 | .PP | |
34 | Each of these is described below in more detail. | |
35 | .SS Hardware | |
c382a365 | 36 | After power-on or hard reset, control is given |
a879ea43 MW |
37 | to a program stored in read-only memory (normally |
38 | PROM); for historical reasons involving the personal | |
39 | computer, this program is often called "the \fBBIOS\fR". | |
fea681da | 40 | |
a879ea43 | 41 | This program normally performs a basic self-test of the |
24b74457 | 42 | machine and accesses nonvolatile memory to read |
c13182ef MK |
43 | further parameters. |
44 | This memory in the PC is | |
c382a365 | 45 | battery-backed CMOS memory, so most people |
a879ea43 MW |
46 | refer to it as "the \fBCMOS\fR"; outside |
47 | of the PC world, it is usually called "the \fBNVRAM\fR" | |
48 | (nonvolatile RAM). | |
fea681da | 49 | |
a879ea43 MW |
50 | The parameters stored in the NVRAM vary among |
51 | systems, but as a minimum, they should specify | |
52 | which device can supply an OS loader, or at least which | |
53 | devices may be probed for one; such a device is known as "the | |
54 | \fBboot device\fR". | |
55 | The hardware boot stage loads the OS loader from a fixed position on | |
56 | the boot device, and then transfers control to it. | |
c13182ef | 57 | .TP |
fea681da | 58 | Note: |
a879ea43 MW |
59 | The device from which the OS loader is read may be attached via a network, in which |
60 | case the details of booting are further specified by protocols such as | |
61 | DHCP, TFTP, PXE, Etherboot, etc. | |
73d8cece | 62 | .SS OS loader |
a879ea43 MW |
63 | The main job of the OS loader is to locate the kernel |
64 | on some device, load it, and run it. | |
65 | Most OS loaders allow | |
66 | interactive use, in order to enable specification of an alternative | |
67 | kernel (maybe a backup in case the one last compiled | |
68 | isn't functioning) and to pass optional parameters | |
69 | to the kernel. | |
70 | ||
71 | In a traditional PC, the OS loader is located in the initial 512-byte block | |
72 | of the boot device; this block is known as "the \fBMBR\fR" | |
fea681da MK |
73 | (Master Boot Record). |
74 | ||
a879ea43 | 75 | In most systems, the OS loader is very |
c13182ef | 76 | limited due to various constraints. |
a879ea43 MW |
77 | Even on non-PC systems, |
78 | there are some limitations on the size and complexity | |
fea681da | 79 | of this loader, but the size limitation of the PC MBR |
a879ea43 MW |
80 | (512 bytes, including the partition table) makes it |
81 | almost impossible to squeeze much functionality into it. | |
fea681da | 82 | |
a879ea43 MW |
83 | Therefore, most systems split the role of loading the OS between |
84 | a primary OS loader and a secondary OS loader; this secondary | |
85 | OS loader may be located within a larger portion of persistent | |
86 | storage, such as a disk partition. | |
fea681da | 87 | |
a879ea43 | 88 | In Linux, the OS loader is often either |
fea681da MK |
89 | .BR lilo (8) |
90 | or | |
91 | .BR grub (8). | |
a879ea43 MW |
92 | .SS Kernel |
93 | When the kernel is loaded, it initializes various components of | |
94 | the computer and operating system; each portion of software | |
95 | responsible for such a task is usually consider "a \fBdriver\fR" for | |
96 | the applicable component. The kernel starts the virtual memory | |
97 | swapper (it is a kernel process, called "kswapd" in a modern Linux | |
98 | kernel), and mounts some filesystem at the root path, | |
99 | .IR / . | |
fea681da MK |
100 | |
101 | Some of the parameters that may be passed to the kernel | |
a879ea43 MW |
102 | relate to these activities (for example, the default root filesystem |
103 | can be overriden); for further information | |
104 | on Linux kernel parameters, read | |
fea681da MK |
105 | .BR bootparam (7). |
106 | ||
a879ea43 MW |
107 | Only then does the kernel create the initial userland |
108 | process, which is given the number 1 as its | |
109 | .B PID | |
110 | (process ID). | |
111 | Traditionally, this process executes the | |
fea681da MK |
112 | program |
113 | .IR /sbin/init , | |
a879ea43 MW |
114 | to which are passed the parameters that haven't already been |
115 | handled by the kernel. | |
116 | .SS Root user-space process | |
117 | When | |
118 | .I /sbin/init | |
119 | starts, it reads | |
fea681da MK |
120 | .I /etc/inittab |
121 | for further instructions. | |
a879ea43 MW |
122 | This file defines what should be run when the |
123 | .I /sbin/init | |
124 | program is instructed to enter a particular \fIrun-level\fR, giving | |
125 | the administrator an easy way to establish an environment | |
126 | for some usage; each run-level is associated with a set of services | |
127 | (for example, run-level \fBS\fR is \fIsingle-user\fR mode, | |
128 | and run-level \fB2\fR entails running most network services). | |
fea681da | 129 | |
c13182ef | 130 | The administrator may change the current |
fea681da | 131 | run-level via |
a879ea43 | 132 | .BR init (1), |
fea681da MK |
133 | and query the current run-level via |
134 | .BR runlevel (8). | |
135 | ||
136 | However, since it is not convenient to manage individual services | |
a879ea43 MW |
137 | by editing this file, |
138 | .I /etc/inittab | |
139 | only bootstraps a set of scripts | |
fea681da | 140 | that actually start/stop the individual services. |
73d8cece | 141 | .SS Boot scripts |
c13182ef | 142 | .TP |
fea681da | 143 | Note: |
a879ea43 MW |
144 | The following description applies to an OS based on UNIX System V Release 4, |
145 | which currently covers most commercial UNIX systems (Solaris, HP-UX, Irix, | |
146 | Tru64) as well as the major Linux distributions (Red Hat, Debian, Mandriva, | |
d2b885c5 | 147 | SUSE, Ubuntu). |
c13182ef | 148 | Some systems (Slackware Linux, FreeBSD, OpenBSD) |
a879ea43 | 149 | have a somewhat different scheme for boot scripts. |
fea681da | 150 | .LP |
a879ea43 | 151 | For each managed service (mail, nfs server, cron, etc.), there is |
fea681da MK |
152 | a single startup script located in a specific directory |
153 | .RI ( /etc/init.d | |
154 | in most versions of Linux). | |
155 | Each of these scripts accepts as a single argument | |
a879ea43 MW |
156 | the word "start" (causing it to start the service) or the word |
157 | \&"stop" (causing it to stop the service). | |
c13182ef | 158 | The script may optionally |
a879ea43 MW |
159 | accept other "convenience" parameters (e.g,. "restart" to stop and then |
160 | start, "status" to display the service status, etc.). | |
c13182ef | 161 | Running the script |
fea681da | 162 | without parameters displays the possible arguments. |
73d8cece | 163 | .SS Sequencing directories |
a879ea43 MW |
164 | To make specific scripts start/stop at specific run-levels and in a |
165 | specific order, there are \fIsequencing directories\fR, normally | |
166 | of the form \fI/etc/rc[0\-6S].d\fR. | |
167 | In each of these directories, | |
db55c5c5 | 168 | there are links (usually symbolic) to the scripts in the \fI/etc/init.d\fR |
fea681da MK |
169 | directory. |
170 | ||
c13182ef | 171 | A primary script (usually \fI/etc/rc\fR) is called from |
a879ea43 MW |
172 | .BR inittab (5); |
173 | this primary script calls each service's script via a link in the | |
174 | relevant sequencing directory. | |
175 | Each link whose name begins with \(aqS\(aq is called with | |
84c517a4 | 176 | the argument "start" (thereby starting the service). |
a879ea43 MW |
177 | Each link whose name begins with \(aqK\(aq is called with |
178 | the argument "stop" (thereby stopping the service). | |
fea681da MK |
179 | |
180 | To define the starting or stopping order within the same run-level, | |
a879ea43 MW |
181 | the name of a link contains an \fBorder-number\fR. |
182 | Also, for clarity, the name of a link usually | |
183 | ends with the name of the service to which it refers. | |
184 | For example, | |
fea681da | 185 | the link \fI/etc/rc2.d/S80sendmail\fR starts the sendmail service on |
c13182ef MK |
186 | runlevel 2. |
187 | This happens after \fI/etc/rc2.d/S12syslog\fR is run | |
fea681da MK |
188 | but before \fI/etc/rc2.d/S90xfs\fR is run. |
189 | ||
a879ea43 MW |
190 | To manage these links is to manage the boot order and run-levels; |
191 | under many systems, there are tools to help with this task | |
192 | (e.g., | |
fea681da | 193 | .BR chkconfig (8)). |
73d8cece | 194 | .SS Boot configuration |
a879ea43 MW |
195 | A program that provides a service is often called a "\fBdaemon\fR". |
196 | Usually, a daemon may receive various command-line options | |
c13182ef | 197 | and parameters. |
a879ea43 MW |
198 | To allow a system administrator to change these |
199 | inputs without editing an entire boot script, | |
200 | some separate configuration file is used, and is located in a specific | |
201 | directory where an associated boot script may find it | |
202 | (\fI/etc/sysconfig\fR on Red Hat systems). | |
fea681da | 203 | |
a879ea43 MW |
204 | In older UNIX systems, such a file contained the actual command line |
205 | options for a daemon, but in modern Linux systems (and also | |
206 | in HP-UX), it just contains shell variables. | |
207 | A boot script in \fI/etc/init.d\fR reads and includes its configuration | |
208 | file (that is, it "\fBsources\fR" its configuration file) and then uses | |
209 | the variable values. | |
d4438ce6 | 210 | .SH FILES |
c13182ef | 211 | .LP |
fea681da | 212 | .IR /etc/init.d/ , |
7174626f | 213 | .IR /etc/rc[S0\-6].d/ , |
fea681da | 214 | .I /etc/sysconfig/ |
d4438ce6 | 215 | .SH SEE ALSO |
fea681da MK |
216 | .BR inittab (5), |
217 | .BR bootparam (7), | |
e8906093 | 218 | .BR init (1), |
fea681da MK |
219 | .BR runlevel (8), |
220 | .BR shutdown (8) |