【Linux】CentOS 7開機啟動過程和關機過程


 

 bootup - 系統啟動過程

描述

系統引導涉及許多不同的組件。開機后,系統BIOS將完成最小的硬件初始化,並將控制交給存儲在持久存儲設備上的引導加載程序。然后,這個引導加載程序將從磁盤(或網絡)調用OS內核。在Linux環境下,這個內核(可選)提取並執行一個初始RAM磁盤映像(Initrd),例如由Dracut(8)生成的,它查找根文件系統(可能為此使用systemd)。在找到並掛載根文件系統之后,initrd將控制交給存儲在OS映像上的主機的系統管理器(例如systemd),然后該管理器負責檢測所有剩余的硬件,掛載所有必要的文件系統並生成所有配置的服務。

在關閉時,系統管理器停止所有服務,卸載所有文件系統(卸載支持它們的存儲技術),然后(可選)跳回到initrd卸載根文件系統及其駐留的存儲。最后,關閉系統。

系統管理器啟動

在啟動時,OS映像上的系統管理器負責初始化系統運行所需的文件系統、服務和驅動程序。對於systemd系統來說,這個過程被划分為幾個階段性步驟。 在每個階段性步驟內部,任務是高度並行的,所以無法准確預測其中的單元的順序,但是不同階段之間的先后順序總是固定的。

當systemd啟動系統時,它將激活default.Target的所有依賴項(以及遞歸地激活這些依賴項的所有依賴項)。通常,default.Target只是Graphical.Target或Multi-user.Target的別名,這取決於系統是配置為圖形用戶界面,還是配置為文本控制台。為了強制啟動流程的規范性以及提高單元的並行性,預先定義了一些具有特定含義的 target 單元。

下面的圖表解釋了這些具有特定含義的 target 單元之間的依賴關系以及各自在啟動流程中的位置。 圖中的箭頭表示了單元之間的依賴關系與先后順序,整個圖表按照自上而下的時間順序執行。

重點標識的目標單元經常被用作啟動目標。有兩種方法可以指定啟動目標: (1)使用 systemd.unit= 內核命令行參數(參見systemd手冊);(2)使用 default.target 軟連接。

因為 timers.target 以異步方式包含在 basic.target 中,所以 timer 單元可以依賴於在 basic.target 之后才啟動的服務。

initrd 啟動過程

初始的RAM磁盤實現(Initrd)也可以使用systemd來設置。在本例中,initrd內部的引導遵循以下結構。

在initrd內部,也可以將 systemd 用作init程序(由"rdinit="內核引導參數指定),此時 initrd.target 將是默認目標。initrd內部啟動流程的上半部分與前一小節 basic.target 之前的部分完全相同,隨后的啟動流程將如下圖所示。 如果成功的將根文件系統掛載到 /sysroot 目錄,那么 sysroot.mount 單元將被激活,然后進一步激活 initrd-root-fs.target 目標。 initrd-parse-etc.service 將會分析 /sysroot/etc/fstab 文件以掛載 /usr (若需要)與帶有 x-initrd.mount 標記的掛載點。 這些掛載點都將被掛載到 /sysroot 之下,然后流程到達 initrd-fs.target 目標。 再接下來 initrd-cleanup.service 將會使用 /usr/bin/systemctl --no-block isolate initrd-switch-root.target 命令啟動 initrd-switch-root.target 目標。因為 isolate 表示立即停止所有在新的目標單元中不需要的進程, 所以此動作實際上是為接下來切換根目錄做預先的准備(也就是清理環境)。 最后,激活 initrd-switch-root.service 服務,將系統的根目錄切換至 /sysroot 目錄。 (之前的流程與上一小節完全相同) :

​​切換到主機上的操作系統

關機過程

systemd 系統在關機時同樣遵循固定的流程,具體如下圖所示:

​ 

要查看具體的啟動順序可以通過如下命令輸入到文件,然后通過瀏覽器打開查看。

systemd-analyze plot > boot.html

列出所有正在運行的單元,按從初始化開始到啟動所花的時間排序。

systemd-analyze blame

 

下面通過查看日志分析啟動過程:

 

##調用kernel:

Oct 14 16:59:56 localhost kernel: Linux version 4.18.11-1.el7.elrepo.x86_64 (mockbuild@Build64R7) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)) #1 SMP Sat Sep 29 09:42:38 EDT 2018

