Linux system boot starts the boot process starting from the beginning of the BIOS detection of hardware information =. Reads the MBR (the first sector of the NO. 0 track on disk), which is the master boot record, which is the primary boot recording. The MBR records pre-boot information and partition table information. The Grub (function: Setting the kernel image in the location of the disk partition) is then copied to memory. Prepare for booting the kernel. = = = "Load kernel." Kernel initialization produces an INIT process with a PID of 1.
Because the kernel is useless, it requires a system to define, manage and control the behavior of the Init process, and to organize and run the initialization work so that the system enters a user-defined mode of operation, which is the init system.
Init(for English: shorthand for Initialization) is a program used in Unix and Unix-like systems to generate all other processes. It exists as a daemon, with a process number of 1. After the Linux kernel is loaded at boot time, the Linux kernel loads the INIT program and the INIT program completes the rest of the boot process.
How Init works: Sysvinit, Upstart, SYSTEMD
The init operation of the early Linux system was compatible with the mode of init running under UNIX system V (a version of UNIX systems).
How the init works under System V:
System V init checks if the '/etc/inittab ' file contains ' Initdefault ' entries. This tells the INIT system whether it has a default run. System V Init describes the status in 8. 0-6 and S or S. Linux set 6 levels: #cat/etc/inittab
# Default RunLevel. The runlevels used is:
# 0-halt (do not set Initdefault to this)
# 1-single User mode
# 2-multiuser, without NFS (the same as 3, if you don't have networking)
# 3-full Multiuser mode
# 4-unused
# 5-x11
# 6-reboot (do not set Initdefault to this)
Unix System v defaults to a Level 3 boot. Most versions of Linux servers are 3 levels by default. The desktop version is typically 5. (graphical interface). How to view: $ RunLevel or $ who-r.
The advantage of Sysvinit is that the concept is simple. Service developers only need to write the start and stop scripts, the concept is very clear, when the service is added/removed to a runlevel, only need to perform some basic operations to create/delete soft connection files, these do not need to learn additional knowledge or special definition syntax (upstart and SYSTEMD all require the user to learn the new language that defines the system initialization behavior.
Second, another important advantage of sysvinit is the determination of the order of execution: the script executes strictly according to the size of the boot number, and one execution completes the next, which is very useful for troubleshooting. Upstart and SYSTEMD support concurrent start-up, resulting in no one knowing the exact boot sequence, which is not easy to debug.
In 2006, Ubuntu intends to use the system in notebooks. The biggest dilemma is that Sysvinit does not have enough hot-swappable support for mobile devices (devices for USB devices). The upstart is then developed based on the event mechanism. For example, when a USB drive is plugged in to an interface, Udev gets a kernel notification and discovers the device, which is a new event. Upstart triggers an appropriate wait task after sensing the event, such as handling a mount point that exists in the/etc/fstab. With this event-driven pattern, upstart perfectly solves the new problems posed by Plug and Play devices. The upstart uses asynchronous methods to start the system faster, to start the service dynamically when new hardware is discovered, and to stop the service dynamically when the hardware is removed. These features enable the upstart to be used in desktop or portable systems to handle the dynamic hardware plug-and-pull characteristics of these systems. But upstart is not completely out of the runlevel mechanism. Only on the basis of compatibility with the corresponding optimization of the runlevel mechanism.
To reduce system startup time, the goal of SYSTEMD is to start fewer processes as much as possible, to start more processes in parallel, and to reduce dependencies between startup processes. A process that is not necessary can be started only when it is needed. In addition, SYSTEMD has created a new management system. The concept of the previous run level (RunLevel) was superseded by the new run target. Target's naming system is similar to the "Multi-user.target" corresponding to the original RunLevel 3 (RunLevel 3). In Centos7, the new SYSTEMD management mechanism was used. The concept of runlevel is no longer used, so/etc/inittab is not used by the system.
CENTOS7 SYSTEMD Management System The default target is implemented via a soft link.
(due to layout problems, the Inode value belongs to the main group and date deleted)
[Email protected] ~]# Ll/etc/systemd/system/default.target
lrwxrwxrwx. /etc/systemd/system/default.target-/lib/systemd/system/multi-user.target
If you want to modify the run target. Only need to remove this soft link. Soft links to new running targets.
# Rm-rf/etc/systemd/system/default.target
# ln-s/lib/systemd/system/multi-user.target/etc/systemd/system/default.target
Let's check out the/etc/inittab file under Centos7.
$ cat/etc/inittab
# Inittab is no longer used when using SYSTEMD.
# ADDING CONFIGURATION here'll has NO EFFECT on YOUR SYSTEM.
# Ctrl-alt-delete is handled By/usr/lib/systemd/system/ctrl-alt-del.target
# SYSTEMD uses ' targets ' instead of runlevels. By default, there is both main target
# Multi-user.target:analogous to RunLevel 3
# graphical.target:analogous to RunLevel 5
# to view current default target, run:
# Systemctl Get-default
# to set a default target, run:
# Systemctl Set-default Target.target
The location of the new target is clearly defined:/usr/lib/systemd/system/ctrl-alt-del.target
Also look under: (Due to layout problems, the Inode value belongs to the main group and date deleted)
# ll/usr/lib/systemd/system/runlevel*
Lrwxrwxrwx/usr/lib/systemd/system/runlevel0.target-Poweroff.target
Lrwxrwxrwx/usr/lib/systemd/system/runlevel1.target-Rescue.target
Lrwxrwxrwx/usr/lib/systemd/system/runlevel2.target-Multi-user.target
Lrwxrwxrwx/usr/lib/systemd/system/runlevel3.target-Multi-user.target
Lrwxrwxrwx/usr/lib/systemd/system/runlevel4.target-Multi-user.target
Lrwxrwxrwx/usr/lib/systemd/system/runlevel5.target-Graphical.target
Lrwxrwxrwx/usr/lib/systemd/system/runlevel6.target-Reboot.target
In addition, the SYSTEMD Management system introduces command-line tool SYSTEMCTL. Systemctl can be seen as service and Chkconfig
Combination. But don't worry. The service command is still available under CENTOS7, but it redirects all commands to the new Systemctl tool.
A few examples:
(Sysvint)
#service Network start |stop |status
#chkconfig httpd on
(SYSTEMCLT)
# Systemctl Start|stop|status Network.service
#systemctl Enable Httpd.service
Currently: Ubuntu 15.04 and later versions have SYSTEMD installed on the default init.
After introducing the mainstream init system, start the system again.
Bios-mbr-grub-Kernel-/etc/inittab-/etc/rc.d/rc.sysinit-boot kernel module/etc/modules.conf-start script under specified level rcx.d-execute/etc/rc.d/ Rc.local-/bin/login
While there are a number of benefits to the new init system: But now, after all, Centos7 's corporate user base is generally not large. We still need to master the CENTOS7 version of the launch. Convenient for later management. And Centos7 is completely backwards compatible at the command level.
Comb out, start the process of boot. Can come in small applications.
For example: Mount the mobile device inside the/etc/rc.d/rc.local, add the personalization service to start. If, the change phase that service cannot start, cause. Start blocking. Whether you can enter single-user mode and comment out the service under the/etc/rc.d/rc.local file. After the boot in the test, repair it?
The main thing is that. Familiar with boot after startup. The error message can be based on the boot. Troubleshooting is the error that occurred at that stage. For example, the system restarts together. See if/etc/inittab has the RUNLEVEL6 mode set. The boot script error should not be a single user into the system troubleshooting. /ETC/RC.D/RCX.D the script below, it is necessary to rename the script starting with S to K first. Wait for the system to start after recovery.
This article is from the "Shong Linux Tour" blog, make sure to keep this source http://12042068.blog.51cto.com/12032068/1893062
A brief talk on CentOS starting up that thing.