Many modules are loaded automatically. A nice example of this is the loading of the module for a network board. Imagine that the module for your specific network card is the pcnet32 module. Usually this module would be started automatically on system boot, so it doesn't make sense to do it manually. However, if your network card isn't initialized automatically, you would see that before configuring your network board with a command such as ifconfig, there just is no module present for it. After you have used the command ifconfig eth0 192.168.1.10 to initialize the network board, however, the module appears automatically. But how does that happen?
In the previous example, the ifconfig command tells what piece of hardware to use by specifying the eth0 argument. This argument is a generic way to refer to the kernel module, which in this case is called pcnet32. Now when you are using the eth0 argument, you are addressing the ifplugd process. This is the link detection daemon for Ethernet devices. This ifplugd process probes on what PCI hardware address it can find an Ethernet network board. This PCI hardware address is also defined in the pcnet32 module as an alias, so when ifplugd calls this specific hardware address, the pcnet32 module will reply and will load automatically.
An easier-to-understand example of how modules can be loaded automatically is for modules that use the /etc/modprobe.conf configuration file. In this configuration file, you can work with aliases, and that's the old way that the driver for your network card was loaded. In /etc/ modprobe.conf, you would find the line alias eth0 pcnet32. This line would make sure when some command called for eth0, the pcnet32 module would be automatically loaded. If you browse through /etc/modprobe.conf, you can see that this alias mechanism is still used for many modules. In the modprobe.conf configuration file, you can pass options to hardware devices as well. These options can include, for example, the hardware settings required by the device or the network properties needed by a network card. Listing 26-3 shows an example of some lines in modprobe.conf.
Listing 26-3. Loading Modules Automatically by Using/etc/modprobe.conf alias parport_lowlevel parport_pc options parport_pc io=0x378 irq=none,none
# If you have multiple parallel ports, specify them this way:
# options parport_pc io=0x378,0x278 irq=none,none
# Linux ACP modem (Mwave) alias char-major-10-219 mwave
In Listing 26-3, you can see that first an alias is created for parport_pc. This alias accomplishes that whenever parport_pc is called, the parport_lowlevel device is loaded. The second line specifies some hardware settings for this device. Then it specifies some lines with comments in it, and finally you see that another alias is created; the name mwave is linked to the device char-major-10-219.
Was this article helpful?