23
UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Embed Size (px)

DESCRIPTION

References CQU COIT13146 System Administration Course Textbook  Chapter 13 Chapter 13 Lectures  2002 # #12

Citation preview

Page 1: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

UNIX Startup and Shutdown

CSCI N321 – System and Network Administration

Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Page 2: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Section Overview

BootstrappingStartup Scripts and Run LevelsBoot Configuration and TroubleshootingSystem Shutdown

Page 4: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Monolithic vs. Microkernels

Source:http://en.wikipedia.org/wiki/Microkernel

Page 5: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

BootstrappingStarting the systemProcess of loading kernel into memoryBoot Modes Normal Single User Rescue (on CD)

Page 6: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

RedHat Boot Process

BIOSBIOS

LoginLoginShellShell

GRUBGRUB

/etc/inittab/etc/inittab

Source: http://nmc.nchu.edu.tw/linux/Linux_boot.htm

LinuxLinuxKernelKernel initinit

/etc/rc.d//etc/rc.d/rc.sysinitrc.sysinit

/etc/rc.d/rc/etc/rc.d/rc

RL SpecificRL Specific/etc/inittab/etc/inittab

/etc/rc.d//etc/rc.d/rc3.drc3.d

/etc/rc.d//etc/rc.d/rc5.drc5.d

Page 7: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Fedora Boot Process

BIOSBIOS

LoginLoginShellShell

GRUBGRUB

/etc/inittab/etc/inittab

Source: http://nmc.nchu.edu.tw/linux/Linux_boot.htm

LinuxLinuxKernelKernel initinit /etc//etc/

event.d/*event.d/* RL SpecificRL Specific

/etc/rc.d//etc/rc.d/rc3.drc3.d

/etc/rc.d//etc/rc.d/rc5.drc5.d

Page 8: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Boot ProcessLoad & initialize kernelDetect & configure devicesFork system processes(Stop if Single User mode)Run startup scriptsStart multiuser operations

Page 9: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Boot LoaderROM loads boot program from diskBoot program finds/loads kernel

Checks available memory Initializes kernel internal data structures

GRand Unified Bootloader (GRUB) Can boot multiple OS Boot options can be edited at boot

Linux Boot Loader (LILO) Can boot multiple OS Single User: linux single Rescue: linux rescue

Page 10: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

/etc/grub.confdefault=1timeout=10splashimage=(hd0,5)/boot/grub/splash.xpm.gztitle Fedora Core - N321 (2.6.11-1.1369_FC4)

root (hd0,5) kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/1 rhgb quiet initrd

/boot/initrd-2.6.11-1.1369_FC4.imgtitle Windows XP

rootnoverify (hd0,0)chainloader +1

title Red Hat Enterprise WS (2.6.9-11.EL) rootnoverify (hd0,4) kernel /boot/vmlinuz-2.6.9-11.EL ro root=LABEL=/ rhgb quiet initrd

/boot/initrd-2.6.9-11.EL.img

Page 11: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

System ProcessesBSD Systems swapper – PID 0 init – PID 1 pagedaemon – PID 2AT&T SVR4 sched – PID 0 (invisible under RedHat) init – PID 1 /etc/inittab

Page 12: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Startup ScriptsHostnameTimezoneCheck the hard drivesMount the hard drivesRemove files from /tmpConfigure network interfacesStart daemons and network services

Page 13: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

BSD /etc/rc* Scripts/etc/rc Master script Executes supplemental scriptsExample supplemental scripts (freeBSD) /etc/defaults/rc.conf /etc/rc.conf /etc/rc.conf.local

Page 14: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

/etc/inittab

Initializes system for useFormat: id:rl:action:process id: uniquely identifies entry rl: Run level entry applies to action: How to execute process process: process command lineEx: Setting the default Runlevel:id:3:initdefault:

Page 15: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Startup Run LevelsSolarisSolaris RedHatRedHat ModeMode1 (S) 1 (S) Single user

2 2 Multiuser (no networking)

3 3 Full Multiuser4 4 Unused5 Power-off shutdown

5 X116 6 Reboot0 0 Halt

Page 16: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Event file directivesexecscriptstart on <event>stop on <event>daemonrespawnservice

Page 17: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

“Events”control-alt-deletepower-status-changedstartuprunlevel <runlevel>started <job>stopped <job>

Page 18: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Virtual ConsolesStarted in /etc/event.d/tty[1-6]:Example (tty2):start on stopped rc2start on stopped rc3start on stopped rc4start on started prefdm

stop on runlevel 0stop on runlevel 1stop on runlevel 6

respawnexec /sbin/mingetty tty2

Page 19: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Started in /etc/event.d/rc[0-6,S]:Example (rc3):start on runlevel 3stop on runlevel [!3]console outputscript set $(runlevel --set 3 || true) if [ "$1" != "unknown" ]; then PREVLEVEL=$1 RUNLEVEL=$2 export PREVLEVEL RUNLEVEL fi exec /etc/rc.d/rc 3end script

Strarting/Stopping Run Levels

Page 20: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Run Level ScriptsActual scripts - /etc/rc.d/init.d//etc/rc.d/rc#.d/ Symbolic links to /etc/init.d scripts S## - Start scripts K## - Stop scripts /etc/sysconfig/ - script configuration fileschkconfig <script> on|offservice <script> start|stop|restart

Page 21: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

Startup MessagesDisplayed to consoleRedHat – daemon [ ok ]/bin/dmesg History of boot messages Convenient to searchRedHat allows for interactive setup (“i”)

Page 22: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

System ShutdownTurn off power – BAD!!!Reboot reboot shutdown –r

Halting the system halt shutdown –h

Changing the Run Level telinit <mode> shutdown –i<mode>

Page 23: UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University

When to ShutdownFailures Maintenance and UpgradesRegularly Scheduled Housecleaning Window for Maintenance/Upgrades

User Notification /etc/motd Email Support web pages