初始化阶段

  1. 内核启动 /etc/init 守护进程(PID 为 1)。

  2. /etc/init 守护进程启动负责启动和停止服务的 svc.startd 进程。

  3. /etc/init 守护进程使用文件 /etc/inittab。
    示例 inittab 文件如下所示:

ap::sysinit:/sbin/autopush -f /etc/iu.ap
sp::sysinit:/sbin/soconfig -f /etc/sock2path 
smf::sysinit:/lib/svc/bin/svc.startd>/dev/msglog 2<>/dev/msglog /dev/msglog 2<>/dev/msglog

如上所示的 init 选项卡文件包含四个字段:

id:rstate:action:process

process 关键字为 action 关键字指定要执行的进程。
例如“/usr/sbin/shutdown -y -i5 -g0”是为“powerfail”动作执行的进程

传统运行级别
运行级别指定特定服务和资源可供用户使用的状态。
以下是 solaris 中可用的运行级别:

0         - system running PROM monitor (ok> prompt)
s or S    - single user mode with critical file-systems mounted.(single user can access the OS)
1         - single user administrative mode with access to all file-systems.(single user can access the OS)
2         - multi-user mode. Multiple users can access the system. NFS and some other network related daemons does not run
3         - multi-user-server mode. Multi user mode with NFS and all other network resources available.
4         - not implemented.
5         - transitional run level. Os is shutdown and system is powered off.
6         - transitional run level. Os is shutdown and system is rebooted to the default run level.

引导程序阶段

  1. mboot 在 FDISK 表中找到活动分区并加载包含 GRUB stage1 的第一个扇区。

  2. GRUB stage1 依次加载 GRUB stage2.

  3. GRUB stage2 定位到GRUB 菜单文件/boot/grub/menu.lst 并显示GRUB 主菜单。

  4. 在这里用户可以选择从分区或者磁盘或者网络启动操作系统。

  5. 执行 /boot/grub/menu.lst 中的 GRUB 命令以加载预先构建的主引导存档(在 solaris 10 中通常为 /platform/i86pc/boot_archive)。

  6. GRUB 加载一个名为 multiboot 的程序,它从 boot_archive 中组装核心内核模块,并通过挂载根文件系统来启动操作系统。

启动 PROM 阶段

  1. BIOS(基本输入输出系统)ROM 运行开机自检(POST)以测试硬件。

  2. BIOS 尝试从启动顺序中提到的设备启动。
    (我们可以通过按 F12 或者 F2 来更改它)。

  3. 从引导盘引导时,BIOS 读取第一个扇区上的主引导程序 (mboot) 和 FDISK 表。

svc.startd 阶段

  1. 内核启动 svc.startd 守护进程后。
    svc.startd 守护进程根据运行级别执行 /sbin 目录中的 rc 脚本。

rc脚本
现在,每个运行级别在 /sbin 目录中都有一个关联的脚本。

# ls -l /sbin/rc?
-rwxr--r--   3 root     sys         1678 Sep 20  2012 /sbin/rc0
-rwxr--r--   1 root     sys         2031 Sep 20  2012 /sbin/rc1
-rwxr--r--   1 root     sys         2046 Sep 20  2012 /sbin/rc2
-rwxr--r--   1 root     sys         1969 Sep 20  2012 /sbin/rc3
-rwxr--r--   3 root     sys         1678 Sep 20  2012 /sbin/rc5
-rwxr--r--   3 root     sys         1678 Sep 20  2012 /sbin/rc6
-rwxr--r--   1 root     sys         4069 Sep 20  2012 /sbin/rcS

每个 rc 脚本运行相应的 /etc/rc?.d/K* 和 /etc/rc?.d/S* 脚本。
例如,对于运行级别 3,以下脚本将由 /sbin/rc3 执行:

/etc/rc3.d/K*
/etc/rc3.d/S*

启动和停止运行脚本的语法是

S##name_of_script - Start run control scripts
K##name_of_scrips - Stop run control scripts

注意大写中的 S 和 K。
以小 s 和 k 开头的脚本将被忽略。
这可用于禁用该特定运行级别的脚本。

Solaris 10 x86/x64引导过程

x86/x64 硬件上的引导过程与 SPARC 硬件略有不同。
x86/x64 硬件也涉及 5 步引导过程,与 SPARC 硬件相同。

更多: zhilu jiaocheng

内核初始化阶段

1.内核读取配置文件/etc/system。

  1. 内核初始化自身并加载内核模块。
    这些模块通常位于 /kernel 和 /usr/kernel 目录中。
    (平台特定的驱动程序在 /platform/‘uname -i‘/kernel 和 /platform/‘uname -m‘/kernel 目录)
日期:2020-09-17 00:15:17 来源:oir作者:oir