Detailed analysis of Linux boot process

Source: Internet
Author: User
Tags ide hard drive
Article Title: detailed analysis of the Linux system boot process. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Linux boot process

First of all, here we will talk about the Linux boot process without the internal details of the KERNEL boot process. I hope this article will be helpful to Linux beginners.

1. From BIOS to KERNEL

After the computer is powered On, the BIOS first conducts Self-check, that is, the so-called POST (Power On Self Test ), then, read the boot block from the hard disk, floppy disk, or CDROM according to the boot sequence set in the BIOS ". For example, if the boot sequence set in BIOS is C at the beginning, read the 0th cylinder and 0th slice of the C drive (the first IDE Hard Drive) into the memory, then jump there to start execution. This sector has a familiar name-MBR (Main Boot Record ). In other words, MBR stores a small piece of program and partition table data. When using WIN9X and DOS, the Code put here marks the first sector of the Active partition in the Partition Table (usually stores the operating system's Boot Code) read the memory and jump to it to start execution.

When using LILO to guide LINUX, there are two options:

(1) install LILO in MBR. In this case, the BIOS directly calls the LILO code into the memory, and then jumps to execute LILO.

BIOS --> LILO (in MBR) --> KERNEL

(2) install LILO in the LINUX partition and set the LINUX partition to Active. In this case, the BIOS calls the MBR code Under WIN9X/DOS, and then calls the code of LILO (located in the first sector of the active partition ).

BIOS --> MBR --> LILO (the first sector in the active partition) --> KERNEL

Because the operating system is not available when reading and executing MBR, you can only use INT13 provided by BIOS for disk operations, while INT13 can only read and write data before the hard disk's 1024 cylinders, we can see that the boot code of any operating system must be before the 1024 cylinder. For LINUX, whether you start using method (1) or method (2), ensure that the KERNEL is placed before the 1024 cylinder. Only after the KERNEL is up can the system read/write data after 1024 cylinders. Because LINUX does not use INT13 for hard disk operations. We can also see from the above that there is no "WIN95 is acceptable, but LINUX is not allowed" problem, as the operating system should be correctly guided, in the existing BIOS, their boot part must be before the 1024 cylinder. If the operating system is still based on INT13

For disk operations, it can only read/write data before the 1024-inch cylinder.

Ii. From KERNEL to login prompt

After the KERNEL is up, the first process -- init will be generated, which is actually executed by/sbin/init. Init performs system initialization Based on the/etc/inittab script, such as setting the keyboard, Font, loading module, and network.

Each line of the/etc/inittab file contains four fields:

Id: runlevels: action: process

Runlevel is the running mode, usually 0-6. Mode 0 is halt, mode 6 is reboot, Mode 1 is a single user, mode 2/3 is a multi-user, and mode 5 is run xdm to log on as a graphical interface. Id is an identifier, usually two letters. Process is the program or script to be executed. Actions include:

(1) defaultinit -- specify the default running mode (runlevel)

(2) sysinit -- specifies the first program/script to run. The runlevels field does not work at this time.

(3) boot -- run after sysinit, And the runlevels domain does not work

(4) bootwait -- same as boot, but init will wait for the end of the command

(5) once -- run when you enter the running mode specified by runlevels

(6) wait -- same as above, but init will wait for the command to end

(7) respawn: run the command when the corresponding runlevel is entered. If the process ends, init starts another process to execute the same command.

(8) ctrlaltdel -- specifies the command to be executed when the user presses Ctrl-Alt-Del. For Redhat, the execution order is:

/Etc/rc. d/rc. sysinit # The first script executed by init

/Etc/rc. d/rc $ RUNLEVEL # $ RUNLEVEL is the default running mode.

/Sbin/mingetty # Wait for User Login

[1] [2] Next page

Related Article

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.