Linux startup process overview

xiaoxiao2021-03-06  87

Linux startup process overview

I. Introduction

This article tells the Linux system startup process to help readers understand the inside of the system.

Second Linux system startup overview

After the system is powdered, the boot loader in the ROM of the BIOS starts to find the boot sector. The boot sector is typically the first sector of the disk, with a small program that can load the operating system. Guide sector The magic number 0xA55 tagged from byte 0x1f, that is, the last two bytes of the sector, the boot loader uses this to distinguish whether the first sector of a disk is a guiding sector. Boot load program can Looking for a boot sector in a floppy disk drive, a hard drive, and a CD-ROM. When a boot partition is found, load it into memory, then the control is handed over to the program that loads the operating system. Actually in the general Linux system The guiding sector loaded by the boot loader is actually part of LILO, which is a "first phase startup loader" of LILO. This is a small program, its task is loading and running "second-phase startup The loader "." Second Phase Startup Dress "gives you a prompt, then load your selected operating system kernel. Then the kernel is loaded and running the init program. Since the init program is running requires the function in the library, Also load the Glibc library. The init program reads the / etc / inittab file, this file specifies the system's default run level, according to the contents of the Bash Run System, initialize the script /etc/rc.d/rc.sinit, for example File system check and load, clock setting, hostname settings, etc. Initialization work. Then call /tc/rc.d/rc#.d scripts according to the default run level to launch some service programs, such as HTTP, etc., then run MINGETTY It allows you to log in through a virtual console. After the user enters the username, the login program starts running, it requests the user to enter the password and check the password, if the password is accurately called the default shell. Shell gives a prompt. Values, users can enter and execute commands in the command line format.

Three file system loading

Although all files in the Linux system form a complete directory tree, the file itself resides in different storage devices such as disk, CD-ROM, etc. In order to access a file system, the file system on a storage device needs to be required. Put it in the primary directory structure, which is the device file load. We can use the mount command to manually load a file system, or you can automate some load work by setting the load information in the configuration file / etc / fstab. As before Reference, initialization script /etc/rc.d/rc.siSinit will complete the check and load of the file system, which actually uses the command: mount -a to load the desired loaded file system, and is / etc / fstab definition Loading those file systems when the system starts.

/ etc / fSTAB file example:

#

/ DEV / HDA3 / EXT3 DEFAULT 0 1

/ DEV / HDC / MNT / CDROM ISO9660 RO, NOAUTO 0 0

/ DEV / FD0 / MNT / FLOPPY Auto Defaults, NOAUTO 0

/ Proc / Proc Proc Defaults

/ dev / hda2 none swap swap

/ DEV / HDA1 / MNT / Windows vfat defaults 0 0

Four service processes start

The service is a resident program that can be run at the same time as other programs, which is continuously waiting for the service request of the local or remote user. When receiving the user service request, the service opens a session to provide services. You can use a specific startup script manual Start or stop a service, you can also configure a service that is automatically opened in the system. As for the automatic service opening division, two forms: Standalone service and xinetd service. The previous service starts running when the system is started until it is closed System, mostly used frequent services, such as Web Server, etc., the latter service opens the service when accepting the user request, more services, such as FTP, etc. For Standalone service, Red Hat uses the sysv init process in the system The service is turned on by using the specific startup script under /etc/rc.d/init.d. The specific access is a script link to the subdirectory set by /etc/rc.d. The ./etc/rc.d directory is a set of subdirectory, named the format is RCN.D, where n is running level 0 ~ 6. The system is started by detecting the default run level, and then performs the corresponding run level subdirectory Start script. If you log in in a command line, the init program executes the service on the /etc/rc.d/rc3.d directory in the system starts, such as / ETC / RC in RC3.D. The link established by the D / INIT.D / HTTPD script is S85HTTPD, indicating that the HTTPD service script is turned on on the run level 85.

For XineTD services, multi-xinet's resident service itself is configured and managed, so that the corresponding Internet service can be turned on when accepted the service request. Xinetf.conf file is the XINETD configuration file, which defines some different services, these services Automatically open when the respective user requests. Every item in this file defines a service, starting with the service keyword, then the service name, then the property is fast. Example Telnet item:

#default: ON

#description: The Telnet Server Serves The Telnet sessions; IT Uses /

#unencryted username / password pairs for automation.

Service telnet

{

Flags = Reuse

Socket_type = stream

Wait = NO

User = root

Server = /usr/sbin/in.telnetd

LOG_ON_FAILURE = UserID

Disable = yes

}

转载请注明原文地址:https://www.9cbs.com/read-105850.html

New Post(0)