Team LiB
Previous Section Next Section

Detecting and Configuring Hardware

Fedora and Red Hat Linux systems use the kudzu utility to automatically detect when hardware is physically added and removed from your computer, and then configure that hardware as best it can. For most popular hardware, kudzu works quite well. Other times, however, you might need to add the drivers or modules you need to use the hardware yourself.

Using Kudzu to Detect Hardware

Most people never run kudzu manually at all. When you reboot your computer after adding a new network card, storage device, modem, or other piece of hardware, kudzu runs automatically and asks how you would like to configure that hardware. What kudzu does is:

  • Probes your computer hardware (devices connected to the PCI bus, serial ports, parallel ports, usb ports, pcmcia slots, SCSI connections, and so on).

  • Compares the hardware it detects against the system's current hardware listed in the /etc/sysconfig/hwconf file.

  • Prompts you to configure or remove hardware, based on the differences in the two hardware lists.

  • Updates the /etc/sysconfig/hwconf file to reflect the new hardware configuration.

In many cases, kudzu will find the right modules needed by the hardware and configure your system to load them automatically each time your system boots. If you want to use kudzu without rebooting, you should first shut down your graphical desktop interface. You can do that by changing to runlevel 3 (init 3). Then, as root user, simply type kudzu.

Configuring Hardware Modules

If kudzu can't configure your hardware drivers, or if you want to configure the drivers differently, you can use tools from the modutils package to load the modules you need to get your hardware working.

Using modules, instead of having drivers for every possible piece of hardware built into the kernel, allows the kernel to contain a minimal set of drivers. When hardware is added and removed, associated modules can be loaded and unloaded with only a small amount of overhead.

The following is a brief overview of utilities in the modutils package for loading, unloading, and listing information about modules.

Checking Loaded Modules

To see what modules are currently loaded on your system, you can use the lsmod command. Here's an example.

   # lsmod | less
   Module               Size  Used by    Not tainted
   parport_pc          18468   1  (autoclean)
   lp                   8356   0  (autoclean)
   parport             36800   1  (autoclean) [parport_pc lp]
   autofs              12052   0  (autoclean) (unused)
   pcmcia_core         55232   0
   via-rhine           14672   1
   mii                  3992   0  [via-rhine]
   floppy              56348   0  (autoclean)
   sg                  34796   0  (autoclean)
   sr_mod              17016   0  (autoclean)
   ide-scsi            11856   0
   scsi_mod           109384   3  [sg sr_mod ide-scsi]
   ide_cd              34176   0
   cdrom               34048   0  [sr_mod ide-cd]
   keybdev              2624   0  (unused)
   mousedev             5204   0  (unused)
   hid                 23652   0  (unused)
   input                5824   0  [keybdev mousedev hid]
   ehci_hcd            19784   0  (unused)
   usb_uhci            25740   0  (unused)
   usbcore             77984   1  [hid ehci-hcd usb-uhci]
   ext3                70532   3
   jbd                 50796   3  [ext3]

The information for each module includes the module name, the module size (in bytes), and the number of modules using that module. Information in the last column is either unused (if the module is loaded but not being used), autoclean (if the module can be autocleaned using rmmod-a), or the names of modules that depend on this module.

If you are interested in what any of the modules are, you can use the modinfo command. Here is an example.

   # modinfo parport_pc
   filename:    /lib/modules/2.4.22-
                1.2140.nptl/kernel/drivers/parport/parport_pc.o
   description: "PC-style parallel port driver"
   author:      "Phil Blundell, Tim Waugh, others"
   license:     "GPL"
   parm:        io int array (min = 1, max = 16), description
                "Base I/O address (SPP regs)"
   parm:        io-hi int array (min = 1, max = 16), description
                "Base I/O address (ECR)"
   parm:        irq string array (min = 1, max = 16),
                description "IRO line"
   parm:        dma string array (min = 1, max = 16).
                description "DMA channel"

Here you can see that the module is a "PC-style parallel port driver". You can also see parameters that can be passed to the module (parm:). Other options to modinfo let you display partial listings of the information just shown. For example, modinfo - p module lets you just view parameters used by the module.

