Boot Process
Server Training - Server Administration

The Boot Process

The boot process or bootstrapping is the process whereby your computer starts up. This is a time of potential problems as there is so little of the system working in this initial stage. Hardware issues must be resolved and configuration files must be correct in order to get the boot process to work. This is one of the reasons that much effort has gone into making the boot process automatic. You can do a manual boot from single user mode.

Server Management Manual

Downloadable PDF - $49.95

Printed 11x 8.5 " Lay Flat Manual with Flash Movie CD

Server Management Manual

 

 

 

 

 

 

Server Management Manual is almost 500 pages of training with 25 Labs. This step by step manual will help you set up and manage a server. The manual is written for CentOS 5 (Red Hat Source Code). The topics in the manual include: boot process, root user, process management, managing the file system, managing users, managing quotas, managing system logs, managing hard drives, backups, automating actions,updates, networking, remote access with Webmin, VNC or SSH, kernel development, XWindow and server security. The manual is 11x8.5 ". This is lay flat spiral manual which is shipped. Includes 64 Flash movies with voice to demonstrate.

 

 

 

Here is a step by step event of a server booting.

Power On

BIOS Starts

POST

Hardware Probe

Select boot Device

Load and execute MBR

Load/execute second stage of GRUB

Load/execute kernel

Hardware probe

Mount Initial RAM disks

Initialize Devices

Mount root System

Load/execute /sbin/init

Select runlevel

run the rc command

run rc?.d/K* stop

run rc?.d/S* start

run kudzu

run daemons

text based logins

start XWindow

The BIOS

The BIOS is software that is placed on a ROM chip on the motherboard. The purpose of the BIOS is to interface between the hardware and the software that is on the system. The first thing the BIOS does is run a POST test, Power On Self-Test, to determine where the MBR is and what peripherals are connected to the machine.

The CMOS,Complementary Metal Oxide Semiconductor, holds the hardware configuration stored on a chip that is saved even when the computer is turned off.

The boot device is the Hard drive partition, CD-ROM, or USB device that holds the boot information. The BIOS will then execute the boot information which is usually found on the first physical sector of the boot device which is the MBR or Master Boot Record found on the first 512 bytes.


GRUB

Intel based motherboards must be started with a 16-bit operating system because of a limitation to 640 kilobytes of RAM at startup. GRUB is used to interface with the 16-bit requirement and load the 32-bit Linux kernel. The AMD CMOS is 64-bit so it can load the 64-bit kernel for Linux. In order for GRUB to work it must use a two step process. The first step loads and executes the Master Boot record, which will then execute the second step which is a file located in /etc/grub. This second step reads the file in /boot/grub/grub.conf.

Here is an example of menu.list found in /boot/grub. This example shows a CPU which has hyper-threading enabled for the CPU, showing two CPUs when there is actually one CPU.

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE: You have a /boot partition. This means that

# all kernel and initrd paths are relative to /boot/, eg.

# root (hd0,0)

# kernel /vmlinuz-version ro root=/dev/md0

# initrd /initrd-version.img

#boot=/dev/hda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title Red Hat Enterprise Linux ES (2.6.9-34.ELsmp)

root (hd0,0)

kernel /vmlinuz-2.6.9-34.ELsmp ro root=/dev/md0 rhgb quiet

initrd /initrd-2.6.9-34.ELsmp.img

title Red Hat Enterprise Linux ES-up (2.6.9-34.EL)

root (hd0,0)

kernel /vmlinuz-2.6.9-34.EL ro root=/dev/md0 rhgb quiet

initrd /initrd-2.6.9-34.EL.img


Note that the grub device name is hd0,0 which is the same as /dev/hda1. If you were going to install grub on /dev/hda1 the command would look like this:

grub-install `(hd0,0)`


Warning: When you install a new kernel or update a kernel you should never remove the existing kernel until you know for sure the new kernel works. So you should use this command to install a kernel:


rpm -ivh kernel*

This will not remove the old kernel.

The configuration shows that the default kernel to load is 0 which is the first one. If you wanted the default to be the second kernel you would change this to 1.

The purpose of kernel is to provide control for the initial process after the root file system has been installed. This requires that device drivers be loaded for all of the devices.

When GRUB activates the kernel it provides access to the initial RAM disk which is called /boot/initrd.x.y.z.img This initial RAM disk contains the drivers needed to mount a filesystem. Once the kernel has discovered and initialized hardware it mounts the root file system and initiates the /sbin/init.

When the kernel completes the basic initialization it creates several spontaneous processes. They are called spontaneous because they were not created out of the normal system fork.

Common Kernel Processes

kjournald - ext3 journal updates to disk

