Linux startup process description

Table of contents

Linux boot process

Start the system kernel

Start the init process


What is Linux

The Linux kernel was originally written by Finnish Linus Torvalds as a personal hobby when he was a student at the University of Helsinki.

The full name of Linux is GUN/Linux. It is an open source Unix-like operating system. It is a POSIX-based multi-user, multi-tasking operating system that supports multi-threading and multi-CPU. It supports 32-bit and 64-bit hardware.

Commonly used Linux distributions

Ubuntu Linux Desktop Market Aspects

Redhat server stable version (service will be charged)

CentOS Community Enterprise Edition (Free)

SuSE is mainly used in Europe and other regions (there are paid versions and free versions - it can be understood as the European version of CentOS)

Fedora Core desktop user testing only

Linux vs. Windows

 

Windows

Linux

usage rights

charging system

Open source free system

Multi-user/Multi-thread

support

support

scenes to be used

Operating system mainly used for personal computers such as gamers

Operating system primarily used as a server

system structure

Composed of independent software modules

file-based operating system

software support

There are many softwares and types
, but the software generally requires a fee and is officially developed and maintained by Windows.

Most of them are open source free software that can be modified, customized and republished by users.
However, the types and functions of the software are relatively small.

Operating habits

Generally use graphical operations (command line is also supported)

Generally use the command line to operate (graphical representation is also supported)

safety

Linux is more secure than Windows, and Linux’s open source approach makes it easier to find and fix errors.

Customizability

Linux is more customizable than Windows


Linux boot process

The boot process of different Linux systems is generally the same. The difference is that the management methods are different, but the process is the same.

The following introduction takes CentOS6 as an example.

Start the system kernel

BIOS power-on self-test

BIOS power-on self-test, also called power-on self-test, is a function of the computer BIOS that will run after the computer is turned on.

Perform hardware testing on computers, including CPU, memory, hard disk, etc.

After a fault is discovered during the self-test, hardware problems will be prompted in some ways (alarm lights, display screens, LEDs, etc.)

MBR boot

After the self-test is completed, the BOOT startup item defined in the BIOS looks for the hard disk with the MBR boot program and starts the system.

If there are multiple boot disks, check them in order. If the first boot disk has MBR boot, start the boot disk. Otherwise, check in turn; if the MBR boot program of the boot disk is faulty during the check, it will Staying on this error interface requires us to troubleshoot

GRUB menu

After the MBR boot is completed, select the GRUB menu (if the boot disk has multiple systems, select which system)

GRUB consists of three parts

Stage1 is stored in the first 446 bytes of the MBR and is used to boot Stage2

Stage1.5 is stored in the /boot/grub directory and is used to identify the file type of the partition where the kernel is located.

Stage2 is stored in the /boot/grub directory and is combined with the grub.conf configuration file to boot the operating system.

Specific work

After the MBR of the device is determined, control of the computer will be transferred to Stage1 located in the first 446 bytes of the MBR.

Then boot stage1.5 and combine with stage2 to implement operating system selection.

Start Kernel

Start the kernel of the selected system, check the hardware devices again, and load the drivers required for device startup

The hardware device driver is in the system. We have not started the system yet. How to load the driver?

You need to use the initramfs.img file under the kernel or BOOT root partition to load the driver.

The initramfs.img file provides a basic, minimal file system when the kernel starts, so that the kernel can access the drivers and tools required by the system and start them, so as to enter the real system.

kernel initialization process

  1. Start the kernel of the selected system
  2. Perform equipment inspection and detection
  3. Perform driver initialization (possibly loading the device driver module from the initrd (initramfs) file)
  4. Mount the root file system read-only
  5. Load the first process init (PID: 1)

Start the init process

After entering the real operating system, you need to start related services and processes.

The init process is the starting point of all processes in the system (PID is 1), and other processes are the child processes of this process; its function is to initialize the system environment

Read the /etc/inittab configuration file - defines the system run level

The /etc/inittab configuration file needs to be read to run the init process. This configuration file defines the system's run level, /etc/sysinit script, /etc/rc.d/rc script and mingetty process.

System running process

This configuration file is used to identify which running level the system starts at; different running levels correspond to different running modes, and the services that the system needs to provide in different running modes are different.

Level 0 is shutdown

Level 1 single user

Level 2 Multiple users, but no network service

Level 3: multi-user, full-featured (generally Level 3)

Level 4 is reserved by the system and will not be used.  

Level 5 Graphical Interface 

Level 6 Restart

/etc/rc.d/rc.sysinit script - system initialization script

Including host name, mounted disk partition, closing SELinux and other initialization work

etc/rc.d/rc script - startup/shutdown scripts for various services

This script needs to be used to turn on/off the application services that need to be turned on/off at this run level, and it is necessary to read the applications or services under the boot auto-start file (/etc/rc.d/rc.local file) to turn them on.

Starting with K means closing the service, starting with L means opening the service; first close the service, then open it

mingetty process

Run the mingetty process to open the login window, and execute /bin/login at the same time to jump out of the login interface. Enter your username and password to log in to the system and perform corresponding operations.

Guess you like

Origin blog.csdn.net/m0_49864110/article/details/133960364