Presentation is loading. Please wait.

Presentation is loading. Please wait.

CIS 191 - Lesson 4 Booting the System. CIS 191 - Lesson 4 Booting the System 1.Power On Self Test (POST) – loads the BIOS. 2.BIOS loads the Master Boot.

Similar presentations


Presentation on theme: "CIS 191 - Lesson 4 Booting the System. CIS 191 - Lesson 4 Booting the System 1.Power On Self Test (POST) – loads the BIOS. 2.BIOS loads the Master Boot."— Presentation transcript:

1 CIS 191 - Lesson 4 Booting the System

2 CIS 191 - Lesson 4 Booting the System 1.Power On Self Test (POST) – loads the BIOS. 2.BIOS loads the Master Boot Record. 3.MBR read its partition table to determine which partition to boot into. 4.MBR loads the boot program in the active partition. 5.Boot program presents user with boot prompt menu. 6.Based upon user selection, boot program loads desired kernel along with and supplied boot options 7.Kernel uncompresses and loads into memory. 8.Kernel detects hardware and initializes its data.

3 CIS 191 - Lesson 4 Rooting the System

4 CIS 191 - Lesson 4 Rooting the System 1.Kernel mounts the root file system 2.Kernel creates and starts the init process 3. init reads /etc/inittab for its instructions 4. init performs system initialization: presents some kind of welcome banner allows for and interactive startup set up keyboard mapping, system fonts, plug and play devices, … checks for dirty file systems, can cleans them if necessary checks disk quotas and swap space mounts all file systems 5.Chooses which runlevel to come up in and executes those scripts via rc script 6.daemons load 7.getty processes are spawned on terminal devices

5 CIS 191 - Lesson 4 Init and runlevels

6 CIS 191 - Lesson 4 Init and Runlevels The /etc/inittab file: A two letter system identifier id A list of runlevels for specified actions An action – how and when should a command be run The process – which command to run Runlevels Runlevel 0 Runlevel 1 Runlevel 2 Runlevel 3, 4, 5 Runlevel 6 rc scripts and/or rc.d directories for each run level RC script naming conventions Start with S or K A number A daemon shell script

7 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – Page 1 [root@rh9 root]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # 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

8 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – Page 1 [root@rh9 root]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # 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 The /etc/inittab file used by the init program Instruction syntax: id:runlevels:action:process id - A two letter system identifier runlevels - A list of runlevels for specified actions action – how and when should a command be run process – the command or script to run Set default system runlevel

9 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – Page 1 [root@rh9 root]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # 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 The /etc/inittab file used by the init program Instruction syntax: id:runlevels:action:process id - A two letter system identifier runlevels - A list of runlevels for specified actions action – how and when should a command be run process – the command or script to run Initialize system (applies to all runlevels)

10 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – Page 1 [root@rh9 root]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # 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 The /etc/inittab file used by the init program Instruction syntax: id:runlevels:action:process id - A two letter system identifier runlevels - A list of runlevels for specified actions action – how and when should a command be run process – the command or script to run Transition to specific runlevel

11 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – Page 1 [root@rh9 root]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # 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 Modify this number to change default runlevel Instructions for the init program System initialization script Runlevel transition script

12 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – Page 1 [root@rh9 root]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # 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 To force user to login with root password for singe user mode add: s0:S:wait:/sbin/sulogin (more in CIS 193)

13 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – page 2 # 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 -nodaemon [root@rh9 root]# mingetty prompts for a username then initiates login process on ttys respawn fires up programs again when they end Note: Runlevel 1 is single user mode Action to take on ctrl-alt-del To disable, comment out with # Runlevel 5 is graphics mode using X

14 CIS 191 - Lesson 4 /etc/inittab password protection in single user mode During GRUB boot, edit the kernel line and add "single" to boot into single user mode Without s0:S:wait:/sbin/sulogin in /etc/inittab Logged in as root without entering a password With s0:S:wait:/sbin/sulogin in /etc/inittab Must enter password to be logged in as root

15 CIS 191 - Lesson 4 runlevel command show previous and current runlevels [root@rh9 root]# runlevel N 5 [root@rh9 root]# Previous runlevel (N=None) Current runlevel

