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