This paper simply introduces the startup process of Linux, and makes a brief analysis on this basis. For the Linux boot process in the internal detailed function calls do not introduce, just hope this article can give novice play a role, in order to further study the Linux startup process. Basically shows the basic process of Linux startup, only for the individual learning summary, such as the big God to shoot bricks, welcomed.
A BIOS self-test:
Some common sense that should be understood:
The BIOS consists of two main components: the POST (Power on system test) code and the runtime service;
The purpose of post is to detect the hardware;
1. When the computer is power-up, the first post (Power on system test) self-test is performed by the BIOS.
That is, the first step is the power-on, post self-test. The boot block is then read from the hard disk, floppy disk, or CDROM according to the boot sequence set in the BIOS;
2. The second step of the BIOS is to enumerate and initialize the local device.
Typically, Linux systems are booted from the hard disk, where the master boot directory (MBR) contains the master boot directory loader, which is a 512-byte sector that is located on a sector of the disk. That is, the first sector of each disk in the MBR,MBR of the disk is recorded in the first 446 bytes of the boot Loader,boot loader installed in the Grub Stage1, which points to the location of the GRUB main program on the disk. After power-on, the BIOS finds the corresponding disk according to boot sequence, and then searches for the MBR of the disk. Locate the Grub program that is located on the basic disk partition, enter the Stage2 phase, and boot the kernel and initrd according to the grub.conf configuration file. When the MBR is loaded into RAM, the BIOS will give control to the MBR.
To view the contents of the MBR: (provided that the root user)
DD IF=/DEV/SDA of=mbr.bin bs=512 count=1
Od–xa Mbr.bin
Check what you see is (both binary):
Two . Start Grub/lilo
Both grub and Lilo are boot loaders that are used primarily to boot the operating system.
Only one operating system's boot record can be stored in a single MBR, so when more than one operating system is required, problems arise and a more flexible bootloader is required.
the difference between grub and Lilo:
Grub has an interactive command interface;
Grub supports network booting;
Lilo can boot the operating system location information stored in the MBR;
*: If the Lilo configuration file has an error, the system will not boot, and when using grub, if there is an error in the configuration file, the system will go to the Grub command interface by default.
Configuration file for grub: /boot/grub/grub.config
Like, after entering cat grub.conf , press the ENTER key:
Three Load kernel:
Loading the kernel image into memory, the kernel image is not an executable kernel, but a compressible kernel image. In front of this kernel image is a routine that implements a small set of hardware settings, decompressing the kernel contained in the kernel image, and then putting it into high-end memory. If a RAM disk image is initialized, the system will move it into memory and indicate that it will be used later, then to the routine to invoke the kernel and start the kernel boot process.
Four. executing the init process
The init process is the starting point for all processes in the system and is the initiator and controller of all processes. Because it is the first running process in any Linux-based operating system, the process number (PID) of the Init process is always 1.
After the kernel is booted, the INIT program is loaded in the process space, and its process number is 1, which is used primarily to perform some boot initialization scripts and monitoring processes. such as: Init reads the information from the system boot profile/etc/inittab to initialize it.
About the role of the INIT process:
- Play the role of ending the parent process: Because the init process never terminates, the system can always confirm its existence and use it as a reference when necessary;
- When you enter a particular runlevel, you run the appropriate program and manage the various runlevel, which is defined by the file/etc/inittab.
Five. For other
/etc/rc.d/rc.sysinit system initialization script;
/ETC/RC.D/RCX.D/[KS] *-Assigning services based on RunLevel X, terminating services beginning with "K" and initiating services starting with "S";
/etc/rc.d/rc.local perform local special configuration;
Finally, other services.
author : itred Blog URL: http://www.cnblogs.com/itred Learning Exchange e-mail : [email protected] This blog you can freely reproduced, However, keep the original author information and the article link URL.
Recommended reference reading:
6 Stages of Linux Boot Process (Startup Sequence) http://www.thegeekstuff.com/2011/02/ linux-boot-process/
"Linux booting Process"http://resources.infosecinstitute.com/linux-booting-process/