kswapd - swaps processes

kreclaimd - reclaims memory pages not used for a while

ksoftirqd - controls multiple layers of soft interrupts

khubd - configure USB devices


Once the kernel has created the spontaneous processes it turns it all over to init.


/etc/inittab sets the default runlevel and then calls the script at /etc/rc.d/rc.sysinit which starts many of the necessary system tasks such as kernel parameters from /etc/sysctl.conf, system clock, keymaps, swap, hostname, executes root file system check and then mounts it r/w, activate RAID, start quotas, mounts file systems in /etc/fstab and then cleans up the PIDs and state locks that were set.


Init Process

The init process is the last process to occur during the boot process. init has the process id of “1”. init launches several copies of mingetty Ctrl+ALT+ F1-F6 so that they can be used to login on terminals. init also launches the Graphical Login in runlevel 5.

The /etc/sysconfig/desktop file contains the preferred display manager which init launches in runlevel 5 as it selects the DISPLAYMANAGER variable.

This section of the /etc/inittab shows how to setup the shutdown if power is lost.


# When our UPS tells us power has failed, assume we have a few minutes

# of power left. Schedule a shutdown for 2 minutes from now.

# This does, of course, assume you have powered installed and your

# UPS connected and working correctly.

pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"


# If power was restored before the shutdown kicked in, cancel it.

pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"


Note that the init program is the first to run and has the PID of 1.

ps aux


init─┬─acpid

─artsd

─atd

─bonobo-activati

─crond

─cups-config-dae

─cupsd

─2*[dbus-daemon-1]

─dbus-launch

─eggcups

─events/0─┬─aio/0

  • ─aio/1


If the system has been started in single user mode by passing the word “single” to the kernel, init is made aware of this fact and waits for the user to load the system manually. If the file system has been loaded read only you will have to remount it as read/write to make changes.

mount -o rw, remount /


A user can enter single user mode by using the command:

telinit 1

or

at GRUB spash screen a user can click “a” to append the selected kernel. Then simply add single to the end of the line:


grub append> ro root=LABEL=/ rhgb quiet single

Now type b to boot into single user mode.

Once the initialization scripts have completed, init must still spawn the getty processes so users can login. The getty process, or mingetty, controls the login on virtual terminals. The graphical logins xdm and gdm are also spawned by init.

Startup Scripts

The startup scripts perform a number of important tasks. These scripts set the computer name, time zone, check disks with fsck, mount disks, remove old files from /tmp, set up network interfaces and start daemons. One place to look for errors on startup is the dmesg file in /var/log.


Daemons

The services run in specific runlevels. Each runlevel directory contains the services that run in that runlevel.

ls -la /etc/rc*

lrwxrwxrwx 1 root root 7 Oct 12 2006 /etc/rc -> rc.d/rc

lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc0.d -> rc.d/rc0.d

lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc1.d -> rc.d/rc1.d

lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc2.d -> rc.d/rc2.d

lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc3.d -> rc.d/rc3.d

lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc4.d -> rc.d/rc4.d

lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc5.d -> rc.d/rc5.d

lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc6.d -> rc.d/rc6.d

lrwxrwxrwx 1 root root 13 Oct 12 2006 /etc/rc.local -> rc.d/rc.local

lrwxrwxrwx 1 root root 15 Oct 12 2006 /etc/rc.sysinit -> rc.d/rc.sysinit


/etc/rc.d:

total 136

drwxr-xr-x 10 root root 4096 Oct 12 2006 .

drwxr-xr-x 82 root root 12288 May 21 07:53 ..

drwxr-xr-x 2 root root 4096 Nov 1 2006 init.d

-rwxr-xr-x 1 root root 2352 Mar 16 2004 rc

drwxr-xr-x 2 root root 4096 Nov 1 2006 rc0.d

drwxr-xr-x 2 root root 4096 Nov 1 2006 rc1.d

drwxr-xr-x 2 root root 4096 Dec 21 12:49 rc2.d

drwxr-xr-x 2 root root 4096 May 2 10:36 rc3.d

drwxr-xr-x 2 root root 4096 Dec 21 12:49 rc4.d

drwxr-xr-x 2 root root 4096 May 2 10:36 rc5.d

drwxr-xr-x 2 root root 4096 Nov 1 2006 rc6.d

-rwxr-xr-x 1 root root 220 Jun 23 2003 rc.local

-rwxr-xr-x 1 root root 27799 Dec 15 2005 rc.sysinit

init

The whole init process sets up various levels of options for the server. The server runlevels are listed below.

 

Runlevel

Function

0

shut down

1

single user - system rescue

2

multi-user with no network

3

multim-user in text mode

