歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Linux Administration Handbook 筆記 startup script

Linux Administration Handbook 筆記 startup script

日期:2017/3/1 11:18:06   编辑:Linux編程

1. Bootstrapping = Booting

Bootstrapping :starting up a computer

During bootstrapping, the kernel is loaded into memory and begins to execute。

step of booting:

1. loading and initialization kernel

Boot Room(BIOS)->MBR->Boot Loader(grub)->Kernel

2. Device detection and configuration

3. Creation of kernel threads

4. Operator intervetion (single-user mode)

通過grub傳給內核single選項,內核通知 init 調用 sulogin,single-user mode 下面登入的是root

5. Execution of system startup scripts

init 運行 startup scripts

6. Multiuser operation

init 運行 getty 等待用戶登錄,如果是圖形界面,還要執行xdm或者gdm

2. init 執行啟動腳本,這些發生在登錄界面出現之前

init 啟動腳本通常叫做 “rc files”,rc 表示 "run command"。

這些腳本的任務有:

設置計算機名,設置時區;

調用fsck檢查磁盤,掛載磁盤,清理/tmp;

配置網絡接口;

啟動daemons和網絡服務;

3. run levels

init 定義了7個run levels:

level 0 is the level in which the system is completely shut down

level 1 or S represents single-user mode

level 2-5 are multiuser levels

level 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

Copyright © Linux教程網 All Rights Reserved