Oct 14 16:59:56 localhost kernel: Command line: BOOT_IMAGE=/vmlinuz-4.18.11-1.el7.elrepo.x86_64 root=/dev/mapper/rootvg-root ro rd.lvm.lv=rootvg/root rd.lvm.lv=rootvg/swap rhgb quiet

… …

Oct 14 16:59:56 localhost kernel: SMBIOS 2.5 present.

Oct 14 16:59:56 localhost kernel: tsc: Detected 2491.908 MHz processor

Oct 14 16:59:56 localhost kernel: acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5

Oct 14 16:59:56 localhost kernel: SCSI subsystem initialized

##提取initramfs:

Oct 14 16:59:56 localhost kernel: Unpacking initramfs...

Oct 14 16:59:56 localhost kernel: Freeing initrd memory: 29564K

 

Oct 14 16:59:56 localhost kernel: Block layer SCSI generic (bsg) driver version 0.4 loaded (major 247)

Oct 14 16:59:56 localhost kernel: ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver

Oct 14 16:59:56 localhost kernel: ehci-pci: EHCI PCI platform driver

Oct 14 16:59:56 localhost kernel: ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver

Oct 14 16:59:56 localhost kernel: ohci-pci: OHCI PCI platform driver

##使用initramfs啟動systemd:

Oct 14 16:59:56 localhost systemd[1]: systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN)

Oct 14 16:59:56 localhost systemd[1]: Detected virtualization kvm.

Oct 14 16:59:56 localhost systemd[1]: Detected architecture x86-64.

Oct 14 16:59:56 localhost systemd[1]: Running in initial RAM disk.

Oct 14 16:59:56 localhost systemd[1]: Set hostname to <localhost.localdomain>.

##到達swap.target:

Oct 14 16:59:56 localhost systemd[1]: Reached target Swap.

Oct 14 16:59:56 localhost systemd[1]: Starting Swap.

Oct 14 16:59:56 localhost systemd[1]: Reached target Local File Systems.

Oct 14 16:59:56 localhost systemd[1]: Starting Local File Systems.

Oct 14 16:59:56 localhost systemd[1]: Created slice -.slice.

Oct 14 16:59:57 localhost systemd: Started Setup Virtual Console.

Oct 14 16:59:57 localhost systemd: Started dracut cmdline hook.

Oct 14 16:59:57 localhost systemd: Starting dracut pre-udev hook...

Oct 14 16:59:58 localhost kernel: device-mapper: uevent: version 1.0.3

Oct 14 16:59:58 localhost systemd: Started dracut pre-udev hook.

Oct 14 16:59:58 localhost systemd: Starting udev Kernel Device Manager...

Oct 14 16:59:58 localhost systemd-udevd: starting version 219

Oct 14 16:59:58 localhost systemd: Started udev Kernel Device Manager.

Oct 14 16:59:58 localhost systemd: Started dracut pre-trigger hook.

Oct 14 16:59:58 localhost systemd: Starting udev Coldplug all Devices...

Oct 14 16:59:58 localhost systemd: Started udev Coldplug all Devices.

##到達sysinit.target:

Oct 14 16:59:58 localhost systemd: Reached target System Initialization.

Oct 14 16:59:58 localhost systemd: Starting System Initialization.

Oct 14 16:59:58 localhost systemd: Starting dracut initqueue hook...

Oct 14 16:59:58 localhost systemd: Starting Show Plymouth Boot Screen...

Oct 14 16:59:58 localhost systemd: Mounting Configuration File System...

Oct 14 16:59:58 localhost systemd: Mounted Configuration File System.

Oct 14 16:59:58 localhost systemd: Started Show Plymouth Boot Screen.

Oct 14 16:59:58 localhost systemd: Reached target Paths.

Oct 14 16:59:58 localhost systemd: Starting Paths.

##到達basic.target:

Oct 14 16:59:58 localhost systemd: Reached target Basic System.

Oct 14 16:59:58 localhost systemd: Starting Basic System.

Oct 14 16:59:58 localhost kernel: scsi host2: ahci

Oct 14 16:59:58 localhost kernel: scsi host3: ahci

