1 .\" Written by Oron Peled <oron@actcom.co.il>.
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" May be distributed subject to the GPL.
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(8) is applicable to almost any UNIX/Linux
11 .\" - boot scripts are applicable to SYSV-R4 based UNIX/Linux
13 .\" Modified 2004-11-03 patch from Martin Schulze <joey@infodrom.org>
15 .TH BOOT 7 2010-09-19 "Linux" "Linux Programmer's Manual"
17 boot-scripts \- general description of boot sequence
20 The boot sequence varies in details among systems
21 but can be roughly divided to the following steps:
22 (i) hardware boot, (ii) operating system (OS) loader,
23 (iii) kernel startup, (iv) init and inittab,
25 We will describe each of these in more detail below.
27 After power-on or hard reset, control is given
28 to a program stored on read-only memory (normally
30 In PC we usually call this program the \fBBIOS\fR.
32 This program normally makes a basic self-test of the
33 machine and accesses nonvolatile memory to read
35 This memory in the PC is
36 battery-backed CMOS memory, so most people
37 refer to it as the \fBCMOS\fR, although outside
38 of the PC world, it is usually called \fBnvram\fR
41 The parameters stored in the nvram vary between
42 systems, but as a minimum, the hardware boot program
43 should know what is the boot device, or which devices
44 to probe as possible boot devices.
46 Then the hardware boot stage accesses the boot device,
47 loads the OS loader, which is located on a fixed position
48 on the boot device, and transfers control to it.
51 We do not cover here booting from network.
53 to investigate this subject may want to research:
54 DHCP, TFTP, PXE, Etherboot.
56 In PC, the OS loader is located in the first sector
57 of the boot device \- this is the \fBMBR\fR
60 In most systems, this primary loader is very
61 limited due to various constraints.
62 Even on non-PC systems
63 there are some limitations to the size and complexity
64 of this loader, but the size limitation of the PC MBR
65 (512 bytes including the partition table) makes it
66 almost impossible to squeeze a full OS loader into it.
68 Therefore, most operating systems make the primary loader
69 call a secondary OS loader which may be located on
70 a specified disk partition.
72 In Linux the OS loader is normally
76 Both of them may install either as secondary loaders
77 (where the DOS installed MBR points to them), or
78 as a two part loader where they provide special MBR
79 containing the bootstrap code to load the second part
80 of the loader from the root partition.
82 The main job of the OS loader is to locate the kernel
83 on the disk, load it and run it.
85 interactive use, to enable specification of alternative
86 kernel (maybe a backup in case the last compiled one
87 isn't functioning) and to pass optional parameters
90 When the kernel is loaded, it initializes the devices (via
91 their drivers), starts the swapper (it is a "kernel process",
92 called kswapd in modern Linux kernels), and mounts the root
95 Some of the parameters that may be passed to the kernel
96 relate to these activities (e.g: You can override the
97 default root filesystem).
98 For further information
99 on Linux kernel parameters read
102 Only then the kernel creates the first (user land)
103 process which is numbered 1.
104 This process executes the
107 passing any parameters that weren't handled by the kernel already.
109 When init starts it reads
111 for further instructions.
112 This file defines what should be run in different \fIrun-levels\fR.
114 This gives the system administrator an easy management scheme, where
115 each run-level is associated with a set of services (e.g,
116 \fBS\fR is \fIsingle-user\fR, on \fB2\fR most network
118 The administrator may change the current
121 and query the current run-level via
124 However, since it is not convenient to manage individual services
125 by editing this file, inittab only bootstraps a set of scripts
126 that actually start/stop the individual services.
130 The following description applies to System V release 4-based systems, which
131 currently covers most commercial UNIX systems (Solaris, HP-UX, Irix, Tru64)
132 as well as the major Linux distributions (Red Hat, Debian, Mandriva,
134 Some systems (Slackware Linux, FreeBSD, OpenBSD)
135 have a somewhat different scheme of boot scripts.
137 For each managed service (mail, nfs server, cron, etc.) there is
138 a single startup script located in a specific directory
140 in most versions of Linux).
141 Each of these scripts accepts as a single argument
142 the word "start" \-\- causing it to start the service, or the word
143 \&"stop" \-\- causing it to stop the service.
144 The script may optionally
145 accept other "convenience" parameters (e.g: "restart", to stop and then
146 start, "status" to display the service status).
148 without parameters displays the possible arguments.
149 .SS Sequencing directories
150 To make specific scripts start/stop at specific run-levels and in
151 specific order, there are \fIsequencing directories\fR.
153 are normally in \fI/etc/rc[0\-6S].d\fR.
154 In each of these directories
155 there are links (usually symbolic) to the scripts in the \fI/etc/init.d\fR
158 A primary script (usually \fI/etc/rc\fR) is called from
160 and calls the services scripts via the links in the sequencing directories.
161 All links with names that begin with \(aqS\(aq are being called with
162 the argument "start" (thereby starting the service).
164 names that begin with \(aqK\(aq are being called with the argument "stop"
165 (thereby stopping the service).
167 To define the starting or stopping order within the same run-level,
168 the names of the links contain order-numbers.
169 Also, to make the names clearer, they usually
170 end with the name of the service they refer to.
172 the link \fI/etc/rc2.d/S80sendmail\fR starts the sendmail service on
174 This happens after \fI/etc/rc2.d/S12syslog\fR is run
175 but before \fI/etc/rc2.d/S90xfs\fR is run.
177 To manage the boot order and run-levels, we have to manage these links.
178 However, on many versions of Linux, there are tools to help with this task
181 .SS Boot configuration
182 Usually the daemons started may optionally receive command-line options
184 To allow system administrators to change these
185 parameters without editing the boot scripts themselves,
186 configuration files are used.
187 These are located in a specific
188 directory (\fI/etc/sysconfig\fR on Red Hat systems) and are
189 used by the boot scripts.
191 In older UNIX systems, these files contained the actual command line
192 options for the daemons, but in modern Linux systems (and also
193 in HP-UX), these files just contain shell variables.
194 The boot scripts in \fI/etc/init.d\fR
195 \fBsource\fR the configuration
196 files, and then use the variable values.
200 .IR /etc/rc[S0\-6].d/ ,