16 CIS 191 - Lesson 4 Important log files dmesg command or /var/log/dmesg var/log/dmesg – kernel boot messages [root@rh9 root]# dmesg | more Linux version 2.4.20-6 (bhcompile@porky.devel.redhat.com) (gcc version 3.2.2 200 30222 (Red Hat Linux 3.2.2-5)) #1 Thu Feb 27 10:06:59 EST 2003 BIOS-provided physical RAM map: BIOS-e820: 0000000000000000 - 000000000009f800 (usable) BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved) BIOS-e820: 00000000000ca000 - 00000000000cc000 (reserved) BIOS-e820: 00000000000dc000 - 00000000000e0000 (reserved) BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved) BIOS-e820: 0000000000100000 - 000000000fef0000 (usable) BIOS-e820: 000000000fef0000 - 000000000feff000 (ACPI data) BIOS-e820: 000000000feff000 - 000000000ff00000 (ACPI NVS) BIOS-e820: 000000000ff00000 - 0000000010000000 (usable) BIOS-e820: 00000000fec00000 - 00000000fec10000 (reserved) BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved) BIOS-e820: 00000000fffe0000 - 0000000100000000 (reserved) 0MB HIGHMEM available. 256MB LOWMEM available. On node 0 totalpages: 65536 zone(0): 4096 pages. zone(1): 61440 pages. zone(2): 0 pages. Kernel command line: ro root=LABEL=/

17 CIS 191 - Lesson 4 Important log files /var/log/boot.log var/log/boot.log – show services [root@rh9 root]# more /var/log/boot.log Aug 13 07:55:46 rh9 syslog: syslogd startup succeeded Aug 13 07:55:46 rh9 syslog: klogd startup succeeded Aug 13 07:55:46 rh9 portmap: portmap startup succeeded Aug 13 07:55:46 rh9 nfslock: rpc.statd startup succeeded Aug 13 07:55:46 rh9 keytable: Loading keymap: Aug 13 07:55:46 rh9 keytable: Aug 13 07:55:46 rh9 rc: Starting keytable: succeeded Aug 13 07:55:47 rh9 random: Initializing random number generator: succeeded Aug 13 07:55:47 rh9 rc: Starting pcmcia: succeeded Aug 13 07:55:47 rh9 netfs: Mounting other filesystems: succeeded Aug 13 07:55:47 rh9 apmd: apmd startup succeeded Aug 13 07:55:47 rh9 autofs: automount startup succeeded Aug 13 07:55:48 rh9 sshd: RSA1 key generation succeeded Aug 13 07:55:48 rh9 sshd: RSA key generation succeeded Aug 13 07:55:46 rh9 ifup: failed; no link present. Check cable? Aug 13 07:55:46 rh9 network: Bringing up interface eth0: failed Aug 13 07:55:49 rh9 sshd: DSA key generation succeeded Aug 13 07:55:49 rh9 sshd: succeeded Aug 13 07:55:53 rh9 xinetd: xinetd startup succeeded Aug 13 07:55:53 rh9 sendmail: sendmail startup succeeded Aug 13 07:55:54 rh9 sendmail: sm-client startup succeeded

