What are the stages of the Linux system boot process

08-01-2023

This article mainly explains the stages of the Linux system startup process. The content of the explanation in the article is simple and clear, easy to learn and understand. Next, please follow the editor's ideas and slowly deepen, and let's study and learn Linux system startup together. What are the stages of the process?

The five stages of the system startup process: 1. The kernel boot stage; device (usually a hard drive) to boot from. 2. Run the init stage; the init process is the starting point of all processes in the system, without this process, any process in the system will not start. 3. System initialization stage; call rc to complete some system initialization work. 4. Establish the terminal stage. 5. The user logs into the system.

Linux system startup process

The startup process of the Linux system is not as complicated as everyone imagines, and the process can be divided into 5 Phase:

(1) Booting of the kernel.

(2) Run init.

(3) System initialization.

(4) Establish a terminal.

(5) User login system.

1. Kernel boot

When the computer is powered on, the first thing is the BIOS power-on self-test, according to the boot device (usually the hard disk) set in the BIOS to start. After the operating system takes over the hardware, it first reads the kernel file in the /boot directory.

2. Run init

(1) The init process is the starting point of all processes in the system, you can compare it to The ancestor of all processes in the system, without this process, no process in the system will start. The init program first needs to read the configuration file /etc/inittab.

(2) Run level: Many programs need to be started at boot. They are called "services" in Windows and "daemons" in Linux.

A major task of the init process is to run these boot-up programs. However, different programs need to be started on different occasions. For example, Apache needs to be started when it is used as a server, but it is not needed when it is used as a desktop.

Linux allows for different occasions, assigning different boot programs, which is called "runlevel" (runlevel). That is to say, according to the "run level" at startup, determine which programs to run.

(3) LiThe nux system has 7 runlevels (runlevel):

  • Runlevel 0: The system is in a shutdown state. The default runlevel of the system cannot be set to 0, otherwise it cannot start normally

    < /li>
  • Run level 1: single-user working status, root authority, for system maintenance, remote login is prohibited

  • Run level 2: multi-user status (No NFS)

  • Run level 3: full multi-user state (with NFS), enter the console command line mode after login

  • Run level 4: The system is not used, reserved

  • Run level 5: X11 console, enter the graphical GUI mode after login

  • < li>

    Run level 6: The system shuts down and restarts normally, the default run level cannot be set to 6, otherwise it cannot start normally

3. System initialization< /strong>

There is such a line in the init configuration file: si::sysinit:/etc/rc.d/rc.sysinit It calls and executes /etc/rc.d/rc.sysinit, And rc.sysinit is a bash shell script, it mainly completes some system initialization work, rc.sysinit is an important script that must be run first at every run level.

Its main tasks are: activate the swap partition, check the disk, load the hardware module and other tasks that need to be prioritized.

4. Establish a terminal:

After rc is executed, return to init. At this time, the basic system environment has been set up, and various daemon processes have also been started. init will then open 6 terminals for users to log in to the system.

5. User login system:

Three types: command line login, ssh login, GUI login

Attachment: Linux shutdown

1. The correct shutdown process is: sync > shutdown > reboot > halt

2. The shutdown command is: shutdown, you can see it with man shutdown Check out the help documentation.

3. Example:

sync # Synchronize data from memory to hard disk.

shutdown –h 10 'This server will shutdown after 10mins'
#This command tells everyone that the computer will shut down after 10 minutes and will be displayed on the current screen of the logged-in user.

shutdown –h now #Shutdown immediately
shutdown –h 20:25 #The system will shut down at 20:25 today
shutdown –h +10 #Shutdown after ten minutes
/>shutdown –r now #The system restarts immediately
shutdown –r +10 #The system restarts after ten minutes
reboot # It is a restart, which is equivalent to shutdown –r now

halt # Shut down the system, which is equivalent to shutdown –h now and poweroff

4. Whether it is restarting the system or shutting down the system, you must first run the sync command to write the data in the memory to disk.

The commands for shutting down are shutdown –h now, halt, poweroff and init 0, and the commands for restarting the system are shutdown –r now, reboot, init 6.

5. shutdown will schedule a time for the system to shut down. It can be used to stop, shut down, and restart the machine.

shutdown -p now # Shut down the machine shutdown -H now # Stop the machine shutdown -r 09:35 # Restart the machine at 09:35am

To cancel the pending shutdown, just enter the following command:

shutdown -c

6. The halt command notifies the hardware to stop all CPU functions, but still keeps the power on. You can use it to keep the system in a low-level maintenance state. Note that in some cases it will completely shut down the system.

# halt ### Stop the machine # halt -p ### Shut down the machine, turn off the power # halt --reboot ### Reboot the machine

poweroff will send an ACPI signal to notify the system to shut down.

# poweroff ### Turn off the machine, turn off the power # poweroff --halt### Stop the machine # poweroff --reboot ### Restart the machine

The reboot command reboot notifies the system to restart.

# reboot ### Restart the machine # reboot --halt ### Stop the machine # reboot -p ### Shut down the machine

Thank you for reading, the above is the content of the stages of the Linux system startup process, after studying this article, I believe Everyone has a deeper understanding of what are the stages of the Linux system startup process, and the specific usage needs to be verified by everyone. This is Yisu Cloud, the editor will push more articles about relevant knowledge points for you, welcome to pay attention!

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us