1, load the kernel
? When the computer is turned on, the first step is BIOS self-check, which starts with the boot device (usually hard disk) set in the BIOS. After the operating system takes over the hardware, it first reads the kernel file in the /boot directory. The kernel of Raspberry Pie 4B is Raspbian GNU/Linux10 (buster), which is based on Debian.
2. Initialize the process init
? After loading the kernel file, run the first program init, which is used to initialize the system environment. Init is located in the directory /sbin, and the process number PID is 1, which means the process 1. All other processes are derived from init and are children of init.
At the same time, there is also a 0 process, an idle process, which was created by the kernel itself from scratch when the system was initialized. Create a kernel thread to execute the init function by calling kernel_thread, and the 0 process creates a 1 process.
3. Operation level
For details, please refer to the author's article-Introduction to ——Linux Run Level? However, how to determine the running level at startup?
The init process first reads the file /etc/inittab, which is a setup file at the run level. But each distribution is different, and the configuration file of init is also different. You can use the configuration file in /etc/event.d, and the latest version is changed to /etc/init directory.
4. Boot program
For more information, please refer to the article-Setting /etc/init.d in -linux. After determining the running level, execute the files in the rcN.d directory. These linked files are programs that connect to the init.d directory. The Init process loads the bootstrapper one by one, and actually runs the startup script in this directory.
For example, a program that starts when the running level is 5 (graphic multiuser):
5. User login
? The user logs in after the bootloader is loaded. Users have three login methods:
? Command line login: init process calls getty program.
? Ssh login: init process calls sshd program.
? Graphical interface login: the init process calls the display manager, and the display manager corresponding to the Gnome graphical interface is gdm.
6? , login shell
The default shell is bash, a command-line interface that allows users to talk directly to the operating system. For reading environment variables, please refer to the author's article-Linux environment variable setting.