[Linux] CentOS 7 boot process and shutdown process

 

 bootup - the system startup process

description

Guiding system involves many different components. After boot, the system BIOS will complete minimal hardware initialization, the boot loader on a persistent storage device and passes control to store. Then the boot loader from the disk (or network) calls the OS kernel. In the Linux environment, the core (optional) fetching and executing an initial RAM disk image (Initrd), for example, generated by Dracut (8), which find the root file system (which may be used for this purpose systemd). After finding and loading the root file system, the storage system control to the initrd the OS image on the manager host (e.g. systemd), then the manager is responsible for detecting all the remaining hardware necessary to mount all of the file system and generate all service configuration.

When closed, the system manager to stop all services and unmount all file systems (uninstall support their storage technology), and (optional) jumps back to unload initrd root file system and storage resides. Finally, shut down the system.

Start System Manager

At startup, the system manager responsible for the OS image required to initialize the system to run the file system, services and drivers. For systemd system, this process is divided into several stages steps. In each stage the internal step, a highly parallel task, it is impossible to accurately predict the order in which the cells, but the sequence between the different stages are always fixed.

Systemd when starting the system, it will activate default.Target all dependencies (and recursively activate all these dependencies dependencies). Usually, default.Target just Graphical.Target or Multi-user.Target alias, depending on the system is configured as a graphical user interface, or configured as a text console. To force the normative boot process and to increase the parallelism means, a number of pre-defined target cell have a specific meaning.

The following diagram illustrates the dependencies between the target cells and each having a specific meaning in the boot process. Arrows in the figure shows the dependency between the unit and the sequence, the entire graph from top to bottom in chronological order of execution.

Focus on the identification of the target unit is often used as a target start. There are two ways to specify start objectives: (1) using systemd.unit = kernel command line parameters (see systemd Handbook); (2) default.target soft connection.

Because timers.target asynchronously contained in the basic.target, the timer unit may be dependent on only start after basic.target service.

initrd boot process

Achieved initial RAM disk (Initrd) may also be used to set systemd. In the present embodiment, the inside of the guide initrd following structure.

In initrd inside, may be used as systemd init program (kernel boot parameter specified by "rdinit ="), this time will be the default target initrd.target. initrd internal boot process identical to the upper half of the portion before the previous subsection basic.target, then the process will start as shown in FIG. If successful, the root file system is mounted to / sysroot directory, sysroot.mount unit will be activated, and then further activate initrd-root-fs.target goal. initrd-parse-etc.service will analyze / sysroot / etc / fstab file to mount the / usr (if necessary) to mount points having x-initrd.mount labeled. The mount points are to be mounted below / sysroot, and then the flow goes initrd-fs.target target. The next initrd-cleanup.service will use the / usr / bin / systemctl --no-block isolate initrd-switch-root.target command to start initrd-switch-root.target goal. Because isolate expressed immediately stop all unwanted target cells in the new process, so this action is actually doing advance preparation (ie, environmental clean-up) for the next switch the root directory. Finally, activation initrd-switch-root.service services, the system is switched to the root directory / sysroot directory. (Identical to the process before the previous section):

Switching to the operating system on the host

The shutdown process

systemd system follow the same fixed process at shutdown, specifically as shown below:

​ 

To view a specific start-up sequence can be entered into a file with the following command, and then open the view through the browser.

systemd-analyze plot > boot.html

List all units are running, press start to start from the initialization time spent sorting.

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 [email protected]).

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)。

Guess you like

Origin www.cnblogs.com/grumpyhippo/p/11298582.html