Table of Contents Previous Chapter Startup/Shutdown.
- ROM monitor may run some simple hardware diagnostics and finds boot device
- ROM monitor loads/runs bootstrap loader
- Bootstrap loader loads/runs kernel (PID 0)
- Kernel may perform more elaborate diagnostics, then checks root file system
- Kernel mounts root file system, then starts init(PID 1)
- Operator may need to switch to multi-user mode
- init runs initialization scripts (rc scripts)
- getty/login produces prompts on terminals (or graphics system starts up) and system is ready to go
This example of the output of System V style ps will help identify these processes.
- Autoboot from power-on
- Boot command from ROM monitor
- Berkeley UNIX has just two operating states: single-user mode and multi-user mode.
- System V has several states, or "run levels"
- Use who -r to see current run level
# who -r
. run-level 2 Mar 5 15:32 2 0 S
Table 6: System V Run Levels
-------------------------------------------------------------------------------------------
Run Level Names and Uses
-------------------------------------------------------------------------------------------
0 Powerdown state; conditions where it is safe to turn the power off.
1 Administrative state.
s or S Single-user mode.
2 Multi-user mode; Normal operating state for isolated,
non-networked systems.
3 Remote File Sharing (RFS) state. Alternative state for networking use. (Normal
multi-user state for OSF/1; other Sys V may use state 2).
4 User-definable state. (Also not normally used; state 2 used instead).
5 Firmware state; Used for some types of maintenance on some systems.
6 Shutdown and reboot state; used to reboot the system from some other running
state (s, 2, 3 or 4) to state 0 then immediately back to normal operating state.
-------------------------------------------------------------------------------------------
The initialization scripts, usually written in Borne shell (BSD, System V) or Korn shell (AIX) perform the following tasks:
- Sets computer's hostname (BSD and some System V)
- Sets time zone (System V only)
- Checks unmounted discs with fsck (only in multi-user mode)
- Mounts the system's disc partitions
- Removes files from the /tmp directory
- Starts up daemons and network services
- Turns on accounting and quotas (if used)
- Configures network interface(s)
- Starts windowing system and window-based login (on graphics workstations)
- /etc/rc (multi-user initialization)
- /etc/rc.local (site-specific initialization)
- /etc/rc.boot (NeXTStep single-user initialization and primary SunOS initialization file)
- /etc/rc.single (under SunOS single-user mode starts shell; under SunOS multi-user mode runs/etc/rc)
- /etc/rc.net, /etc/rc.tcpip, /etc/rc.pci,/etc/rc.ncs (AIX)
Here is an example of a BSD style /etc/rc.local file.
- init reads /etc/inittab to find what to execute
- Initialization files stored in /etc/init.d
- Links made into /etc/rc0.d, /etc/rc2.d, etc.
Here is an example of a simple initialization file, the /etc/init.d/lp file.
- Same as System V, but...
- Initialization files stored in /sbin/init.d
- Links made into /sbin/rc0.d, /sbin/rc2.d, etc.
This diagram shows the process of initialization under System V style Unix.
(WARNING! Never just turn the computer off!)
- Notify users (use wall and/or /etc/motd to announce shutdown, if not done for you)
- Disable logins under BSD (create /etc/nologin, if not done for you by shutdown)
- BSD: shutdown time message
# shutdown +60 "Shutting down for weekly backups"
# shutdown now "There's water coming through the ceiling"
- System V: shutdown -gn -ilevel [-y]
# shutdown -g60 -iS
# shutdown -g0 -i0 -y
- reboot command (BSD, some System V, OSF/1)
- halt command (BSD, some System V, OSF/1)
- Hardware failures
- Power failures/surges
- Environmental problems
- I/O problems (including filled partitions)
- Software problems (kernel faults, bugs, programs)
- Always wait at least ten seconds when power cycling
- Same causes as above
- Errors in initialization scripts
- Improperly configured kernel
Table of Contents Next Chapter