Modules

From SlackWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

When you are compiling a kernel for the first time asking the question to yourself should I module this or compile this in the kernel? Well the answer to this question is not an exact science. Meaning that it depends on what you believe in yourself. The following are a few things that I like to follow when I compile a kernel:

1. Always compile the root file system in the kernel because without the root file system mounted, How can the kernel load the module:)

2. I like to compile my networking card into the kernel. The reason being is what happens if the modules screw up, I would like to be able to SSH into the box and fix it.

3. Iptables and networking OPTIONS I like to compile as modules, because sometimes I may not need them loaded.

4. IDE chipsets (or SCSI chipsets (if you boot from a SCSI disk)) should NOT be compiled as a module because the devices are needed to boot the system and is required to be loaded BEFORE modules are loaded.

MEANING: If you boot from an IDE hard-drive but make the IDE drivers a module, your system will never boot! Your boot device driver(s) MUST be compiled into the kernel so the system can start up so that it can later load modules.


Now remember that Linux is a monolithic kernel so when you load modules the modules go into the kernel space. This would make it so modules run at the SAME speed as if you were to compile the modules into the kernel. My philosophy is that if you REALLY need to load something on startup ( like root file system, or IDE/ATAPI support) then you should compile it into the kernel. The other stuff like ALSA/ Networking Options/USB/I2C/Etc and stuff like that can be unloaded and reloaded which would make sense if you put them as modules.


This is just some advice and it is not 100% correct because some people follow their own strategy when compiling kernels. This is more like a recommendation:)

Listing Loaded Modules

lsmod will produce a list of modules that the kernel has loaded.


Manually Loading a Module

modprobe module will manually load a module (if the module exists).

EXAMPLE: modprobe 8139too will load the 8139too ethernet driver.


Checking To See If A Module Exists

EASY WAY: modprobe module - if the modules doesn't exist (or has a problem), you will get an error message.

HARDER WAY: cd into the /lib/modules/2.X.X/ directories and start poking around for it.