Analysis of boot process for Linux system boot

Source: Internet
Author: User
Tags file system numeric value centos

Linux is free open source software, in Linux, everything is a file, whether it is a command, operation, etc. are saved as a file, this blog to record the Linux boot process through which to write the file to complete.

The Linux version used is the ideal version of Centos5,centos and Ubuntu when they are in contact with each other.

The following is an example of the CentOS5.5 version, which describes the Linux boot process as follows:

Each step is described in detail below:

1 The first step firmware the firmware self-test, mainly carries on the Cmos/bios to the hardware carries on the post to carry on the self-test, at the physical level to the hardware examination is normal. For example, check if the hard drive is plugged in.

2 The second step to read the bootloader of the MBR in the hard drive, since the start of the program, Linux is commonly used since the boot program is grub. The main function of this step is to load the kernel. The kernel is stored in the/boot directory

3 The third step is to load the kernel kernel process,

The main functions are: 1, drive hardware, kernel contains a large number of drivers. 2, start the init process.

4 The Init process, mainly reads the/etc/inittab file, executes the default run level, and continues booting. Need to note that the Init capital of the PID is 1, is the parent process of all processes, and the init process of the negative view is 0, for the kernel Scheduler kernel scheduler.

5)/etc/inittab defines the initialization of the operation.

The main format of the command is: id:runlevels:action:process

Where, as shown in the red box above

1, run-levels operation level has 7, 0-6 are as follows:

0--halt shutdown

1--single User Mode Single-user

2--multiuser,withoutnfs multiuser mode with no network (text mode)

3--full multiuser mode full-featured multiuser modes (text mode)

4--unused Reservation

5--X11 graphical multi-user mode

6--reboot reboot

Can be switched based on these 7 run levels

Command is: View current run level #runlevel, switch run level #init [0 |1 |4 |5 |6]

2, and Acion also have several important values:

1 Initdefault: Specifies the operating level of the system default boot, as shown in the above figure, usually used for repair, for example, we want to enter Single-user mode, you can set it to 1, you cannot set the default to 0 or 6, otherwise it will not start.

2sysinit: System initiates execution of the commands specified in the process

As can be seen from the contents of the Inittab file, no run level is set, that is, regardless of the run level, the execution of the/etc/rc.d/rc.sysinit

6 Initdefault, as mentioned in the fifth step, is mainly to read the information in the/etc/inittab to determine what the default run level is.

7)/etc/rc.d/rc.sysinit

Run to line 21st in the Inittab file and change to start the script. Complete system service program startup, such as system environment variable setting, setting system clock, loading fonts, checking loading file system, generating system startup information log file, etc. Because it is the underlying service because its run-level is set to null:: That is, any level, the action is set to Sysinit. That is, the script starts at any run level to complete the start of the underlying service

8 when the basic service is started, the/ETC/RC.D/RC script is executed

After loading the base service, it is necessary to start the corresponding directory according to the different running levels, it works is to judge the system's default run level is the 6th step, and then execute the corresponding RCN.D directory of the service startup script as shown

9 Execute the Service startup script under the/ETC/RC.D/RCN.D directory

Look at the contents of this directory:

where s represents the script to start, K indicates the script to be closed

The number represents the starting order, and the numeric value is small. Mainly for the management of some services

In this step, you need to explain the/ETC/RC.D/INIT.D directory, where the script is the real script, and RCN.D is placed in the INIT.D directory of soft connections, which means that all rcn.d files in the end need to come to INIT.D to find the real script

Take a look at specific details:

To perform this step, the interface prompts for the username and password, which means that the system is up and the process of entering the username and password is followed by the end of the boot process.

Finally, the Linux boot process is the same idea, but the details because of the version of the problem, in the configuration file name or location are different, this time I used the CentOS version, and the Ubuntu version is not inittab files and grup.conf files, So if you are interested, you can follow this way to explore and explore.

PS: About GRUB

GNU GRUB (referred to as "Grub") is a boot loader from the GNU project. Grub is an implementation of the multiple-boot specification, which allows users to have multiple operating systems in the computer at the same time, and select the operating system that they want to run when the computer starts. Grub can be used to select different cores on the operating system partition or to pass startup parameters to these cores.

The predecessor of GNU Grub is Grand Unified Bootloader. It is mainly used in Unix-like systems; As with most Linux distributions, the GNU system uses GNU GRUB as its initiator. Solaris started with GNU GRUB on the x86 system since version 10 1/06.

Grub can be configured dynamically, it loads configuration information at startup, and allows modifications at startup, such as selecting a different kernel and initrd. To this end, GRUB provides a simple, bash-like command-line interface that allows the user to write a new boot sequence.

Grub is very lightweight. It supports a variety of executable formats, which, in addition to operating systems that support multiple booting, supports operating systems that do not support multiple booting, such as Windows and OS/2, through the link-start feature. Grub supports all UNIX file systems, also supports the FAT and NTFS file systems that Windows applies, and also supports LBA mode. Grub allows the user to view the contents of files in the file system that it supports.

Grub has a variety of user interfaces. Most Linux distributions use Grub's support for the graphical interface to provide customized boot menus with background patterns and sometimes mouse support. By setting up the text interface of grub, the remote terminal can be started by serial port.

Grub can download operating system mirrors from the network, so it can support diskless systems. GRUB supports decompression of its mirrors before starting the operating system.

Unlike other initiators, grub can interact directly with the user through the grub prompt. You can enter the Grub command line by typing the C key under the Grub text mode screen before loading the operating system. You can also enter the GRUB prompt on systems that do not have a job system or have an operating system without a "menu.lst" file. With a bash-like command, the GRUB prompt allows the user to manually start any operating system. You can automatically start an operating system by recording the appropriate commands in the "menu.lst" file.

Grub has a wealth of terminal commands that you can use at the command line to view the details of a hard disk partition, modify partition settings, temporarily remap the disk order, start from any user-defined profile, and view the configuration of other initiators on the file system that grub supports. Therefore, even if you do not know what is installed on a computer, you can start an operating system from an external device.

Grub uses the scrolling screen to select the operating system that you want to start. By adding relevant information to the "menu.lst" file, grub can control 150 or more startup options and use the arrow keys to select them at startup.

With a chained boot, one initiator can start another. Grub can boot from DOS, Windows, Linux, BSD, and Solaris systems with commands from 2 to 3 lines.

Although grub compiles and packs for Unix-like systems, it also has grub for DOS and Windows. Grub can also be installed as an orphaned system without any operating system attached to it. When booting from a CD, you need 1 files to use grub, and 2 files to boot from a floppy disk, hard disk, and USB device. These files can be found on any Linux CD that supports grub, and users can easily find them.

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.