By Wing, Source: LinuxAid
First, what is Modules?
The literal meaning of Modules is the module, which refers to kernel modules; simply, a module provides a feature, such as ISOFS, Minix, NFS, LP, etc. Traditionally, modular has two methods to solve: designers can separate all functions into separate threads, or to recompile the kernel to include / exclude some functions. If the function is separated into the thread, then the kernel is called "Micro-Kernel", which adds communication overhead that coordinated between threads. As in the name of the name, the advantage of this solution is the size of the kernel.
Linux solutions are included in the kernel module, which can be loaded and removed at any time as needed. This can make the size and traffic of the kernel to minimize. Unlike the module from the kernel, do not have to be "tied" in Kernel Codes. There are three advantages: First, when modifying KERNEL, it is not necessary to re-compile, save a lot of time; That is; third, reduce the occupation of the kernel to system resources, the kernel can concentrate on do the most basic thing, and put some extensions into the Modules implementation.
The module can also be used to try new kernel code without having to create and strengthen the kernel each time. However, the problem that does this is that the use of the kernel module usually slightly increases performance and memory expenditure. A loading module will definitely produce more code, this code and additional data structures take up more memory. In addition, the efficiency of the module is slightly lowered because indirect access to kernel resources.
Modular ideas have been widely accepted, mainly because it can extend the functionality of the system, and users can configure the system. Apache also adopted this functional extension method, which is mainly discussed in this article to install and uninstall the kernel module, and the APACHE module is installed. Please refer to the relevant documentation of the APAPCE.
Second, how to load the module?
There are two ways to load the kernel module. The first kind of inSmod command manually puts it into the kernel. Another more intelligent method is to load this module when needed: This is called on-demand loading. When the kernel finds a module, for example, when the user installs a file system that is not in the kernel, the kernel will request the kernel daemon (kernel) to try to load the appropriate module. If you say that you can't mention the kernel daemon, it is very clever, you can take the initiative to automatically insert the modules you need to automatically insert KERNEL, and you will have no use of Module to clear from Kernel. Kerneld consists of two separate parts: a part of the Linux kernel is responsible for sending a request to the DAEMON; the other part works in the system's user data area, which is responsible for transferring the modules specified by the kernel request. If this kind of Kerneld is only manually, it can be loaded with the Insmode or ModeProbe command.
Third, Modules related commands
The command related to Modules is:
LSMODE: Lists modules that have been transferred by the kernel
Insmode: Insert a MODULE into the kernel
RMMOD: Uninstall a MODULE from the kernel
DEPMOD: Generates a dependent file, telling the future Insmod to quote from Modules. This dependency file is in / lib / modules / [your kernel version] /modules.Dep.
Kerneld: The automatic transfer module into the kernel and uninstall the module from the kernel. Fourth, compile a minimum Linux kernel
The module is generally used to support those functions that are not often used. For example, usually you only use a dial-up network, so network features are not needed, then you should use the loadable module to provide this feature. This module is only loaded when you dial-up join. It will be automatically removed when you disconnect the connection. This will make the kernel to use the amount of memory minimum, reduce the load of the system.
Of course, those that are needed when the hard disk is accessible, must be made in the kernel. If you take a network workstation or web server, the network function is needed, you should consider compiling the network function to the kernel. Another method is to load the network module when starting. The advantage of this method is that you don't need to recompile the kernel. The disadvantage is that network functions cannot be particularly efficient.
According to the above principles, we first list one list to see which options in the kernel are not, that is, these things must be compiled into the kernel. Except for those non-essential modules to the kernel.
The first is the hard disk configuration where root is located. Where is your hard drive is an IDE interface, tagged down the IDE's option. If it is an SCSI interface, tabulate your interface parameters and SCSI ID.
The second is which file system is selected. Linux's default file system is ext2, then you must mark it down. If you have other operating systems in the machine, such as Win98 or Windows NT, you may also choose FAT32 or NTFS support, but you can add new module support by manually loaded.
The third is to select the executable file format supported by Linux. There are two formats available here:
ELF: This is the current Linux commonly supported executable file format, must be compiled into the kernel.
A.out: This is the format of the old version of Linux executable files. If you confirm that you don't use the executable of this format, you can compile it into the kernel.
These content must be compiled into the kernel. Other contents are that m prompts in all options, which can be added to the module by manually.
** LOADABLE MODULE SUPPORT * ENABLE LOADABLE MODULE Support (config_modules) [y / n /?] Set version
Information on All Symbols for Modules (config_modversions) [N / Y /?] Kernel Daemon Support (E.G.
AutoLoad Of Modules (config_kernel) [y / n /?]
Their answer y, n, y, respectively. Where the config_kernel's default value is n, so pay attention to select Y.
After Make config, it is still make Dep; make clean.
Next to make Zlilo or make Zimage.
Then Make Modules; Make Modules_Install. After completing, you have compiled a "clean" kernel image file that does not transfer the extra modules.
5. How do you manually load Modules?
If you want to load the module in a manual manner, it is recommended to use ModProbe because it can solve the dependence problem between the modules. In the part of the sound card, the Sound Blaster is a total of the following modules:
SB 33652 0 (AutoClean)
UART401 6160 0 (AutoClean) [SB]
Sound 56492 0 (Autoclean) [SB UART401]
SoundCore 2372 5 (Autoclean) [SB Sound] These modules are loaded, and the entire sound card can work, and they are dependent between them. The core SoundCore must be loaded first, and finally loaded into SB. But the average person does not know its order. Therefore, ModProbe is used to solve this problem.
Usually we only need
Modprobe SB
It will automatically find all the modules used by SB, load them in one, so the general user does not have to hurt the brain.
So how do the kernel know the dependence relationship between these modules? It turns out that there is a 'DEPMOD -A' command in the system boot script, which will create a list of dependencies to all available modules in the system. And 'modprobe module-name' uses this list, in the specified
The module is loaded into the module that is put into advance. If you can't find 'Module-name' in this subordinate list, it gives the corresponding error information.
But if INSMOD is used, it does not automatically complete the transfer of other modules. For example, we have to join the PPP module and use this command:
Root / root> Insmod PPP
Root / root>
If the operation is successful, the system will appear a prompt. If there is no success, the following information may appear:
/LIB/Modules/2.2.2.10/net/ppp.o: unresolved Symbol SLHC_INIT_RSMP_1CA65FCA
/LIB/Modules/2.2.2.10/net/ppp.o: unresolved Symbol SLHC_COMPRESS_RSMP_CFD3A418
/LIB/Modules/2.2.2.10/net/ppp.o: unresolved Symbol SLHC_FREE_RSMP_B99033D9
/LIB/Modules/2.2.2.10/net/ppp.o: unresolved Symbol SLHC_TOSS_RSMP_A152CEC0
/LIB/Modules/2.2.2.2.10/net/ppp.o: unresolved Symbol SLHC_REMEMBER_RSMP_07972313
/LIB/Modules/2.2.2.10/net/ppp.o: unresolved Symbol SLHC_UNCompRESS_RSMP_3BB36B01
[root / root] #
This shows that the PPP module does not load successful, the Unresolved Symbol in the error prompt, and some of the modules needed to be not loaded yet. Error prompts the first line of content is: SLHC_INIT_RSMP_1CA65FCA, which module is this? This may require some experience to make judgments, it is to start with SLHC, try SLHC.
Root / root> Insmod SLHC is all normal, then we load the PPP module
Root / root> Insmod PPP
Root / root>
This time has not returned information, indicating that the PPP module is successfully loaded.
6. Uninstall a modules from memory.
To uninstall a module, you first use LSMOD to see if the module is really loaded, and then do it. In addition, when you encounter a dependency module, the process of unloading the module from the kernel is exactly the opposite of the load, it follows the guidelines of "First In Last Out", that is, a series of dependencies. In the middle, you must first uninstall the last loaded module, and finally uninstall the module that is first loaded. For example, if you want to remove the modules in use with RMMOD (as in the above example, to uninstall SLHC, there is still a PPP module in use) Error Tip: Device Or Resource Busy. So, after uninstalling the PPP module from memory, it is possible to uninstall the SLHC module from memory. In summary, when you uninstall the module, Linux will prompt you to prompt your information, carefully view this information, which is able to take the appropriate action and finally resolve the problem.