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