|
Packit |
7cfc04 |
.\" Written by Oron Peled <oron@actcom.co.il>.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
|
|
Packit |
7cfc04 |
.\" May be distributed subject to the GPL.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" I tried to be as much generic in the description as possible:
|
|
Packit |
7cfc04 |
.\" - General boot sequence is applicable to almost any
|
|
Packit |
7cfc04 |
.\" OS/Machine (DOS/PC, Linux/PC, Solaris/SPARC, CMS/S390)
|
|
Packit |
7cfc04 |
.\" - kernel and init(1) is applicable to almost any UNIX/Linux
|
|
Packit |
7cfc04 |
.\" - boot scripts are applicable to SYSV-R4 based UNIX/Linux
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Modified 2004-11-03 patch from Martin Schulze <joey@infodrom.org>
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH BOOT 7 2015-03-11 "Linux" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
boot \- System bootup process based on UNIX System V Release 4
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The \fBbootup process\fR (or "\fBboot sequence\fR") varies in details
|
|
Packit |
7cfc04 |
among systems, but can be roughly divided into phases controlled by
|
|
Packit |
7cfc04 |
the following components:
|
|
Packit |
7cfc04 |
.IP 1. 4
|
|
Packit |
7cfc04 |
hardware
|
|
Packit |
7cfc04 |
.IP 2. 4
|
|
Packit |
7cfc04 |
operating system (OS) loader
|
|
Packit |
7cfc04 |
.IP 3. 4
|
|
Packit |
7cfc04 |
kernel
|
|
Packit |
7cfc04 |
.IP 4. 4
|
|
Packit |
7cfc04 |
root user-space process (\fIinit\fR and \fIinittab\fR)
|
|
Packit |
7cfc04 |
.IP 5. 4
|
|
Packit |
7cfc04 |
boot scripts
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Each of these is described below in more detail.
|
|
Packit |
7cfc04 |
.SS Hardware
|
|
Packit |
7cfc04 |
After power-on or hard reset, control is given
|
|
Packit |
7cfc04 |
to a program stored in read-only memory (normally
|
|
Packit |
7cfc04 |
PROM); for historical reasons involving the personal
|
|
Packit |
7cfc04 |
computer, this program is often called "the \fBBIOS\fR".
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
This program normally performs a basic self-test of the
|
|
Packit |
7cfc04 |
machine and accesses nonvolatile memory to read
|
|
Packit |
7cfc04 |
further parameters.
|
|
Packit |
7cfc04 |
This memory in the PC is
|
|
Packit |
7cfc04 |
battery-backed CMOS memory, so most people
|
|
Packit |
7cfc04 |
refer to it as "the \fBCMOS\fR"; outside
|
|
Packit |
7cfc04 |
of the PC world, it is usually called "the \fBNVRAM\fR"
|
|
Packit |
7cfc04 |
(nonvolatile RAM).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The parameters stored in the NVRAM vary among
|
|
Packit |
7cfc04 |
systems, but as a minimum, they should specify
|
|
Packit |
7cfc04 |
which device can supply an OS loader, or at least which
|
|
Packit |
7cfc04 |
devices may be probed for one; such a device is known as "the
|
|
Packit |
7cfc04 |
\fBboot device\fR".
|
|
Packit |
7cfc04 |
The hardware boot stage loads the OS loader from a fixed position on
|
|
Packit |
7cfc04 |
the boot device, and then transfers control to it.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Note:
|
|
Packit |
7cfc04 |
The device from which the OS loader is read may be attached via a network, in which
|
|
Packit |
7cfc04 |
case the details of booting are further specified by protocols such as
|
|
Packit |
7cfc04 |
DHCP, TFTP, PXE, Etherboot, etc.
|
|
Packit |
7cfc04 |
.SS OS loader
|
|
Packit |
7cfc04 |
The main job of the OS loader is to locate the kernel
|
|
Packit |
7cfc04 |
on some device, load it, and run it.
|
|
Packit |
7cfc04 |
Most OS loaders allow
|
|
Packit |
7cfc04 |
interactive use, in order to enable specification of an alternative
|
|
Packit |
7cfc04 |
kernel (maybe a backup in case the one last compiled
|
|
Packit |
7cfc04 |
isn't functioning) and to pass optional parameters
|
|
Packit |
7cfc04 |
to the kernel.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
In a traditional PC, the OS loader is located in the initial 512-byte block
|
|
Packit |
7cfc04 |
of the boot device; this block is known as "the \fBMBR\fR"
|
|
Packit |
7cfc04 |
(Master Boot Record).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
In most systems, the OS loader is very
|
|
Packit |
7cfc04 |
limited due to various constraints.
|
|
Packit |
7cfc04 |
Even on non-PC systems,
|
|
Packit |
7cfc04 |
there are some limitations on the size and complexity
|
|
Packit |
7cfc04 |
of this loader, but the size limitation of the PC MBR
|
|
Packit |
7cfc04 |
(512 bytes, including the partition table) makes it
|
|
Packit |
7cfc04 |
almost impossible to squeeze much functionality into it.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Therefore, most systems split the role of loading the OS between
|
|
Packit |
7cfc04 |
a primary OS loader and a secondary OS loader; this secondary
|
|
Packit |
7cfc04 |
OS loader may be located within a larger portion of persistent
|
|
Packit |
7cfc04 |
storage, such as a disk partition.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
In Linux, the OS loader is often either
|
|
Packit |
7cfc04 |
.BR lilo (8)
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR grub (8).
|
|
Packit |
7cfc04 |
.SS Kernel
|
|
Packit |
7cfc04 |
When the kernel is loaded, it initializes various components of
|
|
Packit |
7cfc04 |
the computer and operating system; each portion of software
|
|
Packit |
7cfc04 |
responsible for such a task is usually consider "a \fBdriver\fR" for
|
|
Packit |
7cfc04 |
the applicable component.
|
|
Packit |
7cfc04 |
The kernel starts the virtual memory
|
|
Packit |
7cfc04 |
swapper (it is a kernel process, called "kswapd" in a modern Linux
|
|
Packit |
7cfc04 |
kernel), and mounts some filesystem at the root path,
|
|
Packit |
7cfc04 |
.IR / .
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Some of the parameters that may be passed to the kernel
|
|
Packit |
7cfc04 |
relate to these activities (for example, the default root filesystem
|
|
Packit |
7cfc04 |
can be overridden); for further information
|
|
Packit |
7cfc04 |
on Linux kernel parameters, read
|
|
Packit |
7cfc04 |
.BR bootparam (7).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Only then does the kernel create the initial userland
|
|
Packit |
7cfc04 |
process, which is given the number 1 as its
|
|
Packit |
7cfc04 |
.B PID
|
|
Packit |
7cfc04 |
(process ID).
|
|
Packit |
7cfc04 |
Traditionally, this process executes the
|
|
Packit |
7cfc04 |
program
|
|
Packit |
7cfc04 |
.IR /sbin/init ,
|
|
Packit |
7cfc04 |
to which are passed the parameters that haven't already been
|
|
Packit |
7cfc04 |
handled by the kernel.
|
|
Packit |
7cfc04 |
.SS Root user-space process
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Note:
|
|
Packit |
7cfc04 |
The following description applies to an OS based on UNIX System V Release 4.
|
|
Packit |
7cfc04 |
However, a number of widely used systems have adopted a related but
|
|
Packit |
7cfc04 |
fundamentally different approach known as
|
|
Packit |
7cfc04 |
.BR systemd (1),
|
|
Packit |
7cfc04 |
for which the bootup process is detailed in its associated
|
|
Packit |
7cfc04 |
.BR bootup (7).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
When
|
|
Packit |
7cfc04 |
.I /sbin/init
|
|
Packit |
7cfc04 |
starts, it reads
|
|
Packit |
7cfc04 |
.I /etc/inittab
|
|
Packit |
7cfc04 |
for further instructions.
|
|
Packit |
7cfc04 |
This file defines what should be run when the
|
|
Packit |
7cfc04 |
.I /sbin/init
|
|
Packit |
7cfc04 |
program is instructed to enter a particular \fIrun-level\fR, giving
|
|
Packit |
7cfc04 |
the administrator an easy way to establish an environment
|
|
Packit |
7cfc04 |
for some usage; each run-level is associated with a set of services
|
|
Packit |
7cfc04 |
(for example, run-level \fBS\fR is \fIsingle-user\fR mode,
|
|
Packit |
7cfc04 |
and run-level \fB2\fR entails running most network services).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The administrator may change the current
|
|
Packit |
7cfc04 |
run-level via
|
|
Packit |
7cfc04 |
.BR init (1),
|
|
Packit |
7cfc04 |
and query the current run-level via
|
|
Packit |
7cfc04 |
.BR runlevel (8).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
However, since it is not convenient to manage individual services
|
|
Packit |
7cfc04 |
by editing this file,
|
|
Packit |
7cfc04 |
.I /etc/inittab
|
|
Packit |
7cfc04 |
only bootstraps a set of scripts
|
|
Packit |
7cfc04 |
that actually start/stop the individual services.
|
|
Packit |
7cfc04 |
.SS Boot scripts
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Note:
|
|
Packit |
7cfc04 |
The following description applies to an OS based on UNIX System V Release 4.
|
|
Packit |
7cfc04 |
However, a number of widely used systems (Slackware Linux, FreeBSD, OpenBSD)
|
|
Packit |
7cfc04 |
have a somewhat different scheme for boot scripts.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
For each managed service (mail, nfs server, cron, etc.), there is
|
|
Packit |
7cfc04 |
a single startup script located in a specific directory
|
|
Packit |
7cfc04 |
.RI ( /etc/init.d
|
|
Packit |
7cfc04 |
in most versions of Linux).
|
|
Packit |
7cfc04 |
Each of these scripts accepts as a single argument
|
|
Packit |
7cfc04 |
the word "start" (causing it to start the service) or the word
|
|
Packit |
7cfc04 |
\&"stop" (causing it to stop the service).
|
|
Packit |
7cfc04 |
The script may optionally
|
|
Packit |
7cfc04 |
accept other "convenience" parameters (e.g., "restart" to stop and then
|
|
Packit |
7cfc04 |
start, "status" to display the service status, etc.).
|
|
Packit |
7cfc04 |
Running the script
|
|
Packit |
7cfc04 |
without parameters displays the possible arguments.
|
|
Packit |
7cfc04 |
.SS Sequencing directories
|
|
Packit |
7cfc04 |
To make specific scripts start/stop at specific run-levels and in a
|
|
Packit |
7cfc04 |
specific order, there are \fIsequencing directories\fR, normally
|
|
Packit |
7cfc04 |
of the form \fI/etc/rc[0\-6S].d\fR.
|
|
Packit |
7cfc04 |
In each of these directories,
|
|
Packit |
7cfc04 |
there are links (usually symbolic) to the scripts in the \fI/etc/init.d\fR
|
|
Packit |
7cfc04 |
directory.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
A primary script (usually \fI/etc/rc\fR) is called from
|
|
Packit |
7cfc04 |
.BR inittab (5);
|
|
Packit |
7cfc04 |
this primary script calls each service's script via a link in the
|
|
Packit |
7cfc04 |
relevant sequencing directory.
|
|
Packit |
7cfc04 |
Each link whose name begins with \(aqS\(aq is called with
|
|
Packit |
7cfc04 |
the argument "start" (thereby starting the service).
|
|
Packit |
7cfc04 |
Each link whose name begins with \(aqK\(aq is called with
|
|
Packit |
7cfc04 |
the argument "stop" (thereby stopping the service).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
To define the starting or stopping order within the same run-level,
|
|
Packit |
7cfc04 |
the name of a link contains an \fBorder-number\fR.
|
|
Packit |
7cfc04 |
Also, for clarity, the name of a link usually
|
|
Packit |
7cfc04 |
ends with the name of the service to which it refers.
|
|
Packit |
7cfc04 |
For example,
|
|
Packit |
7cfc04 |
the link \fI/etc/rc2.d/S80sendmail\fR starts the sendmail service on
|
|
Packit |
7cfc04 |
runlevel 2.
|
|
Packit |
7cfc04 |
This happens after \fI/etc/rc2.d/S12syslog\fR is run
|
|
Packit |
7cfc04 |
but before \fI/etc/rc2.d/S90xfs\fR is run.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
To manage these links is to manage the boot order and run-levels;
|
|
Packit |
7cfc04 |
under many systems, there are tools to help with this task
|
|
Packit |
7cfc04 |
(e.g.,
|
|
Packit |
7cfc04 |
.BR chkconfig (8)).
|
|
Packit |
7cfc04 |
.SS Boot configuration
|
|
Packit |
7cfc04 |
A program that provides a service is often called a "\fBdaemon\fR".
|
|
Packit |
7cfc04 |
Usually, a daemon may receive various command-line options
|
|
Packit |
7cfc04 |
and parameters.
|
|
Packit |
7cfc04 |
To allow a system administrator to change these
|
|
Packit |
7cfc04 |
inputs without editing an entire boot script,
|
|
Packit |
7cfc04 |
some separate configuration file is used, and is located in a specific
|
|
Packit |
7cfc04 |
directory where an associated boot script may find it
|
|
Packit |
7cfc04 |
(\fI/etc/sysconfig\fR on older Red Hat systems).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
In older UNIX systems, such a file contained the actual command line
|
|
Packit |
7cfc04 |
options for a daemon, but in modern Linux systems (and also
|
|
Packit |
7cfc04 |
in HP-UX), it just contains shell variables.
|
|
Packit |
7cfc04 |
A boot script in \fI/etc/init.d\fR reads and includes its configuration
|
|
Packit |
7cfc04 |
file (that is, it "\fBsources\fR" its configuration file) and then uses
|
|
Packit |
7cfc04 |
the variable values.
|
|
Packit |
7cfc04 |
.SH FILES
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.IR /etc/init.d/ ,
|
|
Packit |
7cfc04 |
.IR /etc/rc[S0\-6].d/ ,
|
|
Packit |
7cfc04 |
.I /etc/sysconfig/
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR init (1),
|
|
Packit |
7cfc04 |
.BR systemd (1),
|
|
Packit |
7cfc04 |
.BR inittab (5),
|
|
Packit |
7cfc04 |
.BR bootparam (7),
|
|
Packit |
7cfc04 |
.BR bootup (7),
|
|
Packit |
7cfc04 |
.BR runlevel (8),
|
|
Packit |
7cfc04 |
.BR shutdown (8)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|