4

not used

5

multi-user GUI mode

6

reboot



/etc/inittab
Example:

#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Author: Miquel van Smoorenburg, < This e-mail address is being protected from spambots. You need JavaScript enabled to view it >
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, assume we have a few minutes
# of power left. Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"


# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemo

Runlevels

Linux has several levels or modes of operation called runlevels. These runlevels which are defined in /etc/inittab determine which user interfaces will be available as well as if the system will run allowing only one user or many users. Runlevels:

0       Turn the System Off 
1 Administrative Mode or Single-user Mode
2 Basic Multiuser Mode with No Networking
3 Multiuser Mode with Networking and Only a Command Line
4 Not Used
5 Graphical User Interface with Multiuser and Networking
6 Restart the System

Linux actually supports up to 10 runlevels but 7-9 are undefined at this time. The file /etc/inittab contains the configuration for runlevels and has the default runlevel for each system. When you view this file find this text to determine what the current runlevel is set at:

# The default runlevel is defined here id:5:initdefault:

The example shows that the default runlevel is 5, the Graphical User Interface with Multiuser mode and Networking. You would never want to set runlevels 0,4 or 6 in your inittab as this would make the system unusable. Runlevels could be changed in inittab or runlevels 3 and 5. The runlevel can also be determined by running this command at a terminal: /sbin/runlevel The return will be N with a number which will indicate the runlevel. The runlevel can be changed by using the init command with the desired runlevel as root:

init 0          this will stop the system
init 6 this will reboot the system

rc.d Directory

The rc.d directory is located at /etc/rc.d. In this directory are a series of directories that contain links to programs that run in different runlevels. The example shows the contents of /etc/rc.d/rc3.d

The first thing you will notice about each of the items is that they are links to the init.d directory. The second thing you will notice is that each has a K or an S that it starts with. S means start and K means to stop. The system will run each of these scripts when it starts in the numeric number that exits.

lrwxrwxrwx 1 root root 13 Dec 17 08:35 K20nfs → ../init.d/nfs

This example shows that the nfs service will be turned off and that the order in which this script is run is number 20 (K20nfs) which means that it will be run before other scripts with higher numbers.