18 CIS 191 - Lesson 4 Red Hat Runlevels - /etc/rc.d/ [root@rh9 rc.d]# ls -R.: init.d rc rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rc.local rc.sysinit./init.d: anacron autofs firstboot halt isdn killall network nscd portmap rhnsd single vmware-tools ypbind apmd crond functions iptables kdcrotate kudzu nfs ntpd random saslauthd sshd xfs atd cups gpm irda keytable netfs nfslock pcmcia rawdevices sendmail syslog xinetd./rc0.d: K03rhnsd K05keytable K10cups K20nfs K30sendmail K60crond K74ntpd K86nfslock K90network K95firstboot S00killall K05anacron K05saslauthd K10xfs K24irda K44rawdevices K72autofs K75netfs K87portmap K91isdn K95kudzu S01halt K05atd K08vmware-tools K15gpm K25sshd K50xinetd K74apmd K80random K88syslog K92iptables K96pcmcia./rc1.d: K03rhnsd K05saslauthd K10xfs K24irda K44rawdevices K72autofs K75netfs K87portmap K91isdn K95kudzu S17keytable K05anacron K08vmware-tools K15gpm K25sshd K50xinetd K74apmd K80random K88syslog K92iptables K96pcmcia K05atd K10cups K20nfs K30sendmail K60crond K74ntpd K86nfslock K90network K95firstboot S00single./rc2.d: K03rhnsd K20nfs K50xinetd K75netfs K95firstboot S09isdn S17keytable S24pcmcia S80sendmail S90cups S99local K05atd K24irda K72autofs K86nfslock K95kudzu S10network S19vmware-tools S26apmd S85gpm S90xfs K05saslauthd K44rawdevices K74ntpd K87portmap S08iptables S12syslog S20random S55sshd S90crond S95anacron./rc3.d: K05saslauthd K74ntpd S08iptables S12syslog S17keytable S24pcmcia S28autofs S56xinetd S90crond S95anacron S99local K20nfs K95firstboot S09isdn S13portmap S19vmware-tools S25netfs S55sshd S80sendmail S90cups S95atd K24irda S05kudzu S10network S14nfslock S20random S26apmd S56rawdevices S85gpm S90xfs S97rhnsd./rc4.d: K05saslauthd K24irda S05kudzu S10network S14nfslock S24pcmcia S28autofs S56xinetd S90crond S95anacron S99local K08vmware-tools K74ntpd S08iptables S12syslog S17keytable S25netfs S55sshd S80sendmail S90cups S95atd K20nfs K95firstboot S09isdn S13portmap S20random S26apmd S56rawdevices S85gpm S90xfs S97rhnsd./rc5.d: K05saslauthd K74ntpd S08iptables S12syslog S17keytable S24pcmcia S28autofs S56xinetd S90crond S95anacron S99local K20nfs K95firstboot S09isdn S13portmap S19vmware-tools S25netfs S55sshd S80sendmail S90cups S95atd K24irda S05kudzu S10network S14nfslock S20random S26apmd S56rawdevices S85gpm S90xfs S97rhnsd./rc6.d: K03rhnsd K05keytable K10cups K20nfs K30sendmail K60crond K74ntpd K86nfslock K90network K95firstboot S00killall K05anacron K05saslauthd K10xfs K24irda K44rawdevices K72autofs K75netfs K87portmap K91isdn K95kudzu S01reboot K05atd K08vmware-tools K15gpm K25sshd K50xinetd K74apmd K80random K88syslog K92iptables K96pcmcia [root@rh9 rc.d]# Directory name specifies the runlevel File names specify action, order, and service: S = Start, K=Kill Two digit sequence order Name of service(daemon) to start or kill From /etc/inittab 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

19 CIS 191 - Lesson 4 Red Hat Runlevel 3 - /etc/rc.d/rc3.d Directory name specifies the runlevel File names specify action, order, and service: S = Start, K=Kill Two digit start/stop sequence order Name of service(daemon) to start or kill Symbolic links used to actual scripts in /etc/rc.d/int.d/

20 CIS 191 - Lesson 4 Red Hat Runlevel 3 - /etc/rc.d/rc3.d/S55sshd This is the script that is run by the rc script to start and stop the ssh service

21 CIS 191 - Lesson 4 init command Change runlevels now

22 CIS 191 - Lesson 4 show and customize runlevels service and chkconfig commands [root@rh9 root]# service cups stop Stopping cups: [ OK ] [root@rh9 root]# service cups start Starting cups: [ OK ] [root@rh9 root]# service cups restart Stopping cups: [ OK ] Starting cups: [ OK ] [root@rh9 root]# service cups status cupsd (pid 1774) is running... [root@rh9 root]# [root@rh9 rc.d]# chkconfig --list cups cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@rh9 rc.d]# chkconfig --level 3 cups off [root@rh9 rc.d]# chkconfig --list cups cups 0:off 1:off 2:on 3:off 4:on 5:on 6:off [root@rh9 rc.d]# chkconfig --level 3 cups on [root@rh9 rc.d]# chkconfig --list cups cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@rh9 rc.d]# To stop and start a service (will stay until next reboot) To stop and start a service permanently (won't take place until next reboot)

23 CIS 191 - Lesson 4 chkconfig command customize runlevels [root@rh9 rc.d]# ls rc3.d K05saslauthd S08iptables S17keytable S28autofs S90crond S99local K20nfs S09isdn S19vmware-tools S55sshd S90cups K24irda S10network S20random S56rawdevices S90xfs K74ntpd S12syslog S24pcmcia S56xinetd S95anacron K95firstboot S13portmap S25netfs S80sendmail S95atd S05kudzu S14nfslock S26apmd S85gpm S97rhnsd [root@rh9 rc.d]# chkconfig --level 3 cups off [root@rh9 rc.d]# ls rc3.d K05saslauthd S05kudzu S14nfslock S26apmd S85gpm S99local K10cups S08iptables S17keytable S28autofs S90crond K20nfs S09isdn S19vmware-tools S55sshd S90xfs K24irda S10network S20random S56rawdevices S95anacron K74ntpd S12syslog S24pcmcia S56xinetd S95atd K95firstboot S13portmap S25netfs S80sendmail S97rhnsd [root@rh9 rc.d]# chkconfig --level 3 cups on [root@rh9 rc.d]# ls rc3.d K05saslauthd S08iptables S17keytable S28autofs S90crond S99local K20nfs S09isdn S19vmware-tools S55sshd S90cups K24irda S10network S20random S56rawdevices S90xfs K74ntpd S12syslog S24pcmcia S56xinetd S95anacron K95firstboot S13portmap S25netfs S80sendmail S95atd S05kudzu S14nfslock S26apmd S85gpm S97rhnsd [root@rh9 rc.d]#

