Linux boot process is run level

Source: Internet
Author: User

Linux boot Processfirst, the concept

1, boot loader: Lead loading program, commonly used (Grub, Spfdisk)

2, Grub: is a multi-operating system Boot manager, boot the different systems, Windows Linux, etc.

second, the start-up process

1. Load the hardware information of the BIOS (basic Input output system) and self-test

2, read and execute the first boot device MBR (Master boot record sector) boot loader that is, Grub Spfdisk and other programs!

3, Grub (boot loader) is a multi-operating system Boot manager, after running is selected system (boot loader--grup after the function of speaking)

4, according to the boot loader settings load kernel (that is, the 3rd step here to select the kernel of the system), loaded in the kernel in memory to extract and execute, detect hardware information load driver

5, after the hardware driver is successful, kernel will call the first user-level program, INIT, Init will get RunLevel (runlevel) information (run level information saved in/etc/inittab file)

6, init execution/etc/rc.d/rc.sysinit file to prepare the software execution environment (such as network, time zone and other information) specific information can be vim/etc/rc.d/rc.sysinit to see

7, init execution run-level of each service is started and this run-level corresponding service

8, the implementation of/etc/rc.d/rc.local file (this is the user to customize the start-up program, the need to automatically run the program to write in this script)

9, init execution terminal emulator Mingtty to start the login program, and finally wait for the user to log in

third, the role of the Bios (basic Input output system)

1, BIOS It is a set of fixed to the computer board on a ROM (read only memory) on the chip program, it holds the computer's most important basic input and output programs, System setup information, post-boot self-test program and system self-start program, he inside the program is the factory burned in, So I can only read and not change.

2, CMOS is a computer motherboard on a read-write RAM chip, mainly used to save the current system hardware configuration and operators of certain parameters set.

3, through the BIOS program to load the CMOS information, and through the CMOS set of values to obtain the host hardware configuration information, such as cup, interface equipment, the frequency of the communication device start-up device sequence, the various interface device I/O address.

4, after obtaining this information, the Bios will also conduct self-test, then start to perform hardware detection initialization, and set the PNP device, then define the device sequence of the boot, then start the boot device data read (MBR related task start) (MBR master boot Record main boot area)

5, because most of the system software is placed on the hard disk, so the BIOS will set up the device so that we can read the disk operating system core files.

6, because different operating system file system format is different, so we must have a boot management program to deal with the core file loading problem, so this boot manager is called boot loader!

7. This boot loader is installed in the first sector (sector), which is what we call MBR (Master boot record boot recording area)

8, each operating system boot loader are different, so that the BIOS how to read the inside of the MBR boot loader that?

9, in fact, the BIOS through the hardware INT13 interrupt function to read the contents of the MBR, that is, as long as the BIOS when the hardware detection if you can detect your disk (whether it is SATA or IDE interface) there is a way to pass INT 13 This channel reads the contents of your MBR in the first sector of the disk, so that boot loader can be executed!

iv. boot loader ( boot loader )

1, the main function of Boot Loader is to understand the operating system file format, and load the selected system core to live memory to execute.

2, because each kind of operating system's file format is different, therefore each kind of operating system has its own boot loader

3, in this case, when the number of operating systems on a machine what to do because the MBR only one, and each operating system has its own boot loader, in fact, each filesystem or main partition will leave the boot sector ( boot sector ), To install your own boot loader so you can install multiple systems and solve the problem.

4, boot loader the main function:

(1), provide a menu: Users can choose their own boot project, which is the important function of multi-boot.

(2), load the core archives: Direct point to the program section of the boot, start the operating system.

(3), transfer other boot loader: The power-on management function to other boot loader responsible.

* * Because of the menu function, we can choose a different core to boot

* * Due to the function of control transfer, we can load the boot loader in other boot sector!

5, when the boot loader management begins to read the core file, Linux will then compress the core into the main memory, and use the core functions, start testing and driving the various peripherals such as storage devices, CPUs, network cards, sound cards and so on. At this point, the Linux kernel will re-detect the hardware information with its own function, and not necessarily use the information that the BIOS detects, that is, the Linux kernel that starts loading at this time takes over the work of the BIOS!

6, to this memory has been loaded kernel and use the function of kernel to detect the hardware and try to hang in the root to obtain additional drivers, but now the kernel does not know the disk, no way to hang in the root directory, so it can not read the driver in the/lib.modules/

7, the kernel does not know the disk, how to hang in the directory, how to load the driver, it is the use of virtual file system (also called temporary file system initrd) to solve

8, the virtual file system is characterized that he can be loaded into memory through the boot loader, and then this file will be decompressed and emulated into a root directory in memory, and this emulation directory can provide an executable program, through this program to load the boot process required modules, and usually these modules are USB RAID SCSI and other file system and disk interface drivers, and so on after these programs are loaded will help the core re-call/sbin/init to start the subsequent normal boot process.

9, to this kernel loaded the required driver, because the driver can find the disk, so mount the root file system, and release the virtual file system.

10, the core active loading the first user-level program/sbin/init

v. First user-level program init, and profile/etc/inittab and run level

1, after the core loaded, hardware information This test and driver load, at this time your host hardware should be ready, at this time the core will be active to call the first user-level program, that is/sbin/init (init is known as all the ancestor process, is also the first user-level process initiated)

2,/sbin/init the main function is to prepare the software implementation of the environment, including the system hostname, network settings, language settings, System file format and other services to start, and all the actions will be through the init configuration files and/etc/inittab to plan.

3,/etc/inittab configuration of the operating level of the system, the bottom of the file is id:n: Initdefault This is the set of system operating level

4, why to set the operating level of the system, this is different: Linux with a set of run levels to plan, the system uses different services to start, so that the use of Linux different environment, according to the network and have no Xwindow can be divided into 7 levels

5. Run level

(0), run Level 0: shutdown

(1), run level 1:single mode is the single-player maintenance mode, generally forget the root password, the system has a problem what the use of this mode

(2), run Level 2:without NFS is no NFS system

(3), run Level 3: Full text mode with network capability

(4), run Level 4: System reserved

(5), run level 5:xwinods and 3 are similar to just plain text into windowed mode

(6), run Level 6: Restart reboot

6, the start of the execution of the file,/etc/rc.d/rc.sysinit that the system data set to complete!

7. Start the system service and boot configuration file/ETC/RC,D/RC N (your system level, start different services at different levels)/etc/sysconfig

8, loading the core let the whole system ready to accept instructions to work, in the/etc/rc.d/rc.sysinit system module and related hardware information initialization, your system should have been working smoothly!

Six, the switch of the operation level

1. In fact, different runlevel just load the service differently, here has run level 3 and run levels 5 are columns: just their/etc/rc.3d and/etc/rc.5d within the sxxname and Kxxname not Same thing.

2. Compare the files in/etc/rc.3d and/etc/rc.5d with the beginning of K and S

3. More K in the new run level has been shut down

4, in the new run level more s are opened, and all exist on the no tube.

Ok so the runlevel is turned!

Linux boot process is run level

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.