The kernel is designed in two ways: single-core and micro-core, both of which have pros and cons, and a comparison of the two can be found in wikis. Windowds and Solaris use a microkernel structure.
The Linux kernel uses a single kernel structure, the design is relatively simple, but the idea of a single core is to integrate all the functions together, it will inevitably lead to the size of the kernel, but the fact that the Linux kernel volume is not large. Because Linux in the design time borrowed from the micro-core design ideas, the kernel module, the use of the function module when used to load again. However, this leads to a problem, in case the kernel does not have a corresponding drive module, then the kernel will not be able to expand on the hard disk, in order to solve this problem designed an excessive product initrd, where Rd is the meaning of RAM disk, to smooth the kernel expansion to the hard disk, and so on after the completion of the task to exit, The kernel can then load the corresponding modules according to the system needs.
On my DEBIAN8 system, the "/lib/modules/kernel version" is the directory where all the kernel modules that end with. Ko are saved, a total of 183MB, the corresponding modules can be loaded when needed, and the kernel files are saved in the/boot directory, only 3MB in size. So the real kernel is composed of "kernel core" and "kernel module", the core is located in/boot/vmlinuz-version, each kernel module (. ko) is located in/lib/modules/version.
The kernel will complete the next task during initialization:
1. Device detection
2. Driver initialization, may load the driver module from the Initrd file, from this point of view initrd can be seen as a temporary Linux system, this temporary system system integrates a relatively full hardware driver (on my dbeian8 INITRD.IMG-3.16.0-4-AMD64 16MB Large) can help the kernel to complete the initialization of the hard disk that is about to expand the system, and when its mission is completed, it exits.
3. Mount the root file system as read-only.
4. Loading the first user space process init process, PID 1, on different systems may be slightly different, mainly upstart and systemd and so on.
User space to deal with the kernel space can be through the/proc and/sys the two pseudo-file systems, the so-called pseudo-file system refers to the files in both directories are false, I have tried to use Vim to edit the following file, the results prompt error. So the files in these two directories are actually some kernel parameters, the file does not exist in this province. And most of the files are read-only. However, /proc/sys files in this directory are writable, but you need to modify the kernel parameters in the same way as Echo and/proc/sys/filename. For example, I can modify/proc/sys/net/ipv4/ip_forward to 1, turn on packet forwarding, echo 1 > Ip_forward, which is more troublesome, In fact, there is a system management tool SYSCTL (configure kernel parameters at runtime) can easily repair the kernel parameters, the use of the method refer to the man manual, such as modify/proc/sys/kernel/hostname The hostname can be modified with Sysctl Kernel.hostname=asen, which will take effect immediately, but will expire after a reboot. To permanently save, you need to edit the/etc/sysctl.conf file to add a single line of parameters, this file provides some examples for reference, but the disadvantage of this method is that after the restart can be permanent, but now cannot take effect, one way is to use the sysctl-p to notify the kernel to re-read the configuration file. the parameters behind the SYSCT command are actually the paths and files in the corresponding/proc/sys directory, sysctl-a can display all kernel parameters and values.
Several common commands for managing kernel modules are:
Modprobe module_name Loading a module
Modprobe-r module_name Uninstalling a module
Modinfo module_name View specific information for a module, including module dependencies
LSMOD lists the modules that are already loaded on the current kernel
Insmod/path/to/module_name Loading a module
Rmmod module_name Uninstalling a module
Linux kernel module design