Oct 14 16:59:59 localhost kernel: scsi 3:0:0:0: Direct-Access     ATA      VBOX HARDDISK    1.0  PQ: 0 ANSI: 5

Oct 14 16:59:59 localhost kernel: sd 2:0:0:0: [sda] 16777216 512-byte logical blocks: (8.59 GB/8.00 GiB)

Oct 14 16:59:59 localhost kernel: sd 2:0:0:0: [sda] Write Protect is off

Oct 14 16:59:59 localhost kernel: sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA

Oct 14 16:59:59 localhost kernel: sda: sda1 sda2

Oct 14 16:59:59 localhost kernel: sd 2:0:0:0: [sda] Attached SCSI disk

Oct 14 17:00:00 localhost systemd: Found device /dev/mapper/rootvg-root.

Oct 14 17:00:00 localhost systemd: Starting File System Check on /dev/mapper/rootvg-root...

Oct 14 17:00:00 localhost kernel: random: crng init done

Oct 14 17:00:00 localhost kernel: random: 7 urandom warning(s) missed due to ratelimiting

Oct 14 17:00:00 localhost systemd-fsck: /dev/mapper/rootvg-root: clean, 144286/426544 files, 1062697/1705984 blocks

Oct 14 17:00:00 localhost systemd: Started File System Check on /dev/mapper/rootvg-root.

Oct 14 17:00:01 localhost systemd: Started dracut initqueue hook.

Oct 14 17:00:01 localhost systemd: Reached target Remote File Systems (Pre).

Oct 14 17:00:01 localhost systemd: Starting Remote File Systems (Pre).

Oct 14 17:00:01 localhost systemd: Reached target Remote File Systems.

Oct 14 17:00:01 localhost systemd: Starting Remote File Systems.

Oct 14 17:00:01 localhost systemd: Started dracut pre-mount hook.

##將真實的根掛載到/sysroot:

Oct 14 17:00:01 localhost systemd: Mounting /sysroot...

Oct 14 17:00:01 localhost kernel: EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: (null)

Oct 14 17:00:01 localhost systemd: Mounted /sysroot.

##到達initrrd_root_fs.target:

Oct 14 17:00:01 localhost systemd: Reached target Initrd Root File System.

Oct 14 17:00:01 localhost systemd: Starting Initrd Root File System.

Oct 14 17:00:01 localhost systemd: Starting Reload Configuration from the Real Root...

Oct 14 17:00:01 localhost systemd: Reloading.

Oct 14 17:00:01 localhost systemd: Started Reload Configuration from the Real Root.

Oct 14 17:00:01 localhost systemd: Started dracut mount hook.

Oct 14 17:00:01 localhost systemd: Reached target Initrd File Systems.

Oct 14 17:00:01 localhost systemd: Starting Initrd File Systems.

##到達initrd.target,清理環境為切根做准備,按照啟動時相反的順序停止target:

Oct 14 17:00:01 localhost systemd: Reached target Initrd Default Target.

Oct 14 17:00:01 localhost systemd: Starting Initrd Default Target.

Oct 14 17:00:01 localhost systemd: Starting dracut pre-pivot and cleanup hook...

Oct 14 17:00:01 localhost systemd: Started dracut pre-pivot and cleanup hook.

Oct 14 17:00:01 localhost systemd: Starting Cleaning Up and Shutting Down Daemons...

Oct 14 17:00:01 localhost systemd: Stopped Cleaning Up and Shutting Down Daemons.

Oct 14 17:00:01 localhost systemd: Stopped dracut pre-pivot and cleanup hook.

Oct 14 17:00:01 localhost systemd: Stopping dracut pre-pivot and cleanup hook...

Oct 14 17:00:01 localhost systemd: Stopped target Remote File Systems.

Oct 14 17:00:01 localhost systemd: Stopping Remote File Systems.

Oct 14 17:00:02 localhost systemd: Stopped target Remote File Systems (Pre).

Oct 14 17:00:02 localhost systemd: Stopping Remote File Systems (Pre).

Oct 14 17:00:02 localhost systemd: Stopped dracut initqueue hook.

Oct 14 17:00:02 localhost systemd: Stopping dracut initqueue hook...

Oct 14 17:00:02 localhost systemd: Starting Plymouth switch root service...

