Solaris 启动过程

来源:岁月联盟 编辑:zhu 时间:2008-03-09
Solaris 启动过程内容简介:启动有四个阶段 Boot PROM 阶段 Boot program 阶段 Kernel 初始化阶段 /sbin/init 阶段 启动过程: 自检、显示系统信息、读取启动设备的0扇区、在启动设备寻找启动程序、加载启动程序、启动内核、运行/sbin/init。 /sbin/init程序 启动有四个阶段
  Boot PROM 阶段
  Boot program 阶段
  Kernel 初始化阶段
  /sbin/init 阶段
  
  启动过程:
  自检、显示系统信息、读取启动设备的0扇区、在启动设备寻找启动程序、加载启动程序、启动内核、运行/sbin/init。
  /sbin/init程序
  读取/etc/inittab文件。Init程序执行/sbin/rc*脚本。
  
  系统有多种运行级别,不同的运行级别所启动的服务不同。
  系统运行级别有8种,分别为:
  运行级别 意义
  0 进入PROM状态(OK状态)
  1 管理状态(所有文件系统都挂上的单用户模式,禁止其他用户登录)
  2 多用户模式(没有网络文件共享服务)
  3 多用户模式(有网络文件共享服务)
  4 未使用
  5 退出操作系统并关机
  6 重新启动机器
  S,s 单用户模式
  
  who命令查看运行级别
  # who -r
  . run-level 3 5月 10 17:03 3 0 S
  可得到的信息:当前运行级别是3,系统启动的时间是5月10日17:03.
  
  /etc/inittabinittab定义了:
  系统缺省运行级别
  系统进入新运行级别需要做什么
  
  /etc/init.d目录包含了系统的一些启动脚本
  /etc/rc1.d目录包含进入运行级别1所需要运行的一些脚本
  /etc/rc2.d目录包含进入运行级别2所需要运行的一些脚本
  ...
  ...
  
  这些目录下包含两种文件:
  以K打头,后面跟两个数字以及一些字符串:表示系统到这个运行级别时所需要停止的一些服务,系统将以stop调用这个脚本。
  以S打头,后面跟两个数字以及一些字符串:表示系统到这个运行级别时所需要开始的一些服务,系统将以start调用这个脚本。
  
  增加启动控制脚本
  1.Identify the run level for the service
  2.Determine which services are needed by the new process
  3.Change to /etc/rc#.d and identify startup script
  4.Repeat the process for the directory containing the shutdown script
  5.Create the startup (shutdown) script in /etc/init.d
  6.Create hard links to appropriate /etc/rc#.d directories
  7.test
  
  
  改变运行级别
  init命令用于改变操作系统的运行级别。
  命令格式:
  init [ 0123456Ss ]
  
  # init 0
  INIT: New run level: 0
  The system is coming down. Please wait.
  System services are now being stopped.
  Print services stopped.
  Stopping the syslog service.
  syslogd: going down on signal 15
  Aug 14 14:54:30 snmpdx: received signal 15
  The system is down.
  syncing file systems... done
  Program terminated
  Type help for more information
  ok
  
  shutdown
  用于改变操作系统运行级别。
  命令格式:
  shutdown [ -y ] [ -g seconds ] [ -i init-state ] [message]
  选项:
  y 系统提示时默认回答为YES
  g 过多长时间改变
  i 想要的运行级别
  message 给所有登录用户的信息
  
  # shutdown -y -g 0 -i 0
  Shutdown started. Mon Dec 15 15:13:57 PST 1997
  Broadcast Message from root (console) on mcmurdo Mon Dec
  15 15:13:57...
  THE SYSTEM IS BEING SHUT DOWN NOW ! ! !
  Log off now or risk your files being damaged
  Changing to init state 0 - please wait
  ok
  
  halt
  进入0运行级别
  poweroff
  关闭系统并切断电源
  reboot
  重新启动系统

图片内容