CentOS boot process Detailed

A, Linux boot process:

Here Insert Picture Description
The BIOS:
(the Input the Output the System Basic) Basic Input Output System, which is curable to a set of procedures on a computer within the ROM chip on the motherboard, a computer program holds the most important basic input output system and the POST program from start the program, the specific information can be read from the system settings CMOS.

MBR: Master Boot Record, Master Boot Record area.
Boot Loader: boot loader.

Second, a detailed flow

The first step: load the BIOS
Turn on the computer, the computer hardware will automatically load the BIOS, the BIOS reads the relevant hardware information and self-test hardware systems, then find the configuration of a program guide apparatus according to the BIOS.

Step Two: reading MBR
hard disk's first sector of the first track 0 is called MBR, the master boot record size is 512 bytes, storing the pre-boot information, partition table information. After the system finds the hard disk MBR BIOS specified, it will be copied into the physical memory, the physical memory is copied to the contents is Boot Loader (lilo or grub).

The third step: Loader starts the Boot
the Boot Loader is a small program that runs before the operating system kernel to run. Through this small program, we can initialize the hardware devices, the establishment of memory space map, so the system hardware and software environment to bring an appropriate state, in order to make everything ready for the final call to the operating system kernel.
Boot Loader There are several species, including Grub, Lilo is a common Loader.
Taking an example to explain Grub, GRUB functions: provide a menu that allows the user to select the system or to start a different kernel version; the user selected kernel loaded into the RAM in a particular space, decompress, expand.

Grub system reads memory configuration information (typically menu.lst or grub.conf), and in accordance with the configuration information to specify core loading.
Here Insert Picture Description
Step four: Load the kernel
grub handing over control to the system kernel, which began probing recognizable to all hardware devices and attempt to mount the root directory for its driver. At this point you need to first load the disk driver to read the disk, and the disk drivers and stored in the disk, which would result in linux not start. At this point need to solve this problem by pseudo file system.

Virtual File System (Initial RAM Disk) i.e. /boot/initramfs-release.img, this document features that can be loaded into memory by the boot loader, then the file is decompressed, and is modeled as a root directory in the memory of them and this simulation in memory among the file system can provide a program that can be run through the program to load the kernel module during startup are most needed, usually these modules is U disk, RAID, LVM, SCSI and other file systems and the driver disk. Once loaded, the core will help to re-call / sbin / init to start the follow-up of the normal startup process.

Note: RamDisk supporting documents is not necessary, depending on whether the kernel can directly drive device root file system is located.
Here Insert Picture Description
Step Five: Run / sbin / init program, run level setting of linux
after the kernel is loaded, the first application in the user space is running / sbin / init, then read the / etc / inttab files, according to configuration settings file given system run level
Here Insert Picture Description
step Six: init process executes rc.sysinit
after setting the run level, Linux systems to perform /etc/rc.d/rc.sysinit system initialization script. Initialization comprising: providing a host name, a banner, and activation Udex seliux, mount / etc all file systems / fstab file defined in detecting the root file system, set the system clock, is set according to the kernel file /etc/sysctl.conf parameters, activation of LVM and software RAID devices, activate the swap device, load additional device drivers, perform cleanup operations.

Step Seven: Start the kernel module
specifically according to / etc / sysconfig files in the file directory modules / kernel modules to load.

Step eight: Perform run-level of each service is started (script mode)
Depending on the operational level, the system will run rc0.d to rc6.d the appropriate script to complete the corresponding initialization and start the appropriate service .
Here Insert Picture Description
Step 9: execution /etc/rc.d/rc.local
rc.local is, after all initialization, Linux users left to local personalization. You can set up and you want to start something put here.
Here Insert Picture Description
Step 10: execute / bin / login program, enter login status
Linux will start the X Window terminal or wait for the user to log in.
Here Insert Picture Description

Published 180 original articles · won praise 13 · views 7162

Guess you like

Origin blog.csdn.net/weixin_45794138/article/details/104897246