fedora-system

了解ubuntu及fedora啟動方式

ubuntu採用System V init方式
fedora採用systemd及systemctl方式


更新記錄

item note
20160707 第一版

目錄


systemd 與 System V init 比較

item System V init (ubuntu) Systemd(fedora)
init 啟動腳本 一項一項任務依序啟動 服務同時啟動(systemd:服務相依性的自我檢查)
服務相依性 無檢查 systemd 可以自訂服務相依性的檢查
daemon 功能分類 2種(stand alone及super deamon) 多種(service,socket,target..)
runlevel 0,1,2,3,5,6 1,3,5 (?)

linux runlevel

Linux(UNIX)可以分為七種不同啟動模式

level description
0 Halt the system
1 Single-user mode (for special administration)
2 local Multiuser with Networking but without network sevice(like NFS)
3 Full Mulituser with Networking
4 Not Used
5 Full Multiuser with Networking and X Windows(GUI)
6 Reboot

runleve 使用方式

System V (ubuntu) systemd(fedora)
init 0 systemctl poweroff
init 1 systemctl rescue
init [234] systemctl isolate multi-user.target
init 5 systemctl reboot

其它說明

linux啟動流程

  • BIOS 取得第一個可開機裝置,讀取主要開機區 (MBR) 取得開機管理程式
  • 核心主動呼叫 init 程式
  • init 程式開始執行系統初始化: /etc/rc.d/rc.sysinit
  • init 的設定進行 daemon start: /etc/rc.d/rc[0-6].d/*
  • 載入本機設定 (/etc/rc.d/rc.local)

從 CentOS 7.x 以後,Red Hat 系列的 distribution 放棄沿用多年的 System V 開機啟動服務的流程,就是前一小節提到的 init 啟動腳本的方法, 改用 systemd 這個啟動服務管理機制

Linux系統的啟動程序

下面的大致與目前的hisi3535板端相同(除了bios及lilo)

  1. bios
  2. lilo
  3. linux kernel
  4. initi (read /etc/inittab)
  5. /etc/rc.d/rc.sysinit
  6. run level3 or run leve5
  7. Other Programs in /etc/inittab

ubuntu 14.04 inttab

  • man inttab
  • 確定無使用/etc/inttab改由upstart
  • man upstart

fedora系統的啟動程序

  1. bios
  2. mbr boot loader (grub2)
  3. linux kernel: 偵測硬體與載入驅動程式
  4. kernel 會主動呼叫 systemd 程式,並以 default.target 流程開機

查看系統訊息

ubuntu /etc/init.d/README

  • ubuntu 系統版本
1
2
3
4
5
6
7
8
9
erwin@erwin-pc150: /etc
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"
erwin@erwin-pc150: /etc
$ uname -a
Linux erwin-pc150 4.2.0-41-generic #48~14.04.1-Ubuntu SMP Fri Jun 24 17:09:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • /etc/init.d/README

    • 仍採用原本init的方式
1
2
3
4
5
1     Configuration of System V init under Debian GNU/Linux                                                                                                                           
2
3 Most Unix versions have a file here that describes how the scripts
4 in this directory work, and how the links in the /etc/rc?.d/ directories
5 influence system startup/shutdown.

fedora /etc/init.d/README

  • fedora 系統版本
1
2
3
4
[root@localhost /]# cat /etc/redhat-release 
Fedora release 22 (Twenty Two)
[root@localhost /]# uname -a
Linux localhost.localdomain 4.4.13-200.fc22.x86_64 #1 SMP Wed Jun 8 15:59:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • /etc/init.d/README
    • 改採用systemd及systemctl方式
1
2
3
4
5
6
7
8
9
10
You are looking for the traditional init scripts in /etc/rc.d/init.d,
and they are gone?

Here's an explanation on what's going on:

You are running a systemd-based OS where traditional init scripts have
been replaced by native systemd services files. Service files provide
very similar functionality to init scripts. To make use of service
files simply invoke "systemctl", which will output a list of all
currently running services (and other units).

參考來源