Oct 14 17:00:02 localhost systemd: Stopped target Initrd Default Target.

Oct 14 17:00:02 localhost systemd: Stopping Initrd Default Target.

Oct 14 17:00:02 localhost systemd: Stopped target Basic System.

Oct 14 17:00:02 localhost systemd: Stopping Basic System.

Oct 14 17:00:02 localhost systemd: Stopped target System Initialization.

Oct 14 17:00:02 localhost systemd: Stopping System Initialization.

Oct 14 17:00:02 localhost systemd: Stopped udev Kernel Device Manager.

Oct 14 17:00:02 localhost systemd: Stopped Create Static Device Nodes in /dev.

Oct 14 17:00:02 localhost systemd: Stopping Create Static Device Nodes in /dev...

Oct 14 17:00:02 localhost systemd: Stopped Create list of required static device nodes for the current kernel.

Oct 14 17:00:02 localhost systemd: Stopping Create list of required static device nodes for the current kernel...

Oct 14 17:00:02 localhost systemd: Stopped udev Coldplug all Devices.

Oct 14 17:00:02 localhost systemd: Stopping udev Coldplug all Devices...

Oct 14 17:00:02 localhost systemd: Stopped target Paths.

Oct 14 17:00:02 localhost systemd: Stopping Paths.

Oct 14 17:00:02 localhost systemd: Stopped target Sockets.

Oct 14 17:00:02 localhost systemd: Stopping Sockets.

Oct 14 17:00:02 localhost systemd: Closed udev Kernel Socket.

Oct 14 17:00:02 localhost systemd: Stopping udev Kernel Socket.

Oct 14 17:00:02 localhost systemd: Stopped target Slices.

Oct 14 17:00:02 localhost systemd: Stopping Slices.

Oct 14 17:00:02 localhost systemd: Stopped target Local File Systems.

Oct 14 17:00:02 localhost systemd: Stopping Local File Systems.

Oct 14 17:00:02 localhost systemd: Closed udev Control Socket.

Oct 14 17:00:02 localhost systemd: Stopping udev Control Socket.

Oct 14 17:00:02 localhost systemd: Starting Cleanup udevd DB...

Oct 14 17:00:02 localhost systemd: Stopped target Swap.

Oct 14 17:00:02 localhost systemd: Stopping Swap.

Oct 14 17:00:02 localhost systemd: Stopped target Timers.

Oct 14 17:00:02 localhost systemd: Stopping Timers.

Oct 14 17:00:02 localhost systemd: Stopped dracut pre-udev hook.

Oct 14 17:00:02 localhost systemd: Stopping dracut pre-udev hook...

Oct 14 17:00:02 localhost systemd: Stopped dracut cmdline hook.

Oct 14 17:00:02 localhost systemd: Stopping dracut cmdline hook...

Oct 14 17:00:02 localhost systemd: Stopped Apply Kernel Variables.

Oct 14 17:00:02 localhost systemd: Stopping Apply Kernel Variables...

Oct 14 17:00:02 localhost systemd: Started Cleanup udevd DB.

##環境清理完成,到達initrd-switch-root.target:

Oct 14 17:00:02 localhost systemd: Reached target Switch Root.

Oct 14 17:00:02 localhost systemd: Starting Switch Root.

Oct 14 17:00:02 localhost systemd: Started Plymouth switch root service.

Oct 14 17:00:02 localhost systemd: Starting Switch Root...

Oct 14 17:00:02 localhost systemd: Switching root.

Oct 14 17:00:02 localhost journal: Journal stopped

Oct 14 17:00:07 localhost systemd-journald[132]: Received SIGTERM from PID 1 (systemd).

Oct 14 17:00:07 localhost kernel: systemd: 27 output lines suppressed due to ratelimiting

Oct 14 17:00:07 localhost kernel: SELinux:  Disabled at runtime.

Oct 14 17:00:07 localhost systemd[1]: Inserted module 'ip_tables'

Oct 14 17:00:07 localhost journal: Journal started

##切根完成,使用真實的根啟動systemd:

Oct 14 17:00:07 localhost systemd: systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN)

Oct 14 17:00:07 localhost systemd: Detected virtualization kvm.

Oct 14 17:00:07 localhost systemd: Detected architecture x86-64.

Oct 14 17:00:07 localhost systemd: Set hostname to <localhost.localdomain>.

