Linux boot process details

  • 2020-05-30 21:45:35
  • OfStack

Starting a computer is a mysterious process. We just press the power button and see the progress bar or line 1 output on the screen until we get to the login screen. However, booting a computer is a very fragile process, and the login screen we were hoping for might not appear, but a command line or error message. Understanding the computer boot process helps us to fix any problems that may arise during boot.

Initial stage

When we turn on the computer, the computer will automatically read the programs stored on the motherboard from Basic Input/Output System. This 1 program usually knows some hardware that is directly connected to the motherboard (hard disk, network interface, keyboard, serial port, parallel port). Most BIOS now allow you to boot your computer by selecting one from a floppy, compact disc, or hard disk.

In the next step, the computer will read the first 512 bytes (bytes) from the storage device of your choice. If we boot from the CD, the computer will read the first 512 bytes of the CD. These 512 bytes are called the master boot record MBR (master boot record). MBR tells the computer to load the boot loader (boot loader) from one of the partitions on the device (partition). The boot loader stores information about the operating system (OS), such as the name of the operating system, the location of the operating system kernel (kernel), and so on. Common boot loaders are GRUB and LILO.

The boot loader then helps us load the kernel (kernel). Kernel is actually a program used to operate the computer, it is the kernel of the computer operating system, the main task is to manage the computer's hardware resources, as the interface between software and hardware. Any operation on the operating system is communicated to the hardware through the kernel. Windows and Linux each have their own cores. The narrow sense of the operating system refers to the kernel, the broad sense of the operating system includes the kernel and the various applications on the kernel.

(Linus Torvalds is not so much the father of Linux as the father of the Linux kernel. He remains responsible for the development and maintenance of the Linux kernel. As for Ubuntu and Red Hat, they are all based on the same kernel and include a more complete version of the operating system with different applications and interfaces.

In fact, we can install the boot loader on multiple partitions, each boot loader for a different operating system, and select the boot loader we want to start when we read MBR. This is how multiple operating systems work.

Summary: BIOS - > MBR - > Boot loader - > The kernel

The kernel

If we load the Linux kernel, the Linux kernel starts working. The kernel first reserves the memory space it needs to run, and then detects the computer hardware through the driver (driver). That way, the operating system knows what hardware it has available. The kernel then starts an init process. It is process 1 on the Linux system (there is no process 0 on the Linux system). At this point, the kernel completes the work at computer startup and is handed over to init for management.

Summary: kernel - > init process

init process

(according to the boot loader option, Linux can now enter single-user mode (single user mode). In this mode, the initial script has not yet been executed, so we can detect and fix possible errors on the computer.

init then runs the initial scripts for the 1 series (startup scripts), which are common in Linux, shell scripts. These scripts perform the following functions:

Set the computer name, time zone, detect the file system, mount the hard disk, empty the temporary files, set up the network...

When these initial scripts are available, the operating system is fully ready, but no one can log in yet. init gives you the login (login) dialog, or a graphical login screen.

Enter your username (vamei, for example) and password. DONE!

After that, you will operate the computer as user (user)vamei. In addition, Linux will put you into a group (group) based on your Settings when you created the user, such as stupid or vamei.

So you will be user vamei and a member of the vamei group. (note that vamei and vamei are just the same name, so you can call them Dell and still be the boss of Dell. You can also be user vamei and a member of stupid group.)

conclusion

BIOS - > MBR - > Boot loader - > The kernel - > init process - > login

Users, groups.


Related articles: