Press the power supply, click it, start the computer, and then the BIOS screen will pop up. After a while, the GRUB interface will pop up, and a line after line of characters will pop up on the black screen, from time to time there are OK words. oh, don't worry. Enter your username and password ,.... The system is successfully started. So what happened in this process and what are worth learning? This article describes the relationship between the boot loader, kernel, and root file system based on linux boot.
1) Pilot
This is well-known. grub is commonly used in linux. grub is the mainstream of today. lilo, it's a great time, and now grub has taken over the burden; syslinux is a lightweight Boot Tool, which is usually used as a boot tool on a CD and USB. It should be clear that it can be found in applications without disk startup.
The main function of the bootstrap is to find the kernel (vmlinuz) and load it into the memory. Of course there is also initrd. Taking GRUB as an example, it is written in my system (centos5.2 ).
#/Boot/grub/menu. lst Title Centos 5.2 kernel-2.6.18-92.1.17.el5 Root (hd0, 7) Kernel/vmlinuz-2.6.18-92.1.17.el5 root =/dev/VolGroup00/LogVol00 Initrd/initrd-2.6.18-92.1.17.el5.img Boot |
This clarifies the kernel location and passes some parameters to the kernel. Initrd plays a very important role in loading the driver before the kernel accesses the root file system.
2) Kernel
A complete kernel is generated by the kernel source code. The source code can be found at kernel.org, which is about 50 MB after compression and several hundred MB After decoding, we can recompile the source code to update our existing kernel to improve performance and compatibility. So what did the source code output after compilation? Let's take my machine as an example:
A) the kernel is in the/boot partition.
/Boot/initrd-2.6.18-92.1.17.el5.img /Boot/System. map-2.6.18-92.1.17.el5 ................ This is a symbolic table. The ing between functions and addresses /Boot/vmlinuz-2.6.18-92.1.17.el5 /Boot/config-2.6.18-92.1.17.el5 ............................. The configuration file of the kernel, which is generated by the make xconfig command |
B) In the kernel module section, under the/lib/modules/2.6.18-92.1.17.el5 directory, 2.6.18-92.1.17.el5 indicates the version number, which may be different for each user. All modules are here and there is dependency between them.
[Root @ xx 2.6.18-92.1.17.el5] # pwd /Lib/modules/2.6.18-92.1.17.el5 [Root @ xx 2.6.18-92.1.17.el5] # ls-l Total 1128 Lrwxrwxrwx 1 root 48 11-11 20:14 build->.../usr/src/kernels/2.6.18-92.1.17.el5-i686 Drwxr-xr-x 2 root 4096 11-05 0:09 extra Drwxr-xr-x 10 root 4096 11-11 kernel ................................. This directory is in the kernel module. Drwxr-xr-x 2 root 4096 11-13 14:50 misc -Rw-r-1 root 252332 11-13 modules. alias -Rw-r-1 root 69 11-13 modules. ccwmap -Rw-r-1 root 209702 11-13 modules. dep ...................... Dependencies between modules -Rw-r-1 root 147 11-13 modules. ieee1394map -Rw-r-1 root 375 11-13 modules. inputmap -Rw-r-1 root 2314 11-13 modules. isapnpmap -Rw-r-1 root 74 11-13 modules. ofmap -Rw-r-1 root 191108 11-13 modules. pcimap ................... Relationship between physical devices and Kernel Modules -Rw-r-1 root 589 11-13 modules. seriomap -Rw-r-1 root 105259 11-13 modules. symbols -Rw-r-1 root 322731 11-13 modules. usbmap Lrwxrwxrwx 1 root 5 11-11 20:14 source-> build Drwxr-xr-x 2 root 4096 11-05 0:09 updates Drwxr-xr-x 4 root 4096 11-11 20:14 weak-updates |
Note that the source and build directories should be known when the graphics driver is installed,
C) header files and related Kernel configuration files
/Usr/src/kernels/2.6.18-92.1.17.el5-i686. files in this region are required to construct or compile the relevant kernel modules. The files in this directory are used when the video card driver is installed, is there any image? Why? Of course, I want to see the 3D desktop, right ....
[Root @ xx 2.6.18-92.1.17.el5-i686] # pwd /Usr/src/kernels/2.6.18-92.1.17.el5-i686 [Root @ xx 2.6.18-92.1.17.el5-i686] # ls Arch drivers init kernel mm net sound Block fs ipc lib Module. kabi scripts symsets-2.6.18-92.1.17.el5.tar.gz Crypto include kabi_whitelist Makefile Module. symvers security usr |
The header file is in the include directory.
3) root file system
The root file system is very familiar with the spread. After the boot, the system enters the root file system, including/boot,/usr,/bin,/var, and so on.
The boot loader, kernel, and root file system have a rough image. Now let's talk about some things about them.
The bootstrap looks for the kernel, such as GRUB, which can read the file system in which the kernel is located on behalf of a driver, for example, syslinux, which is the kernel found through the sector address, initrd has an executable file named linuxrc or init (which can also be a shell script). It provides a virtual root environment, loads the hard drive, and reads the root file system, make material preparations for Kernel root swap (from the virtual root environment to the root file system. After the kernel is switched to the root file system, the previous virtual root environment has been destroyed by umount. Now the kernel can load the required kernel modules, and then the system starts.
- Detailed tracing of GRUB startup
- Linux Startup Process and Grub Configuration
- How to Use the Grub command to start a corrupted Linux System