Oct 14 17:00:07 localhost systemd: Mounted Debug File System.

Oct 14 17:00:07 localhost systemd: Starting Create Static Device Nodes in /dev...

Oct 14 17:00:07 localhost kernel: EXT4-fs (dm-0): re-mounted. Opts: (null)

Oct 14 17:00:07 localhost systemd: Started Remount Root and Kernel File Systems.

Oct 14 17:00:07 localhost systemd: Started Rebuild Dynamic Linker Cache.

Oct 14 17:00:07 localhost systemd: Starting Load/Save Random Seed...

Oct 14 17:00:07 localhost systemd: Started Rebuild Hardware Database.

Oct 14 17:00:07 localhost systemd: Starting udev Coldplug all Devices...

Oct 14 17:00:07 localhost systemd: Starting Flush Journal to Persistent Storage...

Oct 14 17:00:07 localhost systemd: Starting Configure read-only root support...

Oct 14 17:00:07 localhost systemd: Started First Boot Wizard.

Oct 14 17:00:07 localhost systemd: Started Apply Kernel Variables.

Oct 14 17:00:07 localhost systemd: Started Load/Save Random Seed.

Oct 14 17:00:07 localhost systemd: Started LVM2 metadata daemon.

Oct 14 17:00:07 localhost systemd: Starting LVM2 metadata daemon...

Oct 14 17:00:08 localhost systemd: Started udev Coldplug all Devices.

Oct 14 17:00:08 localhost systemd: Starting udev Wait for Complete Device Initialization...

Oct 14 17:00:08 localhost systemd: Started Flush Journal to Persistent Storage.

Oct 14 17:00:08 localhost kernel: RPC: Registered named UNIX socket transport module.

Oct 14 17:00:08 localhost kernel: RPC: Registered udp transport module.

Oct 14 17:00:08 localhost kernel: RPC: Registered tcp transport module.

Oct 14 17:00:08 localhost kernel: RPC: Registered tcp NFSv4.1 backchannel transport module.

Oct 14 17:00:08 localhost systemd: Mounted RPC Pipe File System.

Oct 14 17:00:08 localhost systemd: Started Configure read-only root support.

Oct 14 17:00:08 localhost systemd: Started Load legacy module configuration.

Oct 14 17:00:08 localhost kernel: Installing knfsd (copyright (C) 1996 okir@monad.swb.de).

Oct 14 17:00:08 localhost systemd: Mounted NFSD configuration filesystem.

Oct 14 17:00:08 localhost lvm: 2 logical volume(s) in volume group "rootvg" monitored

Oct 14 17:00:09 localhost systemd: Started Create Static Device Nodes in /dev.

Oct 14 17:00:09 localhost systemd: Starting udev Kernel Device Manager...

Oct 14 17:00:09 localhost systemd: Reached target Local File Systems (Pre).

Oct 14 17:00:09 localhost systemd: Starting Local File Systems (Pre).

Oct 14 17:00:09 localhost systemd-udevd: starting version 219

Oct 14 17:00:09 localhost systemd: Started udev Kernel Device Manager.

Oct 14 17:00:11 localhost systemd: Created slice system-lvm2\x2dpvscan.slice.

Oct 14 17:00:11 localhost systemd: Starting system-lvm2\x2dpvscan.slice.

Oct 14 17:00:11 localhost systemd: Starting LVM2 PV scan on device 8:16...

Oct 14 17:00:11 localhost systemd: Found device /dev/mapper/rootvg-swap.

Oct 14 17:00:11 localhost systemd: Found device VBOX_HARDDISK 1.

Oct 14 17:00:11 localhost systemd: Starting File System Check on /dev/disk/by-uuid/c701b704-6af7-4cc8-ba8f-5050b589faf2...

Oct 14 17:00:11 localhost systemd: Starting LVM2 PV scan on device 8:2...

Oct 14 17:00:11 localhost systemd: Activating swap /dev/mapper/rootvg-swap...

Oct 14 17:00:11 localhost lvm: 2 logical volume(s) in volume group "rootvg" now active

Oct 14 17:00:11 localhost systemd: Started LVM2 PV scan on device 8:2.

Oct 14 17:00:11 localhost kernel: Adding 1048572k swap on /dev/mapper/rootvg-swap.  Priority:-2 extents:1 across:1048572k FS

