booting and boot levels. 05/09/20152 …the boot process linux uses the init command and a directory...

30
Booting and boot levels

Upload: angela-stone

Post on 26-Dec-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

Booting and boot levels

Page 2: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 2

…The Boot Process

Linux uses the init command and a directory structure based on run-levels to start running the system and loading processes

Page 3: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 3

The Initialisation Process…

System States (or run levels) on early UNIX systems grew out of a need to separate how the system ran depending on the maintenance being performed

Usually, this meant that to add new hardware (or software) a system reboot was necessary

Today, with hot swappable devices, it is not strictly necessary to reboot systems in order to install new hardware or software

Page 4: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 4

…The initialisation Process…

The /etc/inittab file contains settings for the init process and also defines the run levels for a Linux system

Page 5: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 5

/etc/inittab file

# 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)#

Page 6: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 6

init process

init is sometimes referred to as the ‘father of all processes’

init is responsible for creating processes from a script stored in /etc/inittab

Linux init command is compatible with the System V init command

init starts as the last step of the kernel booting init is the first command that initialises and

configures the system for use

Page 7: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 7

init process

Init works by parsing the /etc/inittab file and by running scripts in the /etc/rc.d directories depending on the required run level

Each individual script is designed to start or stop and individual service such as networking, mail, news, web, nfs, dhcp etc.

Page 8: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 8

/etc/rc.d directory

The /etc/rc.d directory contains the following files:rc, rc.local, rc.sysinit

And the following directories:init.drc0.drc1.drc2.drc3.drc4.drc5.drc6.d

Page 9: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 9

Startup Scripts

One of the most important scripts in /etc/inttab is rc.sysinit

When init parses the inittab file, rc.sysinit is the first script found and executed

Page 10: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 10

rc.sysinit script

Sets some initial $PATH variables Configures Networking Sets up Swapping for Virtual Memory Sets the system hostname Checks root file systems for possible repairs Checks root filesystem quotas Turns on user and group quotas for root file

system

Page 11: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 11

rc.sysinit script

Remounts the root filesystem read/write Clears the mounted filesystems table

/etc/mtab Enters the root filesystem into mtab Readies the system for loading modules Finds module dependencies Checks filesystems for possible repairs Mounts all other file systems

Page 12: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 12

rc.sysinit script

Deletes UUCP lock files Deletes stale subsystem files Deletes stale pid files Sets the system clock Turns on swapping Initialises the serial ports Loads Modules

Page 13: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 13

rc.local script

After the rc.sysinit script is run, init runs the rc.local script to carry out any site-specific operations that may be required upon system startup

rc.local may examine the local system and create a message for the login prompt based on the hardware and software versions found

If it does, it will put such details in the file /etc/issue which may be displayed on login

Page 14: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 14

Run Level 0:

/etc/rc.d/rc0.d Starts the shutdown sequence

Kills All Processes Turns off Virtual Memory File Swapping Unmounts swap and mounted file systems

Page 15: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 15

Run Level 1:

/etc/rc,d/rc1.d Single user mode, or administrative state Used by sys admins while performing software

maintenance Nobody else can log in Networking is turned off, but file systems are

mounted

Page 16: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 16

Run Level 2:

/etc/rc.d/rc2.d Multiuser state Networking is enabled, NFS is disabled

Page 17: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 17

Run Level 3:

/etc/rc.d/rc3.d Usually the default run level specified as the first

line in the /etc/inittab file Remote file sharing is enabled along with all other

desired services

Page 18: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 18

Run Level 4:

/etc/rc4.d Usually empty, not used If you want to define your own run level, this can

be used to set up the appropriate links

Page 19: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 19

Run Level 5:

/etc/rc.d/rc5.d Similar to the default run level, but with the named

(internet DNS server) Usually the default run level for X11

Page 20: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 20

Run Level 6:

/etc/rc5.d Reboot run level Contains links similar to level 0, but logic in

the halt script in init.d determines whether the system is being shut down or rebooted

Page 21: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 21

Run Levels…

Each run-level is defined by the services (daemons) that are normally running in that level

The services to stop and start for each run level are defined in the rcX.d directories mentioned above

These directories contain symbolic links to master scripts contained in the /etc/rc.d/init.d directory

Page 22: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 22

…Run Levels…

The symbolic links contained in the rcX.d directories must be named so as to start with capital K or capital S For example: rc3.d contains the following

symbolic links:K05saslauthd K87portmap S10network S25netfs

S80sendmail S95anacron Any other files or symbolic links contained in

the rcX.d directories will be ignored by the rc script

Page 23: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 23

…Run Levels…

In addition to the inclusion of K or S at the start of the symbolic links, the file names also carry a number between 00 and 99

The combination of K or S followed by a number means that when the files are listed alphabetically, they appear in a particular order

This order determines the order in which the scripts are run by the rc script

Page 24: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 24

…Run Levels

When a symbolic link beginning with K is encuntered, rc runs that script with the stop parameter

When a symbolic link beginning with S is encountered, rc runs that script with the start parameter

Page 25: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 25

/etc/rc/d/init.d directory

This directory contains the master copies of all the scripts that may contain symbolic links in the rcX.d directories

Page 26: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 26

Adding Services to Run Levels

If we want a service to start in a given run level we must: Create or copy the start/stop/status script to the

/etc/rc.d/init.d directory Create a symbolic link in the required run level

directory to start the script in the appropriate sequence ln -s /etc/rc.d/init.d/isdn /etc/rc.d/rc3.d/S20isdn

Page 27: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 27

Init

Specify the run-level to put the machine into

Page 28: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 28

Shutdown

shutdown [-krhfnc] [-t secs] time [warning message] -k: Don’t really shut down, just warn -r: reboot after shutdown -h: halt after shutdown -f: do a ‘fast’ reboot -n: do not go through ‘init’ but go down real fast -c: cancel a running shutdown -t <sec>: delay between warning and kill signal Shutdown –t60 –r now

Page 29: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 29

Halt

Notifies the kernel of a shutdown or reboot

Page 30: Booting and boot levels. 05/09/20152 …The Boot Process Linux uses the init command and a directory structure based on run-levels to start running the

19/04/23 30

Reboot

Symbolic link to halt