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