Oct 14 17:00:11 localhost systemd: Activated swap /dev/mapper/rootvg-swap.

Oct 14 17:00:11 localhost systemd: Reached target Swap.

Oct 14 17:00:11 localhost systemd: Starting Swap.

Oct 14 17:00:11 localhost lvm: 1 logical volume(s) in volume group "datavg" now active

Oct 14 17:00:11 localhost systemd: Started LVM2 PV scan on device 8:16.

Oct 14 17:00:11 localhost systemd: Found device /dev/mapper/datavg-lv_data.

Oct 14 17:00:11 localhost systemd: Starting File System Check on /dev/mapper/datavg-lv_data...

Oct 14 17:00:11 localhost systemd: Started udev Wait for Complete Device Initialization.

Oct 14 17:00:11 localhost systemd: Starting Activation of DM RAID sets...

Oct 14 17:00:12 localhost systemd-fsck: /dev/sda1: clean, 699/128016 files, 160136/512000 blocks

Oct 14 17:00:12 localhost systemd: Started File System Check on /dev/disk/by-uuid/c701b704-6af7-4cc8-ba8f-5050b589faf2.

Oct 14 17:00:12 localhost kernel: EXT4-fs (dm-2): mounted filesystem with ordered data mode. Opts: (null)

Oct 14 17:00:12 localhost systemd: Mounting /boot...

Oct 14 17:00:12 localhost kernel: EXT4-fs (sda1): mounting ext3 file system using the ext4 subsystem

Oct 14 17:00:12 localhost systemd: Started Activation of DM RAID sets.

Oct 14 17:00:12 localhost systemd: Reached target Encrypted Volumes.

Oct 14 17:00:12 localhost systemd: Starting Encrypted Volumes.

Oct 14 17:00:12 localhost kernel: EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)

Oct 14 17:00:12 localhost systemd: Mounted /boot.

Oct 14 17:00:12 localhost systemd: Reached target Local File Systems.

Oct 14 17:00:12 localhost systemd: Starting Local File Systems.

Oct 14 17:00:12 localhost systemd: Starting Tell Plymouth To Write Out Runtime Data...

Oct 14 17:00:12 localhost systemd: Starting Import network configuration from initramfs...

Oct 14 17:00:12 localhost systemd: Started Reconfigure the system on administrator request.

Oct 14 17:00:12 localhost systemd: Started Commit a transient machine-id on disk.

Oct 14 17:00:12 localhost systemd: Started Relabel all filesystems, if necessary.

Oct 14 17:00:12 localhost systemd: Starting Preprocess NFS configuration...

Oct 14 17:00:12 localhost systemd: Started Mark the need to relabel after reboot.

Oct 14 17:00:12 localhost systemd: Started Rebuild Journal Catalog.

Oct 14 17:00:12 localhost systemd: Started Update is Completed.

Oct 14 17:00:12 localhost systemd: Started Preprocess NFS configuration.

Oct 14 17:00:12 localhost systemd: Started Tell Plymouth To Write Out Runtime Data.

Oct 14 17:00:12 localhost systemd: Started Import network configuration from initramfs.

Oct 14 17:00:12 localhost systemd: Starting Create Volatile Files and Directories...

Oct 14 17:00:12 localhost systemd: Started Create Volatile Files and Directories.

Oct 14 17:00:12 localhost systemd: Starting Security Auditing Service...

Oct 14 17:00:13 localhost systemd: Started Security Auditing Service.

Oct 14 17:00:13 localhost systemd: Starting Update UTMP about System Boot/Shutdown...

Oct 14 17:00:13 localhost systemd: Started Update UTMP about System Boot/Shutdown.

##到達sysinit.target,激活timers.target,paths.target,sockets.target:

Oct 14 17:00:13 localhost systemd: Reached target System Initialization.

Oct 14 17:00:13 localhost systemd: Starting System Initialization.

Oct 14 17:00:13 localhost systemd: Started Daily Cleanup of Temporary Directories.

Oct 14 17:00:13 localhost systemd: Starting Daily Cleanup of Temporary Directories.

Oct 14 17:00:13 localhost systemd: Reached target Timers.

Oct 14 17:00:13 localhost systemd: Starting Timers.

