linux routine maintenance (ii)

linux boot process

  1. BIOS self-test
  2. Start GRUB 2
  3. Load the kernel
  4. Systemd process execution
  5. Initialize the system environment
  6. Execute / bin / login program
(A) BIOS self-test
  1. POST, power (to detect the hardware)
  2. Enumeration and initialization of the local device.

BIOS consists of two parts: Service POST code and runtime. When POST is completed, it is cleared from memory, but the BIOS runtime services still remain in memory, the target operating system can use these services.

linux system are generally directed from the hard disk, wherein the master boot record (MBR) contains a primary boot loader. MBR is a 512-byte sectors, the first sector is located on the disk (sector 0 0 1 cylinder). When the track is loaded in RAM MBR, BIOS passes control to the MBR.

(B) start GRUB 2

It is linux system default boot loader, a boot the operating system starts. When the computer boot operating system, BIOS will read the medium on the top of the guide 512 bytes (Master Boot Record)

(C) load the kernel

Load the kernel image into memory, the kernel image is not an executable kernel, but a compressed kernel image. In front of this kernel image is a routine that is set to achieve a small amount of hardware, and kernel image included in the kernel decompression, put it into any high-end memory. If there is an initial RAM disk image, the system will move into his memory, and indicate future use. The routine then calls the kernel and kernel boot process is started.

(Iv) implement systemd process

The process is the starting point of all processes linux system, after the completion of the kernel boot, that is loaded systemd program within the process space. systemd process is the initiator of all processes and controllers. Because in any linux system, it is the first process to run, all process ID PID systemd process is always 1

(E) to initialize the system environment

systemd as linux system using boot manager, the boot process will systemd after completion. using the target system (target) to guide the processing and service management processes. These systemd in the target file is used to group different boot unit and start the synchronization process.

  1. The first goal is the implementation of systemd default.target, but in fact default.target goal is to point graphical.target target of a soft link. The actual position of the object unit file is graphical.targe /user/lib/systemd/system/graphical.target.
  2. In the implementation phase graphical.target target, we will start multi-user.target goal, and this goal will be stored in the unit byte word /etc/systemd/system/multi-user.target.wants directory. Non-root user and firewall related services started to draw at this stage.
  3. multi-user.target target will control to basic.target goal. basic.target common target for starting services, especially image management services. It is determined that the service will be started, after basic.target target will hand over control of sysinit.target goal by /etc/systemd/system/basic.target.wants directory.
  4. sysinit.target main goal will be to start system services, such as system mount, memory, swap space and equipment, the kernel supplement options. sysinit.target target will be passed to local-fs.target and swap.target goals during startup.
  5. locat-fs.target user does not start and swap.target related services, which only deal with the underlying core services. These two goals can perform actions according to / etc / fstab and / etc / inittab file.
(F) the implementation of / bin / login program

login will receive a user name and mingetty came as the user name parameter, then login user name will be analyzed. If the username is not root, and there is / etc / nologin file, login nologin will output the contents of the file, and then exit. This is usually used to prevent non-root user login when system maintenance. Only registered in the / etc / securetty terminal only allow the root user login, if the file does not exist, the root can log on any terminal. / Etc / usertty file users to make additional access restrictions on users, if the file does not exist, there are no other restrictions.

After analyzing the user name, login will search / etc / passwd and / etc / shadow passwords and other information to verify the account settings, such as what home directory is? What shell to use? If no primary target, then the main root directory as the default setting; shell if not specified, then the default setting for the type of shell / bin / bash.

After the login procedure is successful, the corresponding terminal in output last logged (recorded in / var / log / lastlog file), and checks whether the user has new messages (corresponding to the user in the / var / spool / mail / a under the name directory), and then begin setting up various environment variables. Corresponding to the bash, the system first looks for / etc / profile script and execute it; then, if there is .bash_profile file in the user's home directory, execute it, and in these documents may call the other configuration files, all configuration files after the execution, a variety of environmental variables set up well, then there will be the familiar command prompt, start this whole process is over.

Excerpt: "Linux practical tutorial" People's Post published Yue was released in edited

Guess you like

Origin www.cnblogs.com/mylive/p/11280239.html