Loading Modules

To manually load a module (that was either not detected or improperly detected), you can use the modprobe command.

Note 

The insmod command can also be used to load modules in Linux. However, insmod loads only the requested module and does not load modules on which the one you want depends. Module dependencies queried by modprobe before loading a module are contained in the /lib/modules/*/modules.dep file.

Supported modules that come with Fedora and other Red Hat Linux systems are typically stored in /lib/modules/*/kernel directory (where you replace the asterisk with the name of your current kernel). There are modules listed as unsupported by Red Hat that are contained in the /lib/modules/*/unsupported directory.

Before just randomly loading the modules, you should know which modules are needed by the hardware you want to use. If you have the kernel-source package installed, you can read descriptions of many of the modules in the /usr/src/linux-*/Documentation directory for your kernel.

To load a module that is included in a Red Hat distribution using the modprobe command, you can simply type modprobe and the module name. For example:

   # modprobe appletalk

The modprobe command will first look in the /etc/modules.conf for anything required of this module. Then it will look in the /lib/modules/*/modules.dep file and load any modules listed as being needed by the one you want. Then it will load the module itself. If there are options you want to pass to the modules, you can also do that when you run modprobe. For example:

   # modprobe pwc size=cif fps=10

The pwc module is used for several different models of Philips Webcams. The options shown here specify the resolution of the image (cif is 352 × 288) and the number of frames per second being used (in this case, 10). I found the descriptions of these particular parameters in the /usr/src/1inux-*/Documentation/usb/philips.txt file.

If you are getting third-party modules, you should be careful that:

  • You know and trust the source of that module.

  • You know whether you are using a tainted module. A tainted module is one that is not distributed under the GPL or other acceptable license. Some vendors distribute modules in binary-only format. Because the Linux community cannot fix problems that might occur with these modules, kernel developers will not respond to problems that occur with these tainted kernels. There are times when you must use a binary-only module to use the hardware at all. (1 personally use binary-only modules for my NVIDIA video card and my Webcam.)

To continue with my Philips Webcam example, there is a pwcx decompressor module available to use with the pwc core driver as a plug-in. Although this module will allow larger images and higher frame rates, it is a binary-only module and is considered tainted. If you decide that you want to load this module anyway (which you do at your own risk), you need to force installation of that module. To temporarily try the module (with the module downloaded and unzipped to the current directory), type the following:

   # insmod --force ./pwcx.o
   Warning: kernel-module version mismatch
            ./pwcx.o was compiled for kernel version 2.4.23
            while this kernel is version 2.4.18-14
   Warning: loading ./pwcx.o will taint the kernel:
   non-GPL license - Proprietary. See
   http://www.smcc.demon.nl/webcam/tainting.html
     See http://www.tux.Org/lkml/#export-tainted for information
            about tainted modules
   Warning: loading ./pwcx.o will taint the kernel: forced load
   Module pwcx loaded, with warnings

As you can see, there are warnings about tainting the kernel, but it loads the module anyway. Follow the links shown in these warnings to see some good descriptions of the issue.

The behavior of modprobe can be modified by adding entries to the /etc/modules.conf file. Some of the more interesting things you can do within this file include setting commands to be run before, after, or instead of loading the requested module. Here are a few examples of entries added to the modules.conf file that make the modules perform better.

   post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L \
           >/dev/null 2>&1 | | :
   post-install pwc /sbin/insmod --force / moddir/pwcx.o >/dev/null 2>&1 | | :

Here are two entries that are run after the modules they are associated with are installed. The first entry runs the aumix-minimal command after the sound-slot-0 modules (representing the first sound card) are loaded. The command reads in the values in the /etc/.aumixrc file to set initial levels for the sound card. The second line continues the example with the pwcx driver. After the pwc module is loaded, the insmod command forces the pwcx.o module to be loaded. (You would replace moddir with the full path to the pwcx.o file.)


Team LiB
Previous Section Next Section