A detailed description of the startup process and system initialization of Linux system

Source: Internet
Author: User
Tags create directory

First, the Linux system startup process

The start-up process for Linux systems can be divided into the following steps:

Post power-on self-Test-->bios (boot Sequence)--loads the MBR on the corresponding boot (bootloader)--and the master boot setting loads its Bootloader-->kernel initialization-- Initrd->/etc/init process Load/etc/inittab, its process flowchart is as follows:

Second, the detailed START process analysis

    1. Post post: When the host computer is powered on, it will then hear a drop of sound and the system starts to post (Post-power on self

    2. Test), the process is mainly to detect computer hardware equipment such as: CPU, Memory, motherboard, video card, CMOS and other devices have failed to survive

    3. In, if there is a hardware failure, it will be in two cases: for a serious failure (fatal failure) downtime, at this time due to a variety of initialization operations are not completed,

    4. Can not give any hint or signal, for non-serious failure to give a hint or sound alarm signal, waiting for the user processing), if there is no fault, post complete their own

    5. Relay task, the tail work will be handed over to the BIOS processing.

⑵,

    1. BIOS: The first place to read the computer after the power-on self-test is the BIOS (basic input output system, basic inputs and outputs)

    2. , the chipset and related settings of the motherboard are recorded in the BIOS, such as the frequency of communication between CPU and interface devices, the search order of boot devices, the size of the hard disk and

    3. Type, system time, external bus, I/O address of various interface devices, IRQ interrupt information that has been communicated with the CPU, so, start if you want to start smoothly,

    4. The first thing to read is the BIOS settings.

⑶,

    1. Follow the system boot process set by the BIOS and, if detected, start on the first device based on the boot sequence (boot Sequence)

    2. program, our boot device mainly includes hard disk, USB, SD, etc., we generally use the hard disk, and then read the first device is the hard disk, the first

    3. To read is the main boot record of the drive MBR (Master boot record), then the system can be installed according to the ScanDisk

    4. The boot loader (boot Loader) begins to perform the core recognition work. "In this plug-in: MBR program just find just hard disk partition within the front

    5. The 446-byte boot Loader "then look for the relevant configuration and definitions.

⑷,

    1. Boot Loader Loading Grub Program

    2. In this process, the grub is primarily started by booting, and grub is divided into a single phase:

    3. Stage1: the main boot loader

    4. Stage 1.5: Transition

    5. Stage2: Mainly/boot/grub

Through the above we can find that Linux kernel Vmlnuz,grub, initrd are in the/boot directory

Below the/boot/grub/we see the familiar Stage1,stage2 and Grub tool configuration file grub.conf, so what is defined in the grub.conf??

⑸, Kernel

    1. As defined in grub, after the grub has been read, the following work is delivered to the kernel. Kernel is mainly to complete the system hardware detection and hardware driver initial

    2. and mount the root filesystem (root switch) in a read-write manner, then there is a "chicken or egg file first", what exactly?

    3. That?

    4. To access the real root file system (ROOTFS), the device in the root filesystem must be loaded, and the root file system is not mounted.

    5. To mount the root file system and load the driver from the root filesystem, what do you do? In order to solve this problem, this is the use of the Initrd file.

    6. In terms of the kernel initialization of the content to be done to do a simple summary:

    7. Probing hardware-> Load Driver (INITRD)-> Mount root filesystem->rootfs (/sbin/init)

⑹,

    1. To this end of the kernel space related work has been completed, the task of the kernel space began to transfer to the user space, kernel space through an indirect initrd (micro

    2. Linux)/sbin/init over the user space, so gurb started booting the kernel to INITRD.

    3. INITRD: A virtual file system that contains lib, bin, sbin, usr, proc, sys, VAR, dev, boot, and other directories,

    4. In fact, you will find the directory is a bit like the real/right, so we call it a virtual root filesystem, the role is to kernel and the real root file system

    5. Establish an affinity relationship that allows kernel to load the driver required by the root filesystem in Initrd and mount the root filesystem in a read-write manner, and let the execution

    6. The first process init of the user.

