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