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
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, this 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 transmits 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 is the version number. each user may have a different host and all modules are here, and the 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, etc, the root file system has 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 replaced by umount, at this point, the kernel can load the required kernel module, and then the system starts.