24 CIS 191 - Lesson 4 chkconfig command show all services and runlevels [root@rh9 rc.d]# chkconfig --list vmware-tools 0:off 1:off 2:on 3:on 4:off 5:on 6:off kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off random 0:off 1:off 2:on 3:on 4:on 5:on 6:off rawdevices 0:off 1:off 2:off 3:on 4:on 5:on 6:off pcmcia 0:off 1:off 2:on 3:on 4:on 5:on 6:off saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off keytable 0:off 1:on 2:on 3:on 4:on 5:on 6:off apmd 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off irda 0:off 1:off 2:off 3:off 4:off 5:off 6:off isdn 0:off 1:off 2:on 3:on 4:on 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off portmap 0:off 1:off 2:off 3:on 4:on 5:on 6:off nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off rhnsd 0:off 1:off 2:off 3:on 4:on 5:on 6:off crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off firstboot 0:off 1:off 2:off 3:off 4:off 5:off 6:off

25 CIS 191 - Lesson 4 Exercise: Runlevels 1.Find out what your current runlevel is. 2.Start and stop the cups service. 3.Configure cups service to not start for runlevel 3 4.Change from run level 5 to runlevel 2 5.Check cups service (hint: service cups status ) 6.Change from 2 to 3 7.Check cups service 8.Reconfigure cups service back to original setting for runlevel 3 and start the service manually. Note: If you mouse starts acting "weird" in your VM after changing runlevles, then restart the gpm service: service gpm restart

26 CIS 191 - Lesson 4 Shutting down the system

27 CIS 191 - Lesson 4 Shutting down the system Shutting down: Users log out Services halt Data is saved File systems are unmounted System powers off Types of shutdowns: init 0 – no user warning shutdown [-hcr] time – warns users before shutting down halt and reboot – shortcuts for shutdown Ctrl-Alt-Del – shutdown behavior can be disabled

28 CIS 191 - Lesson 4 shutdown command Schedule for a time in the future

29 CIS 191 - Lesson 4 shutdown command Cancelling a pending shutdown

30 CIS 191 - Lesson 4 halt command shortcut to shutdown

31 CIS 191 - Lesson 4 Startup and Shutdown walk-through

32 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – Page 1 [root@rh9 root]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # 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

33 CIS 191 - Lesson 4 /etc/inittab Red Hat 9 – page 2 # 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 -nodaemon [root@rh9 root]#

34 CIS 191 - Lesson 4 Red Hat 9 Starting Up GRUB boot code runs [root@rh9 root]# cat /boot/grub/grub.conf # 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/sda2 # initrd /initrd-version.img #boot=/dev/sda default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz title Red Hat Linux (2.4.20-6) root (hd0,0) kernel /vmlinuz-2.4.20-6 ro root=LABEL=/ initrd /initrd-2.4.20-6.img [root@rh9 root]#

35 CIS 191 - Lesson 4 Red Hat 9 Starting Up GRUB boot code uncompresses kernel

36 CIS 191 - Lesson 4 Red Hat 9 Starting Up kernel starts up – screen capture and dmesg dmesg output (snipped) [root@rh9 root]# dmesg Linux version 2.4.20-6 (bhcompile@porky.devel.redhat.com) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Thu Feb 27 10:06:59 EST 2003 BIOS-provided physical RAM map: BIOS-e820: 0000000000000000 - 000000000009f800 (usable) BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved) BIOS-e820: 00000000000ca000 - 00000000000cc000 (reserved) BIOS-e820: 00000000000dc000 - 00000000000e0000 (reserved) BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved) BIOS-e820: 0000000000100000 - 000000000fef0000 (usable) BIOS-e820: 000000000fef0000 - 000000000feff000 (ACPI data) BIOS-e820: 000000000feff000 - 000000000ff00000 (ACPI NVS) BIOS-e820: 000000000ff00000 - 0000000010000000 (usable) BIOS-e820: 00000000fec00000 - 00000000fec10000 (reserved) BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved) BIOS-e820: 00000000fffe0000 - 0000000100000000 (reserved)

