| 1 |
.\" Written by Oron Peled <[email protected]>. |
| 2 |
.\" |
| 3 |
.\" SPDX-License-Identifier: GPL-1.0-or-later |
| 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) |
| 8 |
.\" - kernel and init(1) is applicable to almost any UNIX/Linux |
| 9 |
.\" - boot scripts are applicable to SYSV-R4 based UNIX/Linux |
| 10 |
.\" |
| 11 |
.\" Modified 2004-11-03 patch from Martin Schulze <[email protected]> |
| 12 |
.\" |
| 13 |
.TH boot 7 2024-05-02 "Linux man-pages 6.9.1" |
| 14 |
.SH NAME |
| 15 |
boot \- System bootup process based on UNIX System V Release 4 |
| 16 |
.SH DESCRIPTION |
| 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) 5 |
| 21 |
hardware |
| 22 |
.IP (2) |
| 23 |
operating system (OS) loader |
| 24 |
.IP (3) |
| 25 |
kernel |
| 26 |
.IP (4) |
| 27 |
root user-space process (\fIinit\fR and \fIinittab\fR) |
| 28 |
.IP (5) |
| 29 |
boot scripts |
| 30 |
.P |
| 31 |
Each of these is described below in more detail. |
| 32 |
.SS Hardware |
| 33 |
After power-on or hard reset, control is given |
| 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". |
| 37 |
.P |
| 38 |
This program normally performs a basic self-test of the |
| 39 |
machine and accesses nonvolatile memory to read |
| 40 |
further parameters. |
| 41 |
This memory in the PC is |
| 42 |
battery-backed CMOS memory, so most people |
| 43 |
refer to it as "the \fBCMOS\fR"; outside |
| 44 |
of the PC world, it is usually called "the \fBNVRAM\fR" |
| 45 |
(nonvolatile RAM). |
| 46 |
.P |
| 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. |
| 54 |
.TP |
| 55 |
Note: |
| 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 |
| 58 |
DHCP, TFTP, PXE, Etherboot, etc. |
| 59 |
.SS OS loader |
| 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. |
| 67 |
.P |
| 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" |
| 70 |
(Master Boot Record). |
| 71 |
.P |
| 72 |
In most systems, the OS loader is very |
| 73 |
limited due to various constraints. |
| 74 |
Even on non-PC systems, |
| 75 |
there are some limitations on the size and complexity |
| 76 |
of this loader, but the size limitation of the PC MBR |
| 77 |
(512 bytes, including the partition table) makes it |
| 78 |
almost impossible to squeeze much functionality into it. |
| 79 |
.P |
| 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. |
| 84 |
.P |
| 85 |
In Linux, the OS loader is often |
| 86 |
.BR grub (8) |
| 87 |
(an alternative is |
| 88 |
.BR lilo (8)). |
| 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 |
| 93 |
the applicable component. |
| 94 |
The kernel starts the virtual memory |
| 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 / . |
| 98 |
.P |
| 99 |
Some of the parameters that may be passed to the kernel |
| 100 |
relate to these activities (for example, the default root filesystem |
| 101 |
can be overridden); for further information |
| 102 |
on Linux kernel parameters, read |
| 103 |
.BR bootparam (7). |
| 104 |
.P |
| 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 |
| 110 |
program |
| 111 |
.IR /sbin/init , |
| 112 |
to which are passed the parameters that haven't already been |
| 113 |
handled by the kernel. |
| 114 |
.SS Root user-space process |
| 115 |
.TP |
| 116 |
Note: |
| 117 |
The following description applies to an OS based on UNIX System V Release 4. |
| 118 |
However, a number of widely used systems have adopted a related but |
| 119 |
fundamentally different approach known as |
| 120 |
.BR systemd (1), |
| 121 |
for which the bootup process is detailed in its associated |
| 122 |
.BR bootup (7). |
| 123 |
.P |
| 124 |
When |
| 125 |
.I /sbin/init |
| 126 |
starts, it reads |
| 127 |
.I /etc/inittab |
| 128 |
for further instructions. |
| 129 |
This file defines what should be run when the |
| 130 |
.I /sbin/init |
| 131 |
program is instructed to enter a particular run level, 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 |
| 135 |
.B S |
| 136 |
is single-user mode, |
| 137 |
and run level |
| 138 |
.B 2 |
| 139 |
entails running most network services). |
| 140 |
.P |
| 141 |
The administrator may change the current run level via |
| 142 |
.BR init (1), |
| 143 |
and query the current run level via |
| 144 |
.BR runlevel (8). |
| 145 |
.P |
| 146 |
However, since it is not convenient to manage individual services |
| 147 |
by editing this file, |
| 148 |
.I /etc/inittab |
| 149 |
only bootstraps a set of scripts |
| 150 |
that actually start/stop the individual services. |
| 151 |
.SS Boot scripts |
| 152 |
.TP |
| 153 |
Note: |
| 154 |
The following description applies to an OS based on UNIX System V Release 4. |
| 155 |
However, a number of widely used systems (Slackware Linux, FreeBSD, OpenBSD) |
| 156 |
have a somewhat different scheme for boot scripts. |
| 157 |
.P |
| 158 |
For each managed service (mail, nfs server, cron, etc.), there is |
| 159 |
a single startup script located in a specific directory |
| 160 |
.RI ( /etc/init.d |
| 161 |
in most versions of Linux). |
| 162 |
Each of these scripts accepts as a single argument |
| 163 |
the word "start" (causing it to start the service) or the word |
| 164 |
\&"stop" (causing it to stop the service). |
| 165 |
The script may optionally |
| 166 |
accept other "convenience" parameters (e.g., "restart" to stop and then |
| 167 |
start, "status" to display the service status, etc.). |
| 168 |
Running the script |
| 169 |
without parameters displays the possible arguments. |
| 170 |
.SS Sequencing directories |
| 171 |
To make specific scripts start/stop at specific run levels and in a |
| 172 |
specific order, there are \fIsequencing directories\fR, normally |
| 173 |
of the form \fI/etc/rc[0\-6S].d\fR. |
| 174 |
In each of these directories, |
| 175 |
there are links (usually symbolic) to the scripts in the \fI/etc/init.d\fR |
| 176 |
directory. |
| 177 |
.P |
| 178 |
A primary script (usually \fI/etc/rc\fR) is called from |
| 179 |
.BR inittab (5); |
| 180 |
this primary script calls each service's script via a link in the |
| 181 |
relevant sequencing directory. |
| 182 |
Each link whose name begins with \[aq]S\[aq] is called with |
| 183 |
the argument "start" (thereby starting the service). |
| 184 |
Each link whose name begins with \[aq]K\[aq] is called with |
| 185 |
the argument "stop" (thereby stopping the service). |
| 186 |
.P |
| 187 |
To define the starting or stopping order within the same run level, |
| 188 |
the name of a link contains an \fBorder-number\fR. |
| 189 |
Also, for clarity, the name of a link usually |
| 190 |
ends with the name of the service to which it refers. |
| 191 |
For example, |
| 192 |
the link \fI/etc/rc2.d/S80sendmail\fR starts the |
| 193 |
.BR sendmail (8) |
| 194 |
service on |
| 195 |
run level 2. |
| 196 |
This happens after \fI/etc/rc2.d/S12syslog\fR is run |
| 197 |
but before \fI/etc/rc2.d/S90xfs\fR is run. |
| 198 |
.P |
| 199 |
To manage these links is to manage the boot order and run levels; |
| 200 |
under many systems, there are tools to help with this task |
| 201 |
(e.g., |
| 202 |
.BR chkconfig (8)). |
| 203 |
.SS Boot configuration |
| 204 |
A program that provides a service is often called a "\fBdaemon\fR". |
| 205 |
Usually, a daemon may receive various command-line options |
| 206 |
and parameters. |
| 207 |
To allow a system administrator to change these |
| 208 |
inputs without editing an entire boot script, |
| 209 |
some separate configuration file is used, and is located in a specific |
| 210 |
directory where an associated boot script may find it |
| 211 |
(\fI/etc/sysconfig\fR on older Red Hat systems). |
| 212 |
.P |
| 213 |
In older UNIX systems, such a file contained the actual command line |
| 214 |
options for a daemon, but in modern Linux systems (and also |
| 215 |
in HP-UX), it just contains shell variables. |
| 216 |
A boot script in \fI/etc/init.d\fR reads and includes its configuration |
| 217 |
file (that is, it "\fBsources\fR" its configuration file) and then uses |
| 218 |
the variable values. |
| 219 |
.SH FILES |
| 220 |
.IR /etc/init.d/ , |
| 221 |
.IR /etc/rc[S0\-6].d/ , |
| 222 |
.I /etc/sysconfig/ |
| 223 |
.SH SEE ALSO |
| 224 |
.BR init (1), |
| 225 |
.BR systemd (1), |
| 226 |
.BR inittab (5), |
| 227 |
.BR bootparam (7), |
| 228 |
.BR bootup (7), |
| 229 |
.BR runlevel (8), |
| 230 |
.BR shutdown (8) |