Linux学习:CentOS 7开机启动过程和关机过程
英文网址:http://man7.org/linux/man-pages/man7/bootup.7.html
名称
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)。
更多推荐
所有评论(0)