37 CIS 191 - Lesson 4 Red Hat 9 Starting Up kernel starts up – screen capture and dmesg BIOS-e820: 00000000fffe0000 - 0000000100000000 (reserved) 0MB HIGHMEM available. 256MB LOWMEM available. On node 0 totalpages: 65536 zone(0): 4096 pages. zone(1): 61440 pages. zone(2): 0 pages. Kernel command line: ro root=LABEL=/ Initializing CPU#0 Detected 2501.843 MHz processor. Console: colour VGA+ 80x25 Calibrating delay loop... 5006.95 BogoMIPS Memory: 252832k/262144k available (1347k kernel code, 6812k reserved, 999k data, 132k init, 0k highmem) Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode cache hash table entries: 16384 (order: 5, 131072 bytes) Mount cache hash table entries: 512 (order: 0, 4096 bytes) Buffer-cache hash table entries: 16384 (order: 4, 65536 bytes) Page-cache hash table entries: 65536 (order: 6, 262144 bytes) Intel machine check architecture supported. Intel machine check reporting enabled on CPU#0. CPU: After generic, caps: 0febfbff 00100000 00000000 00000000 CPU: Common caps: 0febfbff 00100000 00000000 00000000 CPU: Intel(R) Core(TM)2 Duo CPU T9300 @ 2.50GHz stepping 06 Enabling fast FPU save and restore... done. Enabling unmasked SIMD FPU exception support... done. Checking 'hlt' instruction... OK.

38 CIS 191 - Lesson 4 Checking 'hlt' instruction... OK. POSIX conformance testing by UNIFIX mtrr: v1.40 (20010327) Richard Gooch (rgooch@atnf.csiro.au) mtrr: detected mtrr type: Intel PCI: PCI BIOS revision 2.10 entry at 0xfd8a0, last bus=1 PCI: Using configuration type 1 PCI: Probing PCI hardware PCI: Using IRQ router PIIX [8086/7110] at 00:07.0 Limiting direct PCI/PCI transfers. isapnp: Scanning for PnP cards... Red Hat 9 Starting Up kernel starts up – dmesg

39 CIS 191 - Lesson 4 dmesg output (snipped) isapnp: Scanning for PnP cards... isapnp: No Plug & Play device found Linux NET4.0 for Linux 2.4 Based upon Swansea University Computer Society NET3.039 Initializing RT netlink socket apm: BIOS version 1.2 Flags 0x03 (Driver version 1.16) Starting kswapd VFS: Disk quotas vdquot_6.5.1 pty: 2048 Unix98 ptys configured Serial driver version 5.05c (2001-07-08) with MANY_PORTS MULTIPORT SHARE_IRQ SERIAL_PCI ISAPNP enabled ttyS0 at 0x03f8 (irq = 4) is a 16550A ttyS1 at 0x02f8 (irq = 3) is a 16550A Red Hat 9 Starting Up kernel starts up – screen capture and dmesg

40 CIS 191 - Lesson 4 Red Hat 9 Starting Up kernel starts up – screen capture and dmesg ttyS1 at 0x02f8 (irq = 3) is a 16550A Real Time Clock Driver v1.10e Floppy drive(s): fd0 is 1.44M FDC 0 is a post-1991 82077 NET4: Frame Diverter 0.46 RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize Uniform Multi-Platform E-IDE driver Revision: 7.00beta-2.4 ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx PIIX4: IDE controller at PCI slot 00:07.1 PIIX4: chipset revision 1 PIIX4: not 100% native mode: will probe irqs later ide1: BM-DMA at 0x1408-0x140f, BIOS settings: hdc:DMA, hdd:pio hdc: VMware Virtual IDE CDROM Drive, ATAPI CD/DVD-ROM drive ide1 at 0x170-0x177,0x376 on irq 15 ide-floppy driver 0.99.newide md: md driver 0.90.0 MAX_MD_DEVS=256, MD_SB_DISKS=27 md: Autodetecting RAID arrays. md: autorun... md:... autorun DONE. NET4: Linux TCP/IP 1.0 for NET4.0 IP Protocols: ICMP, UDP, TCP, IGMP IP: routing cache hash table of 2048 buckets, 16Kbytes TCP: Hash tables configured (established 16384 bind 32768) Linux IP multicast router 0.06 plus PIM-SM NET4: Unix domain sockets 1.0/SMP for Linux NET4.0. RAMDISK: Compressed image found at block 0 Freeing initrd memory: 248k freed

