|
Start the BIOS program
When the power button is pressed, BIOS (Basic nput Output System) will be run by the flash memory on the motherboard. BIOS program will decompress themselves to the system memory, and then read the CMOS (Complementary Metal Oxide Semiconductor) the storage of information (such as system time, boot device order, etc.) to configure the system. At the same time self-test (POST: Power-On Self Test). Hardware detection system if there are problems, then self-checking, BIOS loads the MBR first boot device (Master Boot Record: master boot sector) in the boot loader program.
It should be noted that is, BIOS bootloader is loaded by hardware interrupt INT 13 functions to be loaded. That is, after the BIOS to read the disk, INT 13 through this channel to read the first sector of the disk in the boot loader program!
Start Bootloader program
The following Linux Bootloader There are many, such as early default LILO, as well as the current mainstream grub. Below the current Linux system above mainstream grub bootloader mainly done to explain what happened?
It will automatically read the configuration file /boot/grub/grub.conf Grub boot, and then execute the command grub! Figure 2.1 is a configuration file grub.conf CentOS6.5 above! Grub command is part of the red box, it is mainly divided into three parts
1. Set boot hard disk partition (root command), passed to the command parameter is the partition, this command will be to analyze and mount the partition, and then read out in one of the / boot folder following. For example, as shown in Figure 2.2, after executing the command, the boot can read the contents of a folder below!
2. Select boot kernel file and set the kernel parameters (kernel command)
3. Load the initrd file, set the virtual file system. (Initrd command)
Of particular note is the initrd file, this is actually a virtual file system (Initial RAM Disk). In the Linux system, some disk driver does not build in the kernel, but is packaged into modules stored in the / lib / modules directory, and when you need to load the kernel boot disk drivers. But the / lib / modules has not been mounted, then it produces a contradiction! To resolve this conflict, it gave rise to the concept of the virtual file system. We can say initrd file is loaded into memory (for fear of affecting the file system on the disk, then the root directory is mounted read-only way to mount), a virtual file system root out, and then read virtual root file system disk driver, and then re-mount the real root directory.
Loading system kernel and hardware drivers
After the program finishes running Grub above three commands, kernel file (vmlinuz - $ (uname -r)) will be extracted to the memory into running! At this time, the kernel will detect it again myself come from a new hardware and load the driver! After the check is complete, the kernel will call the Init procedure, a process to create the first system!
Init process for system initialization
After Init program starts, it will be the first to read the / etc / inittab file for this operating system Run Level (run level). What is the level of running it, Linux system the following depending on whether the network and to the X Window
Run system is divided into seven levels.
This is the description of the mode in which the Linux / etc / inittab file.
0 represents the off mode, Mode 1 represents single-user mode (maintenance mode), Mode 2 represents a multi-user from the command line, but not the network. Mode 3 represents a network comprising multi-user command line mode. Mode 4 is reserved for the system function. Mode 5 represents a graphical interface mode. Mode 6 represents the state of the system is restarted.
Corresponding to each run level, / etc directory are set different directories
Run a system level, or to run the appropriate directory (/ etc / rc [runlevel] .d) within the script file. Here that rc represents the run command, the command starts to run when, on behalf of the .d directory, the directory represents the meaning!
Inittab a file system can be set start level, there are some other features
This is CentOS6.5 above inittab for a description of other configurations.
In short, Init program after obtaining over operation of the system level, we will continue to perform the following functions:
Initializing the system (/etc/init/rcS.conf execute this script file or to run some custom level program run by /etc/init/rc.conf)
Load System Services item (running / etc / rc [runlevel] .d / in the script file)
Set Ctrl + Alt + Del key features
Mingetty six runs to set the appropriate terminals
Run the terminal and accept user login
When the contents of the system initialization is complete, the system will call mingetty function to set up the terminal, and waits for user login! It is this specific process, init process to fork a child process and the child process to exec a getty program. Getty will attempt to open a terminal, if the open is successful, it will display the word on the screen to login, when a user types a user name after the task getty program is complete! It then calls the way to exec login procedure. Login program to read user name and password, and then read the shadow file to verify the user's password is correct. If the password is incorrect, the login by calling exit 1 to exit, then the init process fork again to repeat the above steps.
If the password verification is successful, then the login program will set some operating system environments (such as setting the working directory, set the uid and gid, user name, etc.). After setting up these systems environments, login procedure will be invoked by the shell program exec, shell program execution and read some of the startup script (such as / etc / bashrc, etc.). After reading finish these startup scripts, shell prompt, print out, and then waits for the user to type commands! At this point we will start a normal system! |
|
|
|