MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

*DocIndex - Hardware

Hardware Configuration II

* 4.2 Kernel-space Configuration
* '/etc/lilo.conf' vs. '/etc/modules.conf'
* Boot-time Configuration
* Run-time Configuration

Related Resources:

The Linux BootPrompt-HOWTO
'Configure.help' and 'modules.txt' in 'linux/Documentation'
man modprobe

Revision / Modified: Sep. 10, 2001
Author: Tom Berger

 

* 4.2 Kernel-space Configuration

* '/etc/lilo.conf' vs. '/etc/modules.conf'

GNU/Linux may use drivers in two different ways: as part of the kernel itself or as modules. Nowadays it is commonplace practice to take modules rather than built-in drivers whenever possible:

  • The Linux kernel must be kept in system memory all the time. The bigger the kernel the less system resources remain for other tasks.
  • Most modules are loaded when needed and unloaded after not having been needed for one minute. This ensures efficient use of system resources.
  • A modularized kernel may run on more than one machine or with less difficulties on a machine with changing hardware.
  • To upgrade a modularized driver you just need to recompile the module. If the driver is part of the kernel, you have to recompile the kernel.

So in almost all cases, you will need to configure a module during run-time via '/etc/modules.conf' (or 'conf.modules' in some versions of ML) and should not have to fiddle about with boot-time parameters which are to be put into '/etc/lilo.conf' or '/boot/grub/menu.lst'.

To find out about this, have a look at '/usr/src/linux/arch/i386/defconfig'. This file contains the standard configuration of the Mandrake kernel. You will see that the Mandrake kernel is thoroughly modularized and that most of the modules have been built and are ready to run.
The entries in 'defconfig' look like this:

[OPTION]=[m,y]

m stands for 'module', y for 'built-in'. If you need help with the options, read '/usr/src/linux/Documentation/Configure.help'.
If you see an entry like this:

# [OPTION] is not set

and you really need this option to be enabled, you have to recompile the kernel. This should be seldom necessary, though.

* Boot-time Configuration

In the rare case you need to configure a built-in driver, have a look at The Linux Bootprompt HOWTO. It lists all available devices and their optional values.
Many drivers support auto-probing, so just supplying their names without any values will already help in many cases.

Example: hdc=cdrom will tell GNU/Linux that there is a CD-ROM drive as master on the second IDE port. This might help if GNU/Linux doesn't recognize your ATAPI CD-ROM drive.

You can configure as many devices as you like. You usually start with trying them out at the boot prompt or via loadlin:

  • boot : [device]=[value1],[value2] [device2]=[value1] etc.
    This is one line. Spaces are only allowed between different device configuration entries, all entries are case-sensitive. Note that the keyboard isn't mapped to your local language yet, so some keys may work differently if you're using a non-US keyboard.

  • loadlin [image] [root] [device]=[value1],[value2] [device2]=[value1] etc.
    if you're booting via DOS using loadlin. Again, this is one line.

  • If you are using the GRUB boot loader, just hit 'e' twice and append all the entries you need. When you're ready, hit the 'Enter' key and then 'b'.

As soon as this works sufficiently, you can write the device configuration into your startup-file, usually '/etc/lilo.conf' or '/boot/grub/menu.lst':

append="[device1]=[value1],[value2] [device2]=[value1] etc."

Spaces are allowed after append, in front of the first device entry and between device entries. The appended configuration value has to be included in quotes. append can be either added to the first 'global' section or - better - to the entry of the kernel image, like this:

image=/boot/vmlinuz
label=linux
root=/dev/hda[x]
initrd=/boot/initrd.img
append="[device1]=[value1],[value2] etc."
read-only

In GRUB's 'menu.lst' you just have to append the value pairs to the set boot command line.

* section index * top

* Run-time Configuration

Most likely you need to configure a driver that is available as a module.

Some basic commands first:

  • /sbin/lsmod shows all configured modules on your system.
  • /sbin/modprobe -l lists all available modules.
  • /sbin/modprobe -c lists all configured aliases, options and commands concerning modules. Note that system defaults (likealias eth0 off) overridden by entries in '/etc/modules.conf' are listed nevertheless (which may be somewhat confusing).
  • /sbin/modprobe [module] loads a module. It is the successor to insmod. So if you read insmod ... somewhere replace it with modprobe ....
  • /sbin/modprobe -r [module] unloads a module. Successor tormmod.
  • man modprobe is a must-read. Concise and really easy to understand.

If you've downloaded a driver from the net and compiled it yourself (or if it came precompiled for your kernel version), move it to the appropriate sub directory of '/lib/modules/[kernel version]/'. If you can't figure out which one to use, choose 'misc'.

Run depmod -a to let the system know about the new module. Test the module by loading it:

modprobe [module name]

The module name is the file name of the driver without its ending (e.g. 'joy-sidewinder.o' becomes 'joy-sidewinder'). If you get no error messages here, the module has loaded OK (run lsmod to make sure) and you're - almost - set.
If you get Device or resource busy, it is either the wrong module, or you need to do some additional configuration (modprobe [module] [options], see below).

Configuration and loading of modules is done via '/etc/modules.conf' (or 'conf.modules' in some releases). If you have a look at it, you will see that there's already some configuration done. You will also note that there are some switches which allow you to control the loading procedure:

  • alias [class] [module]. This assigns a specified module / driver to a class of devices. alias eth0 ne2k-pci for example tells GNU/Linux to use a networking card controlled by the ne2k-pci driver as the first Ethernet interface. Other popular classes are 'scsi_hostadapter' and 'sound'. alias [class] off tells GNU/Linux to refrain from loading any driver for this device class.

  • options [class or module] [value1] [value2] Some modules may require further configuration, like IRQ numbers or I/O addresses. Valid options are either described in the documentation file of the module (in /usr/src/linux/Documentation), in a README file included in the source directory of the module (subdirectories of '/usr/src/linux/drivers') or in the source file itself ('[module].c']).

  • pre/postinstall [module] [command] tells GNU/Linux to run a command before or after a module is loaded into memory. In ML 7 for example, you found this line (if you had a SCSI controller, that is):
    post-install supermount modprobe scsi_hostadapter
    This means: after the 'supermount' module is loaded, load the module 'scsi_hostadapter'. Loading this module will allow 'supermount' to handle devices which are connected to the SCSI bus.
    OK, let's say you do not use 'supermount', but want to load the module for the SCSI host adapter every time you are mounting your SCSI-CD drive. Look at 'devices.txt' in 'linux/Documentation' and you'll find that SCSI CD-ROMs are block devices with the major number '11'. Run modprobe -c and you see that there's already an alias for block-major-11 calledsr_mod.
    Now put it all together:

    pre-install sr_mod modprobe scsi_hostadapter

    Obviously this line must be inserted into '/etc/conf.modules' below the alias for the adapter...
    Fun, isn't it? ;-)

Now you are on your own: Read the docs for the modules and try the available options. If you still can't figure it out, use Google (that's what I usually do - the 'net knows everything! ;-)).

* section index * top


 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.