41 CIS 191 - Lesson 4 Red Hat 9 Starting Up kernel starts up – screen capture and dmesg dmesg output (snipped) Freeing initrd memory: 248k freed VFS: Mounted root (ext2 filesystem). SCSI subsystem driver Revision: 1.00 PCI: Found IRQ 11 for device 00:10.0 scsi: ***** BusLogic SCSI Driver Version 2.1.15 of 17 August 1998 ***** scsi: Copyright 1995-1998 by Leonard N. Zubkoff scsi0: Configuring BusLogic Model BT-958 PCI Wide Ultra SCSI Host Adapter scsi0: Firmware Version: 5.07B, I/O Address: 0x1060, IRQ Channel: 11/Level scsi0: PCI Bus: 0, Device: 16, Address: 0xE8800000, Host Adapter SCSI ID: 7 scsi0: Parity Checking: Enabled, Extended Translation: Enabled scsi0: Synchronous Negotiation: Ultra, Wide Negotiation: Enabled scsi0: Disconnect/Reconnect: Enabled, Tagged Queuing: Enabled scsi0: Scatter/Gather Limit: 128 of 8192 segments, Mailboxes: 211 scsi0: Driver Queue Depth: 211, Host Adapter Queue Depth: 192 scsi0: Tagged Queue Depth: Automatic, Untagged Queue Depth: 3 scsi0: Error Recovery Strategy: Default, SCSI Bus Reset: Enabled scsi0: *** BusLogic BT-958 Initialized Successfully *** scsi0 : BusLogic BT-958 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 scsi0: Target 0: Queue Depth 28, Asynchronous scsi0: Target 1: Queue Depth 28, Asynchronous * * * * * - Not all screen messages are in dmesg output

42 CIS 191 - Lesson 4 dmesg output (snipped) Attached scsi disk sda at scsi0, channel 0, id 0, lun 0 Attached scsi disk sdb at scsi0, channel 0, id 1, lun 0 SCSI device sda: 10485760 512-byte hdwr sectors (5369 MB) Partition check: sda: sda1 sda2 sda3 sda4 SCSI device sdb: 4194304 512-byte hdwr sectors (2147 MB) sdb: unknown partition table Journalled Block Device driver loaded kjournald starting. Commit interval 5 seconds EXT3-fs: mounted filesystem with ordered data mode. Freeing unused kernel memory: 132k freed scsi0: Tagged Queuing now active for Target 0 Red Hat 9 Starting Up kernel finds and starts init program * * * * * * * - Not all screen messages are in dmesg output Init program starts File system mounted

43 CIS 191 - Lesson 4 Red Hat 9 Starting Up init program uses instructions in /etc/inittab Snippet from /etc/rc.d/rc.sysinit # Print a text banner. echo -en $"\t\tWelcome to " if LC_ALL=C grep -q "Red Hat" /etc/redhat-release ; then [ "$BOOTUP" = "color" ] && echo -en "\\033[0;31m" echo -en "Red Hat" [ "$BOOTUP" = "color" ] && echo -en "\\033[0;39m" PRODUCT=`sed "s/Red Hat \(.*\) release.*/\1/" /etc/redhat- release` echo " $PRODUCT" else PRODUCT=`sed "s/ release.*//g" /etc/redhat-release` echo "$PRODUCT" fi From /etc/inittab # System initialization. si::sysinit:/etc/rc.d/rc.sysinit init program starts /etc/rc.d/rc.sysinit init checks file system allows for interactive startup

44 CIS 191 - Lesson 4 Red Hat 9 Starting Up init runs – /etc/rc.d/rc.sysinit and /etc/rc.d/rc scripts /etc/rc.d/rc.sysinit /etc/rc.d/rc 5 Snippet from /etc/inittab l5:5:wait:/etc/rc.d/rc 5 From /etc/inittab # System initialization. si::sysinit:/etc/rc.d/rc.sysinit init checks file system allows for interactive startup

