Linux System Boot Process
The startup process of a Linux system can be divided into 5 phases:
1. Kernel boot
When the computer is powered on, it is the BIOS post that starts with the boot device (usually the hard disk) set up in the BIOS. After the operating system takes over the hardware, it first reads the kernel file in the/boot directory.
2. Run init
The init process is the starting point for all processes in the system, and you can compare it to the ancestor of all processes in the system, without which any process in the system will not start. The INIT program first needs to read the configuration file/etc/inittab.
NIT type of program:
- SysV: init, before CentOS 5, configuration file:/etc/inittab.
- Upstart: init,centos 6, configuration file:/etc/inittab,/etc/init/*.conf.
- Systemd : systemd, CentOS 7, configuration file:/usr/lib/systemd/system,/etc/systemd/system.
3. Operating level
Many programs need to boot up. They are called "services" in Windows, and in Linux they are called "daemons" (daemon).
One of the major tasks of the Init process is to run these boot-up programs.
However, different applications need to start different programs, such as when serving as a server, the need to start Apache, as a desktop is not required.
Linux allows different start-up programs to be assigned for different occasions, which is called "RunLevel" (runlevel). That is, at startup, depending on the runlevel, determine which programs to run.
The Linux system has 7 runlevel (runlevel):
- RunLevel 0: System down state, system default RunLevel cannot be set to 0, otherwise it will not start normally
- RunLevel 1: Single User working status, root privilege, for system maintenance, remote login Forbidden
- RunLevel 2: Multi-User State (no NFS)
- RunLevel 3: Full multiuser State (with NFS), enter console command line mode after login
- Run Level 4: System not used, reserved
- Run level 5:x11 console, login to GUI mode
- RunLevel 6: The system shuts down gracefully and restarts, the default runlevel cannot be set to 6, otherwise it will not start normally
4. initialization of the system
There is a line in the init configuration file: Si::sysinit:/etc/rc.d/rc.sysinit It calls execution/etc/rc.d/rc.sysinit, and Rc.sysinit is a bash shell script, It is mainly to do some system initialization work, Rc.sysinit is each run level must first run the important script.
Its main tasks are: Activating the swap partition, checking the disk, loading the hardware modules, and some other priorities that need to be performed.
The RC startup script in/etc/rc.d/rc5.d/is usually a connection file that starts with K or S, and will run with the start parameter for startup scripts starting with S.
5. User Login System
In general, there are three ways users sign in:
- (1) Command line login
- (2) SSH login
- (3) Graphical interface login
Text login: When we see the mingetty login screen, we can enter the username and password to log into the system.
Linux Account Verification Program is Login,login will receive mingetty from the user name parameters.
Login then parses the username: If the user name is not root and there is a/etc/nologin file, login will output the contents of the Nologin file and then exit.
This is typically used for system maintenance to prevent non-root users from logging on. Only the terminal registered in/etc/securetty allows the root user to log on, and if the file does not exist, root can log on at any terminal.
The/etc/usertty file is used to make additional access restrictions to the user, and there are no additional restrictions if the file does not exist.
5 processes of system startup for Linux system learning