From GRUB to kernel from kernel to root file system

Source: Internet
Author: User
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:

  1. #/Boot/grub/menu. lst
  2. Title Centos 5.2 kernel-2.6.18-92.1.17.el5
  3. Root (hd0, 7)
  4. Kernel/vmlinuz-2.6.18-92.1.17.el5 root =/dev/VolGroup00/LogVol00
  5. Initrd/initrd-2.6.18-92.1.17.el5.img
  6. 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.

  1. /Boot/initrd-2.6.18-92.1.17.el5.img
  2. /Boot/System. map-2.6.18-92.1.17.el5 ................ This is a symbolic table. the ing between functions and addresses
  3. /Boot/vmlinuz-2.6.18-92.1.17.el5
  4. /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.

  1. [Root @ xx 2.6.18-92.1.17.el5] # pwd
  2. /Lib/modules/2.6.18-92.1.17.el5
  3. [Root @ xx 2.6.18-92.1.17.el5] # ls-l
  4. Total 1128
  5. Lrwxrwxrwx 1 root 48 11-11 20:14 build->.../usr/src/kernels/2.6.18-92.1.17.el5-i686
  6. Drwxr-xr-x 2 root 4096 11-05 0:09 extra
  7. Drwxr-xr-x 10 root 4096 11-11 kernel ................................. This directory is in the kernel module.
  8. Drwxr-xr-x 2 root 4096 11-13 14:50 misc
  9. -Rw-r-1 root 252332 11-13 modules. alias
  10. -Rw-r-1 root 69 11-13 modules. ccwmap
  11. -Rw-r-1 root 209702 11-13 modules. dep ...................... Dependencies between modules
  12. -Rw-r-1 root 147 11-13 modules. ieee1394map
  13. -Rw-r-1 root 375 11-13 modules. inputmap
  14. -Rw-r-1 root 2314 11-13 modules. isapnpmap
  15. -Rw-r-1 root 74 11-13 modules. ofmap
  16. -Rw-r-1 root 191108 11-13 modules. pcimap ................... Relationship between physical devices and kernel modules
  17. -Rw-r-1 root 589 11-13 modules. seriomap
  18. -Rw-r-1 root 105259 11-13 modules. symbols
  19. -Rw-r-1 root 322731 11-13 modules. usbmap
  20. Lrwxrwxrwx 1 root 5 11-11 20:14 source-> build
  21. Drwxr-xr-x 2 root 4096 11-05 0:09 updates
  22. 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 ....

  1. [Root @ xx 2.6.18-92.1.17.el5-i686] # pwd
  2. /Usr/src/kernels/2.6.18-92.1.17.el5-i686
  3. [Root @ xx 2.6.18-92.1.17.el5-i686] # ls
  4. Arch drivers init kernel mm net sound
  5. Block fs ipc lib Module. kabi scripts symsets-2.6.18-92.1.17.el5.tar.gz
  6. 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.

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.