The Modular Mighty
Ever spend hours online looking for a windows driver to get your favorite legacy device working? Modems are the best, failure is imminent 90% of the time. I can thank places like DriverGuide.com for giving me wrong drivers in exchange for a daily subscriptions to Viagra and Septic Tank newsletters. Actually, any ISA PnP device under Windows is doomed because despite the name, you still have to control the device's resources manually. If you let Windows manage the resources, you'll probably endup with a COM13 sharing your VGA's IRQ.
In the Linux world, Drivers are called modules. A module embodies the same concept as a driver in the Windows environment. As the name indicates, it is a modular piece of code that is dynamically loaded or unloaded into memory by the Linux Kernel. This is not to say that the Kernel is responsible for determining the appropriate driver and loading it automatically. The user is still responsible for determining which module is required for their specific hardware.
A module is written to support specific hardware or family of hardware. If the Kernel does not already have built-in support for that hardware, the user can load the module to offer support for it. This is particularly handy because the user has the ultimate choice about how support for a piece of hardware is handled. With a large broad Kernel, support for many devices is already built-in. This means supporting devices is done automatically and without any user intervention. This is particularly useful when the hardware is not known yet (ie: fresh installation or Linux-on-a-CD). If the user cares about customizing their hardware for their own needs however, they will be responsible for trimming the Kernel and removing excess fat. Only support for existing hardware is left. This is handy when creating a Linux on a Floppy disk or when size matters. Hard-core Linux users typically go through the process of creating a custom Kernel with external modules very early on after performing the installation.
The process of loading and unloading modules is where the advantage really is. Using tools such as insmod, the user can load a module on the fly. No waiting around or having to reboot. The changes are immediate and status of the operation is displayed immediately. If the user chose the wrong module, they will be made aware of that instantly. Using the dmesg command, a user can view important kernel log data and decide exactly why any failures took place. The rmmod tool is used to remove a module from memory. Support for the hardware is immediately halted. Using lsmod, the user can view a dynamically generated list of loaded modules. Sometimes, modules depend on other modules to be loaded first before they can do their job. A tool such as modprobe is ideally used to load a module and all its dependencies. A module cannot be removed from memory if a dependent module is still active.
The general idea behind the module concept is simple, modularity = good. Keep minimal hardware support in Kernel for lightweight Kernel then let the modules do the rest. This is beautiful for servers where rebooting is not an option.
One thing is important though, the compatibility issue. In Windows, everyone has the same major release (ie: Windows 2000, XP, 98, ...etc). In the case of Linux, slightly new version (minor releases) are made public almost every week! Finding someone with the same version as you is not very likely. This means finding another module from another machine will be more headache than creating your own... hear me out first. The Linux Kernel comes with the source code for the entire Kernel and a handy configuration utility that will allow you to choose exactly how you want things to operate. As you go down the list of options and decide which are right for your machine, you will be given a chance to decide how you want to create support for that particular hardware. You can choose to exclude support if you are certain you will never use it, or you can create support for specific hardware as either a module or directly into the finished Kernel. Once the kernel is configured and compiled, you have yourself the kernel exactly as you wanted it with a list of modules that were created to be loaded dynamically as needed.
Article by Mourad Kessas