Let's look at what's inside the init script:

From the script content above we can see the main work of the INIT process:

    1. Mount: Mount/proc in Initrd,/sys/dev to the corresponding directory in the current primary partition

    2. Create directory:/dev/mapper

    3. Complete the creation of block or character special files via Mknod

    4. Mounting of related modules

    5. Creating a root device

    6. Mount/sysroot

    7. Finally complete the root switch

⑺, Init after the completion of the system will start the/etc/inittab file, to complete the system system initialization work. Let's take a look at the details of Inittab in this configuration file:

Definitions for each level:

Default Run Level

    1. 0:halt//Shutdown

    2. 1:single user mode//single user maintenance mode)

    3. 2:multi user mode, without NFS//NFS feature not supported

    4. 3:multi user mode, text mode//character interface

    5. 4:reserved//System retention

    6. 5:multi user mode, graphic mode//graphical interface

    7. 6:reboot//restart

/etc/inittab format and syntax (:)

    1. [Option]:[runlevel]:[behavior]:[Command]

    2. Behavior:

    3. Initdefault: Represents the default run level

    4. Sysinit: Represents system initialization Operation options

    5. Ctrlaltdel: Related Settings for restart

    6. Wait: Performs the following actions on behalf of the last Command execution end

    7. Respawn: Represents a trailing field that can be regenerated indefinitely (reboot)

    8. Command options

    9. Some commands, but they're usually scripts.

The following is the initialization script defined in Inittab: Rc.sysinit--/etc/rc.d/rc.sysinit

    1. As shown: Some definitions of system initialization are defined in the Rc.sysinit script

    2. Set host name

    3. Detect and mount other file systems in/etc/fstab

    4. Start swap partition

    5. /etc/sysctl.conf Setting Kernel parameters

    6. Load key Mapping--> function of each key on the keyboard

    7. Then run the related service script according to the system run level:/etc/rc.d/init.d/script and/etc/rc.d/rc#d

    1. RC0-RC6 directory under script:

    2. k* # #只要是以K开头的文件均执行stop工作

    3. s* # #只要是以S开头的文件均执行start工作

    4. 0-99 (The order of execution, the smaller the number is executed first)

    5. User-defined boot loader (/etc/rc.d/rc.local)

    6. You can write some execution commands or scripts into the/etc/rc.d/rc.local according to your own needs, and when you boot, you can load the

Iii. Summary

The general summary of the system initialization is summarized as follows:

  1. Initialization of the hardware, initialization of the image interface (if the default boot base is set)

  2. Host RAID setup initialization, device mapper and associated initialization,

  3. Detects the root file system and mounts it in read-only mode

  4. Activating Udev and SELinux

  5. Set Kernel parameters/etc/sysctl.conf

  6. Setting the system clock

  7. Enable swap partition, set host name

  8. Loading keyboard mappings

  9. Activating RAID and LVM logical volumes

  10. Mount additional file system/etc/fstab

  11. Finally, according to the Mingetty program call login to let the user login-> User Login (complete system boot)

  12. During system startup, the main scripts and directories are:

  13. Boot

  14. /grub

  15. /boot/grub/grub.conf

  16. /boot/initrd+ kernel version

  17. /INITRD file/proc//sys//dev/directory mount and Root switch

  18. /etc/inittab Script

  19. /etc/rc.d/rc.sysinit scripts, etc.

These are important scripts and directories, as well as other important directories and files, scripts, and so on. In this article we can learn more about the Linux system startup and initialization process, and then we can according to the Linux system startup process and the command used to DIY a micro Linux system, about the "DIY Micro Linux System" will be published in three days post, And then we'll be together. Explore the components of the Linux system in more detail related

Information!!!

Transferred from: http://chrinux.blog.51cto.com/6466723/1192004

A detailed description of the startup process and system initialization of Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.