Oct 14 17:00:13 localhost systemd: Listening on D-Bus System Message Bus Socket.

Oct 14 17:00:13 localhost systemd: Starting D-Bus System Message Bus Socket.

Oct 14 17:00:13 localhost systemd: Reached target Paths.

Oct 14 17:00:13 localhost systemd: Starting Paths.

Oct 14 17:00:13 localhost systemd: Listening on RPCbind Server Activation Socket.

Oct 14 17:00:13 localhost systemd: Starting RPCbind Server Activation Socket.

Oct 14 17:00:13 localhost systemd: Reached target Sockets.

Oct 14 17:00:13 localhost systemd: Starting Sockets.

##到達basic.target,激活multi-user.target或graphical.target:

Oct 14 17:00:13 localhost systemd: Reached target Basic System.

Oct 14 17:00:13 localhost systemd: Starting Basic System.

Oct 14 17:00:13 localhost systemd: Started OpenSSH Server Key Generation.

Oct 14 17:00:13 localhost systemd: Starting firewalld - dynamic firewall daemon...

Oct 14 17:00:13 localhost systemd: Starting System Logging Service...

Oct 14 17:00:13 localhost systemd: Starting Kernel Samepage Merging...

Oct 14 17:00:17 localhost systemd: Starting D-Bus System Message Bus...

Oct 14 17:00:17 localhost systemd: Started Load CPU microcode update.

Oct 14 17:00:17 localhost systemd: Starting Login Service...

Oct 14 17:00:17 localhost systemd: Starting NTP client/server...

Oct 14 17:00:17 localhost systemd: Started Software RAID monitoring and management.

Oct 14 17:00:17 localhost systemd: Starting Dump dmesg to /var/log/dmesg...

Oct 14 17:00:17 localhost systemd: Starting Modem Manager...

Oct 14 17:00:17 localhost systemd: Started irqbalance daemon.

Oct 14 17:00:17 localhost systemd: Starting irqbalance daemon...

Oct 14 17:00:17 localhost systemd-logind: New seat seat0.

Oct 14 17:00:18 localhost systemd: Started Dump dmesg to /var/log/dmesg.

Oct 14 17:00:18 localhost systemd: Started Login Service.

Oct 14 17:00:18 localhost systemd: Starting Kernel Samepage Merging (KSM) Tuning Daemon...

Oct 14 17:00:18 localhost systemd: Started NTP client/server.

Oct 14 17:00:18 localhost systemd: Started GSSAPI Proxy Daemon.

Oct 14 17:00:18 localhost systemd: Started RPC security service for NFS server.

Oct 14 17:00:18 localhost systemd: Started RPC security service for NFS client and server.

Oct 14 17:00:18 localhost systemd: Reached target NFS client services.

Oct 14 17:00:18 localhost systemd: Starting NFS client services.

Oct 14 17:00:20 localhost systemd: Started firewalld - dynamic firewall daemon.

Oct 14 17:00:20 localhost systemd: Starting LSB: Bring up/down networking...

Oct 14 17:00:32 localhost network: Bringing up interface enp0s3:  [  OK  ]

Oct 14 17:00:32 localhost systemd: Started LSB: Bring up/down networking.

Oct 14 17:00:32 localhost systemd: Reached target Network.

Oct 14 17:00:32 localhost systemd: Starting Network.

Oct 14 17:00:32 localhost systemd: Starting Dynamic System Tuning Daemon...

Oct 14 17:00:32 localhost systemd: Started OpenSSH server daemon.

Oct 14 17:00:32 localhost systemd: Starting OpenSSH server daemon...

Oct 14 17:00:32 localhost systemd: Reached target Network is Online.

Oct 14 17:00:32 localhost systemd: Starting Network is Online.

Oct 14 17:00:32 localhost systemd: Starting Postfix Mail Transport Agent...

Oct 14 17:00:32 localhost systemd: Starting Vsftpd ftp daemon...

Oct 14 17:00:32 localhost systemd: Reached target Remote File Systems (Pre).

Oct 14 17:00:32 localhost systemd: Starting Remote File Systems (Pre).

Oct 14 17:00:32 localhost systemd: Reached target Remote File Systems.

Oct 14 17:00:32 localhost systemd: Starting Remote File Systems.