45 CIS 191 - Lesson 4 Red Hat 9 Starting Up init - starting /etc/rc.d/rc 5 Snippet from /etc/rc.d/rc: # See if we want to be in user confirmation mode if [ "$previous" = "N" ]; then if [ -f /var/run/confirm ] \ || grep -i confirm /proc/cmdline >/dev/null ; then rm -f /var/run/confirm CONFIRM=yes export CONFIRM echo $"Entering interactive startup" else echo $"Entering non-interactive startup" fi Snippet from /etc/inittab l5:5:wait:/etc/rc.d/rc 5 check disk quotas and enable swap space

46 CIS 191 - Lesson 4 [root@rh9 root]# ls /etc/rc.d/rc5.d K05saslauthd S09isdn S20random S56xinetd S95atd K20nfs S10network S24pcmcia S80sendmail S97rhnsd K24irda S12syslog S25netfs S85gpm S99local K74ntpd S13portmap S26apmd S90crond K95firstboot S14nfslock S28autofs S90cups S05kudzu S17keytable S55sshd S90xfs S08iptables S19vmware-tools S56rawdevices S95anacron [root@rh9 root]# S05 S08 S10 S12 S13 S14 Red Hat 9 Starting Up init – starting services in /etc/rc.d/rc 5 Snippet from /var/log/boot.log Note, no entries before system logging daemon started! Aug 13 12:20:58 rh9 syslog: syslogd startup succeeded Aug 13 12:20:58 rh9 syslog: klogd startup succeeded Aug 13 12:20:58 rh9 portmap: portmap startup succeeded Aug 13 12:20:58 rh9 nfslock: rpc.statd startup succeeded Snippet from /etc/inittab l5:5:wait:/etc/rc.d/rc 5

47 CIS 191 - Lesson 4 [root@rh9 root]# ls /etc/rc.d/rc5.d K05saslauthd S09isdn S20random S56xinetd S95atd K20nfs S10network S24pcmcia S80sendmail S97rhnsd K24irda S12syslog S25netfs S85gpm S99local K74ntpd S13portmap S26apmd S90crond K95firstboot S14nfslock S28autofs S90cups S05kudzu S17keytable S55sshd S90xfs S08iptables S19vmware-tools S56rawdevices S95anacron [root@rh9 root]# S05 S08 S10 S12 S13 S14 Red Hat 9 Starting Up init – starting services in /etc/rc.d/rc 5 Snippet from /etc/inittab l5:5:wait:/etc/rc.d/rc 5 Snippet from: /etc/rc.d/rc5.d/S10network action $"Setting network parameters: " sysctl -e -p /etc/sysctl.conf # bring up loopback interface action $"Bringing up loopback interface: "./ifup ifcfg-lo

48 CIS 191 - Lesson 4 Red Hat 9 Starting Up init – starting services in /etc/rc.d/rc 5 [root@rh9 root]# ls /etc/rc.d/rc5.d K05saslauthd S09isdn S20random S56xinetd S95atd K20nfs S10network S24pcmcia S80sendmail S97rhnsd K24irda S12syslog S25netfs S85gpm S99local K74ntpd S13portmap S26apmd S90crond K95firstboot S14nfslock S28autofs S90cups S05kudzu S17keytable S55sshd S90xfs S08iptables S19vmware-tools S56rawdevices S95anacron [root@rh9 root]# Snippet from /etc/inittab l5:5:wait:/etc/rc.d/rc 5 Snippet from /var/log/boot.log Aug 13 12:20:58 rh9 nfslock: rpc.statd startup succeeded Aug 13 12:20:58 rh9 keytable: Aug 13 12:20:58 rh9 keytable: Loading system font: Aug 13 12:20:58 rh9 keytable: Aug 13 12:20:58 rh9 rc: Starting keytable: succeeded Aug 13 12:20:58 rh9 ifup: iptables: No chain/target/match by that name Aug 13 12:20:58 rh9 network: Bringing up interface eth0: succeeded Aug 13 12:21:00 rh9 random: Initializing random number generator: succeeded Aug 13 12:21:00 rh9 rc: Starting pcmcia: succeeded Aug 13 12:21:01 rh9 netfs: Mounting other filesystems: succeeded Aug 13 12:21:01 rh9 apmd: apmd startup succeeded Aug 13 12:21:01 rh9 autofs: automount startup succeeded Aug 13 12:21:02 rh9 sshd: succeeded Aug 13 12:21:05 rh9 xinetd: xinetd startup succeeded Aug 13 12:21:06 rh9 sendmail: sendmail startup succeeded Aug 13 12:21:06 rh9 sendmail: sm-client startup succeeded Aug 13 12:21:06 rh9 gpm: gpm startup succeeded Aug 13 12:21:07 rh9 crond: crond startup succeeded Aug 13 12:21:09 rh9 cups: cupsd startup succeeded Aug 13 12:21:10 rh9 xfs: xfs startup succeeded Aug 13 12:21:10 rh9 anacron: anacron startup succeeded S14 S17 S95 S80 S26 S19 S90 S85 S20 S24 S25 S55

49 CIS 191 - Lesson 4 Red Hat 9 Starting Up init – starting services in /etc/rc.d/rc 5 Snippet from /etc/inittab l5:5:wait:/etc/rc.d/rc 5 # Run xdm in runlevel 5 x:5:respawn:/etc/X11/prefdm -nodaemon

50 CIS 191 - Lesson 4 [root@rh9 root]# ls /etc/rc.d/rc6.d K03rhnsd K10cups K30sendmail K74ntpd K90network S00killall K05anacron K10xfs K44rawdevices K75netfs K91isdn S01reboot K05atd K15gpm K50xinetd K80random K92iptables K05keytable K20nfs K60crond K86nfslock K95firstboot K05saslauthd K24irda K72autofs K87portmap K95kudzu K08vmware-tools K25sshd K74apmd K88syslog K96pcmcia [root@rh9 root]# Red Hat 9 Rebooting init – stopping services in /etc/rc.d/rc 6 K05 K10 K15 K92 K87 K88 K90 K80 K60 K50 K30 K25 K74 S00 Snippet from /etc/inittab l6:6:wait:/etc/rc.d/rc 6 S01

51 CIS 191 - Lesson 4 Shutting the System Down Sequence: Users log out Services halt Data is saved File systems are unmounted System powers off Example of shutdowns: init 0 – shuts down with no user notification init 6 – reboots with no user notification shutdown +5 Everyone off fast! – notifies users with custom message and shuts down to single user mode halt – stops everything so power switch can be turned off manually reboot – reboots the computers Ctrl-Alt-Del – shutdown behavior can be customized in /etc/inittab

52 CIS 191 - Lesson 4 Shutting the System Down

53 CIS 191 - Lesson 4 Canceling shutdown

54 CIS 191 - Lesson 4 Example shutdown

55 CIS 191 - Lesson 4 Example shutdown

56 CIS 191 - Lesson 4 Example shutdown

57 CIS 191 - Lesson 4 Example shutdown Now enter halt command

58 CIS 191 - Lesson 4 Example halt after shutdown Power switch can be turned off now manually

59 CIS 191 - Lesson 4 Science Experiment From runlevel 5, logged in as root haltshutdown +1 bye bye shutdown –h +1 bye bye poweroffinit 0 rh9broadcast services stopped no command line still powered broadcast services stopped single user mode manual poweroff to end broadcast services stopped powered off broadcast services stopped powered off no broadcast services stopped powered off openSUSE 11 broadcast splash-esc services stopped powered off broadcast TERM > PS'es Single user mode manual poweroff to end broadcast splash-esc services stopped powered off broadcast splash-esc services stopped powered off no broadcast splash-esc services stopped powered off FC9broadcast powered off broadcast single user mode manual poweroff to end broadcast powered off broadcast powered off no broadcast powered off Ubuntu 8.04 broadcast splash screen powered off broadcast stopping services recovery menu single user mode manual poweroff to end broadcast splash screen powered off broadcast splash screen powered off no broadcast splash screen powered off

60 CIS 191 - Lesson 4 New Commands and files

61 CIS 191 - Lesson 4 New commands: chkconfig- show and manage services (daemons) cntl-alt-del- can be configured for shutdown dmesg- shows kernel messages halt- shortcut to shutdown init- change runlevels reboot- shortcut to shutdown runlevel- show previous and current runlevel service- for starting and stopping services (daemons) shutdown- graceful system shutdown New Files and Directories: /etc/inittab- instructions for init program /etc/rc.d/- red hat runlevel directories /sbin/init- primordial init program /var/log/dmesg- kernel bootup messages (rh9, ubuntu) /var/log/boot.log- service startup and shutdown messages (rh9) /var/log/boot.msg- all bootup messages (openSUSE 11) VMware: tbd- tbd

62 CIS 191 - Lesson 4 Red Hat 9 boot & root si::sysinit:/etc/rc.d/rc.sysinit


Download ppt "CIS 191 - Lesson 4 Booting the System. CIS 191 - Lesson 4 Booting the System 1.Power On Self Test (POST) – loads the BIOS. 2.BIOS loads the Master Boot."

Similar presentations


Ads by Google