[root@wk etc]# ls -la rc.d/rc3.d
total 260
drwxr-xr-x 2 root root 4096 Dec 22 11:35 .
drwxr-xr-x 10 root root 4096 Dec 17 08:34 ..
lrwxrwxrwx 1 root root 24 Dec 17 08:35 K02NetworkManager -> ../init.d/Networ kManager
lrwxrwxrwx 1 root root 19 Dec 17 08:34 K05saslauthd -> ../init.d/saslauthd
lrwxrwxrwx 1 root root 19 Dec 17 08:35 K10dc_server -> ../init.d/dc_server
lrwxrwxrwx 1 root root 16 Dec 17 08:35 K10psacct -> ../init.d/psacct
lrwxrwxrwx 1 root root 19 Dec 17 08:35 K12dc_client -> ../init.d/dc_client
lrwxrwxrwx 1 root root 13 Dec 17 08:35 K20nfs -> ../init.d/nfs
lrwxrwxrwx 1 root root 14 Dec 17 08:35 K24irda -> ../init.d/irda
lrwxrwxrwx 1 root root 22 Dec 17 08:38 K30spamassassin -> ../init.d/spamassa ssin
lrwxrwxrwx 1 root root 19 Dec 17 08:37 K35vncserver -> ../init.d/vncserver
lrwxrwxrwx 1 root root 17 Dec 17 10:41 K35winbind -> ../init.d/winbind
lrwxrwxrwx 1 root root 14 Dec 17 09:17 K36lisa -> ../init.d/lisa
lrwxrwxrwx 1 root root 16 Dec 17 10:36 K36mysqld -> ../init.d/mysqld
lrwxrwxrwx 1 root root 14 Dec 17 08:35 K50ipmi -> ../init.d/ipmi
lrwxrwxrwx 1 root root 17 Dec 17 08:35 K50netdump -> ../init.d/netdump
lrwxrwxrwx 1 root root 15 Dec 17 08:36 K50snmpd -> ../init.d/snmpd
lrwxrwxrwx 1 root root 19 Dec 17 08:36 K50snmptrapd -> ../init.d/snmptrapd
lrwxrwxrwx 1 root root 16 Dec 17 10:41 K73ypbind -> ../init.d/ypbind
lrwxrwxrwx 1 root root 14 Dec 17 10:41 K74nscd -> ../init.d/nscd
lrwxrwxrwx 1 root root 15 Dec 17 08:35 K85mdmpd -> ../init.d/mdmpd
lrwxrwxrwx 1 root root 18 Dec 17 08:34 K89netplugd -> ../init.d/netplugd
lrwxrwxrwx 1 root root 19 Dec 17 08:35 K90bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root 18 Dec 17 08:35 K94diskdump -> ../init.d/diskdump
lr
lrwxrwxrwx 1 root root 25 Dec 17 08:35 K99readahead_early -> ../init.d/reada head_early
lrwxrwxrwx 1 root root 23 Dec 17 08:35 S00microcode_ctl -> ../init.d/microco de_ctl
lrwxrwxrwx 1 root root 15 Dec 17 08:34 S05kudzu -> ../init.d/kudzu
lrwxrwxrwx 1 root root 18 Dec 17 08:35 S06cpuspeed -> ../init.d/cpuspeed
lrwxrwxrwx 1 root root 18 Dec 17 08:35 S08iptables -> ../init.d/iptables
lrwxrwxrwx 1 root root 14 Dec 17 08:35 S09isdn -> ../init.d/isdn
lrwxrwxrwx 1 root root 16 Dec 17 08:35 S09pcmcia -> ../init.d/pcmcia
lrwxrwxrwx 1 root root 17 Dec 17 08:34 S10network -> ../init.d/network
lrwxrwxrwx 1 root root 16 Dec 17 08:34 S12syslog -> ../init.d/syslog
lrwxrwxrwx 1 root root 20 Dec 17 08:35 S13irqbalance -> ../init.d/irqbalance
lrwxrwxrwx 1 root root 17 Dec 17 08:35 S13portmap -> ../init.d/portmap
lrwxrwxrwx 1 root root 17 Dec 17 08:35 S14nfslock -> ../init.d/nfslock
lrwxrwxrwx 1 root root 19 Dec 17 08:35 S15mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx 1 root root 19 Dec 17 08:35 S18rpcidmapd -> ../init.d/rpcidmapd
lrwxrwxrwx 1 root root 17 Dec 17 08:35 S19rpcgssd -> ../init.d/rpcgssd
lrwxrwxrwx 1 root root 15 Dec 17 08:34 S25netfs -> ../init.d/netfs
lrwxrwxrwx 1 root root 14 Dec 17 08:35 S26apmd -> ../init.d/apmd
lrwxrwxrwx 1 root root 20 Dec 17 08:36 S26lm_sensors -> ../init.d/lm_sensors
lrwxrwxrwx 1 root root 16 Dec 17 08:35 S28autofs -> ../init.d/autofs
lrwxrwxrwx 1 root root 16 Dec 17 08:35 S40smartd -> ../init.d/smartd
lrwxrwxrwx 1 root root 15 Dec 17 08:35 S44acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 14 Dec 22 11:35 S55cups -> ../init.d/cups
lrwxrwxrwx 1 root root 14 Dec 17 08:35 S55sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 20 Dec 17 08:34 S56rawdevices -> ../init.d/rawdevices
lrwxrwxrwx 1 root root 16 Dec 17 08:35 S56xinetd -> ../init.d/xinetd
lrwxrwxrwx 1 root root 14 Dec 17 10:43 S58ntpd -> ../init.d/ntpd
lrwxrwxrwx 1 root root 18 Dec 17 08:35 S80sendmail -> ../init.d/sendmail
lrwxrwxrwx 1 root root 13 Dec 17 08:35 S85gpm -> ../init.d/gpm
lrwxrwxrwx 1 root root 15 Dec 17 08:35 S90crond -> ../init.d/crond
lrwxrwxrwx 1 root root 13 Dec 17 08:36 S90xfs -> ../init.d/xfs
lrwxrwxrwx 1 root root 13 Dec 20 04:45 S91smb -> ../init.d/smb
lrwxrwxrwx 1 root root 17 Dec 17 08:35 S95anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root 13 Dec 17 08:35 S95atd -> ../init.d/atd
lrwxrwxrwx 1 root root 20 Dec 17 08:34 S97messagebus -> ../init.d/messagebus
lrwxrwxrwx 1 root root 15 Dec 17 08:35 S97rhnsd -> ../init.d/rhnsd
lrwxrwxrwx 1 root root 28 Dec 17 08:37 S98cups-config-daemon -> ../init.d/cu ps-config-daemon
lrwxrwxrwx 1 root root 19 Dec 17 08:34 S98haldaemon -> ../init.d/haldaemon
lrwxrwxrwx 1 root root 11 Dec 17 08:34 S99local -> ../rc.local
wxrwxrwx 1 root root 19 Dec 17 08:35 K99readahead -> ../init.d/readahead

 


Copyright CyberMontana Inc. and BeginLinux.com

All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874