Welcome 微信登录

首页 / 操作系统 / Linux / Linux Administration Handbook 笔记 startup script

1. Bootstrapping = BootingBootstrapping :starting up a computerDuring bootstrapping, the kernel is loaded into memory and begins to execute。step of booting:1. loading and initialization kernelBoot Room(BIOS)->MBR->Boot Loader(grub)->Kernel2. Device detection and configuration3. Creation of kernel threads4. Operator intervetion (single-user mode)通过grub传给内核single选项,内核通知 init 调用 sulogin,single-user mode 下面登入的是root5. Execution of system startup scriptsinit 运行 startup scripts6. Multiuser operationinit 运行 getty 等待用户登录,如果是图形界面,还要执行xdm或者gdm2. init 执行启动脚本,这些发生在登录界面出现之前init 启动脚本通常叫做 “rc files”,rc 表示 "run command"。这些脚本的任务有:设置计算机名,设置时区;调用fsck检查磁盘,挂载磁盘,清理/tmp;配置网络接口;启动daemons和网络服务;3. run levelsinit 定义了7个run levels:level 0 is the level in which the system is completely shut downlevel 1 or S represents single-user modelevel 2-5 are multiuser levelslevel 6 is a "reboot" level各个run level 要做的都定义在 /etc/inittab 中,其中可以定义系统默认的run level,不同的发行版本,它的格式有可能不同。在切换 run level 的时候,init 会执行 /etc/init.d/rc,它会执行其他和run level 相关的目录中的脚本,使系统达到新的run level,之后会查看rc*.d(*表示新的run level号)rc*.d中的包含的是符号链接 链接到/etc/init.d目录中的脚本,这些脚本都是以K或S,加上数字 开头,如下图。当系统run level 从低-->高转变时,运行以S开头的脚本,并且以数字升序执行,并传以start参数;当从高-->低转变时,运行K开头的脚本,并以数字降序执行,并传以stop参数。新的启动管理器:上面的内容可能有地那过时,Ubuntu 10.04之后使用upstart,RedHat 也将要用init的替代者 systemd