Oct 14 17:00:32 localhost systemd: Starting Permit User Sessions...

Oct 14 17:00:32 localhost systemd: Starting Virtualization daemon...

Oct 14 17:00:32 localhost systemd: Starting The Apache HTTP Server...

Oct 14 17:00:32 localhost systemd: Starting Availability of block devices...

Oct 14 17:00:33 localhost systemd: Started Vsftpd ftp daemon.

Oct 14 17:00:33 localhost systemd: Started Permit User Sessions.

Oct 14 17:00:33 localhost systemd: Started Availability of block devices.

Oct 14 17:00:33 localhost systemd: Starting Wait for Plymouth Boot Screen to Quit...

Oct 14 17:00:33 localhost systemd: Started Command Scheduler.

Oct 14 17:00:33 localhost systemd: Starting Command Scheduler...

Oct 14 17:00:33 localhost systemd: Starting GNOME Display Manager...

Oct 14 17:00:34 localhost systemd: Started GNOME Display Manager.

Oct 14 17:00:35 localhost systemd: Started Dynamic System Tuning Daemon.

Oct 14 17:00:35 localhost systemd: Started The Apache HTTP Server.

Oct 14 17:00:38 localhost systemd: Started Postfix Mail Transport Agent.

Oct 14 17:00:40 localhost systemd: Received SIGRTMIN+21 from PID 294 (plymouthd).

Oct 14 17:00:40 localhost systemd: Started Wait for Plymouth Boot Screen to Quit.

Oct 14 17:00:40 localhost systemd: Reached target Multi-User System.

Oct 14 17:00:40 localhost systemd: Starting Multi-User System.

Oct 14 17:00:40 localhost systemd: Reached target Graphical Interface.

Oct 14 17:00:40 localhost systemd: Starting Graphical Interface.

Oct 14 17:00:40 localhost systemd: Starting Update UTMP about System Runlevel Changes...

Oct 14 17:00:40 localhost systemd: Started Stop Read-Ahead Data Collection 10s After Completed Startup.

Oct 14 17:00:40 localhost systemd: Started Update UTMP about System Runlevel Changes.

Oct 14 17:00:40 localhost systemd: Startup finished in 1.248s (kernel) + 6.518s (initrd) + 37.578s (userspace) = 45.345s.

至此,啟動完成。

 

查看initramfs內容:

 

#mkdir /tmp/initramfs

# cp /boot/initramfs-3.10.0-327.el7.x86_64.img  /tmp/initramfs

# /usr/lib/dracut/skipcpio initramfs-3.10.0-327.el7.x86_64.img | zcat | cpio -id --no-absolute-filenames

解壓后的目錄內容如下:

total 18676

-rw-r--r--  1 root root 19076118 Oct 14 21:28 initramfs-3.10.0-327.el7.x86_64.img

drwxr-xr-x  2 root root     4096 Oct 14 21:29 sys

-rwxr-xr-x  1 root root     3041 Oct 14 21:29 shutdown

lrwxrwxrwx  1 root root        7 Oct 14 21:29 lib -> usr/lib

lrwxrwxrwx  1 root root       23 Oct 14 21:29 init -> usr/lib/systemd/systemd

drwxr-xr-x  2 root root     4096 Oct 14 21:29 var

drwxr-xr-x  2 root root     4096 Oct 14 21:29 tmp

drwxr-xr-x  2 root root     4096 Oct 14 21:29 sysroot

lrwxrwxrwx  1 root root        8 Oct 14 21:29 sbin -> usr/sbin

drwxr-xr-x  2 root root     4096 Oct 14 21:29 run

drwxr-xr-x  2 root root     4096 Oct 14 21:29 root

drwxr-xr-x  2 root root     4096 Oct 14 21:29 proc

lrwxrwxrwx  1 root root        9 Oct 14 21:29 lib64 -> usr/lib64

drwxr-xr-x 12 root root     4096 Oct 14 21:29 etc

drwxr-xr-x  2 root root     4096 Oct 14 21:29 dev

lrwxrwxrwx  1 root root        7 Oct 14 21:29 bin -> usr/bin

drwxr-xr-x  7 root root     4096 Oct 14 21:29 usr

 

init是鏈接到systemd,systemd是Linux的第一個進程(PID=1)。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM