Professional Documents
Culture Documents
06 Run Level Concepts
06 Run Level Concepts
: PPT/2K403/02
• Booting Sequence.
• The Run-levels.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
Booting Sequence
3
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
– BIOS- Grub – Kernel : The first three significant steps when Linux
computer is started.
– The kernel uncompress itself and organizes the subsequent
booting of the system.
– It searches for the RAM disk, providing one is available.
– This depends on whether GRUB (Grand Unified Bootloader) has
loaded initrd (/boot/initrd).
– If initrd exists, it is integrated into kernel.
– Then linuxrc is started, it loads the modules required to mount the
root file system.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
– When this script is finished, the kernel removes initrd from the
system.
– If no initrd exists, the drivers to mount the file system are already
in the kernel.
– The kernel can now boot from hard drive and starts the first
process: init .
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
– init thus controls the entire booting of the system as well as the
shutting down, because init is the last process running, ensuring
that all other processes are correctly ended.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
The Runlevel
7
– The init process ensures that all actions specified there are
carried out.
– The format of this file is :
• id:runlevel:action:process
– id is unique name for the entry in /etc/inittab; it can be up to four
characters in length.
– runlevel refers to one or more runlevels in which this entry should be
evaluated.
– action describes what init is to do.
– process is the process connected to this entry.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
– Linux also has Ctrl + Alt +Del key combination for restarting.
• ca:ctrlaltdel:/sbin/shutdown –r –t 4 now
– Following block describes in which runlevels getty
processes (login processes) are started.
• 1.2345:respawn:/sbin/mingetty –noclear tty1
• 2:2345:respawn:/sbin/mingetty tty2
• 3:2345:respawn:/sbin/mingetty tty3
• 4:2345:respawn:/sbin/mingetty tty4
– The getty processes provide the login prompt and in return
expect a user name as input.
– If the line is disabled, no further login is possible at
corresponding virtual console.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
• In the directory /etc/init.d, all the scripts used to start and stop
services are located.
– These scripts are called in different ways :
• Called up directly by init when the system is booted or when the
system is shut down.
• Called up indirectly by init when changing the runlevel.
• Called up directly by /etc/init.d/script start or stop
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
Parameter Description
– start Starts a service that is not running
– stop Stops the service that is running
– restart Stops the service that is running and starts
again.
– reload Rereads the configuration of the service without
stopping and restarting the service.
– status Displays the current status of the Service
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
• rc
– This scripts is responsible for the correct change from one runlevel to
another one.
– It runs the stop scripts for the current runlevel then the start scripts for
new one.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
– When the runlevel is changed, first the stop scripts of the current
runlevel are run, then the start scripts of new runlevel.
– These scripts for each runlevel are located in the directories
/etc/init.d/rcrunlevel.d .
– All the start scripts begin with an “S”and stop scripts with “K”.
– The following example illustrates how changes from runlevel 3 to
runlevel 5 takes place.
• The system is running in runlevel 3. If the administrator (root) now
enters init5.
• init consults the configuration file /etc/inittab to find out which script
to run when changing to this runlevel: /etc/init.d/rc with parameter 5.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
• Now programs rc compares all the stop scripts of runlevel with the
start scripts of runlevel 5.If there is not matching , stop scripts is
started, ending the service.
• Then the start scripts of runlevel 5 are compared with the stop scripts
of runlevel 3.
• If there is no matching, start script is started, starting the service.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
– There are some useful commands for properly shutting down the
system or restarting it:
Command Description
• halt Ensures an immediate, controlled system
halt.
• poweroff Same effect a halt,except that machine is
switched off automatically if possible.
• reboot Reboots the system.
• shutdown –h time Shuts down the system after the specified
time.with option –r instead of –h, the
system is rebooted.without option it changes to
runlevel 1.
– The shutdown command can also be given with warning message,
# shutdown +5 The new hard drive arrived
– The shutdown command can be revoked by, shutdown -c
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
18