Linux Device Drivers Demystified - page 2
Another much-trumpeted advantage of Linux is that it does not need to be rebooted as often as other operating systems. You might think that this is due to its rock solid stability. You may think I am now going to talk about the quality of the device drivers. But you'd be wrong. The reason that Linux device drivers lead to less rebooting is that we can reconfigure, load or unload them without restarting the system.
To do this modular kernel drivers are used.
How to load a module
Most people configure their modules at install time and then leave them alone. All the major distributions have taken to modules because of another advantage they have: size. Distribution makers want to support all the possible cards and devices that Linux can. If we compiled all these into the kernel it would be huge. If several different static kernels for different devices were supplied then they would take up too much space, as well. With the modular system distribution makers supply a stripped down kernel plus a comprehensive set of device drivers. This typically only occupies two or three floppy disks in total.
modprobe, lsmod and insmod
if you want to load a module after system setup time, then the easiest way is as follows:
This example loads the Apple Mac disk subsystem driver (called hfs) with the modprobe command. If the module takes parameters, like IRQ numbers, then you can specify them with modprobe too.
To see what modules are loaded and to see information on how they depend on each other we use lsmod. Here is some example output from lsmod.
Module Size Used by gus 45016 0 mad16 6564 0 sb 31416 0 ad1848 15112 0 [mad16] uart401 5588 0 [mad16 sb] sound 54368 0 [gus mad16 sb ad1848 uart401]
In this example the mad16 kernel device driver depends on the ad1848 device driver.
Yes, there really is a mad16 device driver. It is a soundcard chipset.
In the normal course of events the modules we asked for when Linux was installed are loaded at boot time. To achieve this the file
/etc/modules is used. This is a list of modules to be loaded.
The options for the modules are stored in
/etc/conf.modules. Recommended practice is to not edit /etc/conf.modules, however, but to use a script like
update-modules; see the man pages for more details.