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
References
CQU COIT13146 System Administration Course TextbookChapter 13
Lectures2002 #12
Monolithic vs. Microkernels
Source:http://en.wikipedia.org/wiki/Microkernel
BootstrappingStarting the systemProcess of loading kernel into memoryBoot Modes Normal Single User Rescue (on CD)
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
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
Boot ProcessLoad & initialize kernelDetect & configure devicesFork system processes(Stop if Single User mode)Run startup scriptsStart multiuser operations
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
/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
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
Startup ScriptsHostnameTimezoneCheck the hard drivesMount the hard drivesRemove files from /tmpConfigure network interfacesStart daemons and network services
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
/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:
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
Event file directivesexecscriptstart on <event>stop on <event>daemonrespawnservice
“Events”control-alt-deletepower-status-changedstartuprunlevel <runlevel>started <job>stopped <job>
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
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
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
Startup MessagesDisplayed to consoleRedHat – daemon [ ok ]/bin/dmesg History of boot messages Convenient to searchRedHat allows for interactive setup (“i”)
System ShutdownTurn off power – BAD!!!Reboot reboot shutdown –r
Halting the system halt shutdown –h
Changing the Run Level telinit <mode> shutdown –i<mode>
When to ShutdownFailures Maintenance and UpgradesRegularly Scheduled Housecleaning Window for Maintenance/Upgrades
User Notification /etc/motd Email Support web pages