1 |
199 |
simons |
This file describes the strategy for dynamically loadable modules
|
2 |
|
|
in the Linux kernel. This is not a technical description on
|
3 |
|
|
the internals of module, but mostly a sample of how to compile
|
4 |
|
|
and use modules.
|
5 |
|
|
|
6 |
|
|
Note: You should ensure that the modules-X.Y.Z.tar.gz you are using
|
7 |
|
|
is the most up to date one for this kernel. The "X.Y.Z" will reflect
|
8 |
|
|
the kernel version at the time of the release of the modules package.
|
9 |
|
|
Some older modules packages aren't aware of some of the newer modular
|
10 |
|
|
features that the kernel now supports. (If you are unsure, you can
|
11 |
|
|
usually find out what the current release of the modules-X.Y.Z.tar.gz
|
12 |
|
|
package is by looking up the URL listed for "Bjorn Ekwall" in the
|
13 |
|
|
file ./linux/CREDITS)
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
In the beginning...
|
17 |
|
|
-------------------
|
18 |
|
|
|
19 |
|
|
Anyway, your first step is to compile the kernel, as explained in the
|
20 |
|
|
file linux/README. It generally goes like:
|
21 |
|
|
|
22 |
|
|
make config
|
23 |
|
|
make dep
|
24 |
|
|
make clean
|
25 |
|
|
make zImage or make bzImage or make zlilo
|
26 |
|
|
|
27 |
|
|
In "make config", you select what you want to include in the "resident"
|
28 |
|
|
kernel and what features you want to have available as loadable modules.
|
29 |
|
|
You will generally select the minimal resident set that is needed to boot:
|
30 |
|
|
|
31 |
|
|
The filesystem of your root partition
|
32 |
|
|
A scsi driver, but see below for a list of SCSI modules!
|
33 |
|
|
Normal hard drive support
|
34 |
|
|
Net support (CONFIG_NET)
|
35 |
|
|
TCP/IP support (CONFIG_INET), but no drivers!
|
36 |
|
|
|
37 |
|
|
plus those things that you just can't live without...
|
38 |
|
|
|
39 |
|
|
The set of modules is constantly increasing, and you will be able to select
|
40 |
|
|
the option "m" in "make config" for those features that the current kernel
|
41 |
|
|
can offer as loadable modules.
|
42 |
|
|
|
43 |
|
|
You also have a possibility to create modules that are less dependent on
|
44 |
|
|
the kernel version. This option can be selected during "make config", by
|
45 |
|
|
enabling CONFIG_MODVERSIONS, and is most useful on "stable" kernel versions,
|
46 |
|
|
such as the kernels from the 1.2 and 2.0 series.
|
47 |
|
|
If you have modules that are based on sources that are not included in
|
48 |
|
|
the official kernel sources, you will certainly like this option...
|
49 |
|
|
|
50 |
|
|
Here is a sample of the available modules included in the kernel sources:
|
51 |
|
|
|
52 |
|
|
Most filesystems: minix, xiafs, msdos, umsdos, sysv, isofs, hpfs,
|
53 |
|
|
smbfs, nfs
|
54 |
|
|
|
55 |
|
|
Mid-level SCSI support (required by top and low level scsi drivers).
|
56 |
|
|
Most low-level SCSI drivers: (i.e. aha1542, in2000)
|
57 |
|
|
All SCSI high-level drivers: disk, tape, cdrom, generic.
|
58 |
|
|
|
59 |
|
|
Most ethernet drivers: (too many to list, please see the file
|
60 |
|
|
./Documentation/networking/net-modules.txt)
|
61 |
|
|
|
62 |
|
|
Most CDROM drivers:
|
63 |
|
|
aztcd: Aztech,Orchid,Okano,Wearnes
|
64 |
|
|
cm206: Philips/LMS CM206
|
65 |
|
|
gscd: Goldstar GCDR-420
|
66 |
|
|
mcd, mcdx: Mitsumi LU005, FX001
|
67 |
|
|
optcd: Optics Storage Dolphin 8000AT
|
68 |
|
|
sjcd: Sanyo CDR-H94A
|
69 |
|
|
sbpcd: Matsushita/Panasonic CR52x, CR56x, CD200,
|
70 |
|
|
Longshine LCS-7260, TEAC CD-55A
|
71 |
|
|
sonycd535: Sony CDU-531/535, CDU-510/515
|
72 |
|
|
|
73 |
|
|
And a lot of misc modules, such as:
|
74 |
|
|
lp: line printer
|
75 |
|
|
binfmt_elf: elf loader
|
76 |
|
|
binfmt_java: java loader
|
77 |
|
|
isp16: cdrom interface
|
78 |
|
|
serial: the serial (tty) interface
|
79 |
|
|
|
80 |
|
|
When you have made the kernel, you create the modules by doing:
|
81 |
|
|
|
82 |
|
|
make modules
|
83 |
|
|
|
84 |
|
|
This will compile all modules and update the linux/modules directory.
|
85 |
|
|
In this directory you will then find a bunch of symbolic links,
|
86 |
|
|
pointing to the various object files in the kernel tree.
|
87 |
|
|
Now, after you have created all your modules, you should also do:
|
88 |
|
|
|
89 |
|
|
make modules_install
|
90 |
|
|
|
91 |
|
|
This will copy all newly made modules into subdirectories under
|
92 |
|
|
"/lib/modules/kernel_release/", where "kernel_release" is something
|
93 |
|
|
like 2.0.1, or whatever the current kernel version is...
|
94 |
|
|
|
95 |
|
|
As soon as you have rebooted the newly made kernel, you can install
|
96 |
|
|
and remove modules at will with the utilities: "insmod" and "rmmod".
|
97 |
|
|
After reading the man-page for insmod, you will also know how easy
|
98 |
|
|
it is to configure a module when you do "insmod" (hint: symbol=value).
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
Nifty features:
|
102 |
|
|
---------------
|
103 |
|
|
|
104 |
|
|
You also have access to two utilities: "modprobe" and "depmod", where
|
105 |
|
|
modprobe is a "wrapper" for (or extension to) "insmod".
|
106 |
|
|
These utilities use (and maintain) a set of files that describe all the
|
107 |
|
|
modules that are available for the current kernel in the /lib/modules
|
108 |
|
|
hierarchy as well as their interdependencies.
|
109 |
|
|
|
110 |
|
|
Using the modprobe utility, you can load any module like this:
|
111 |
|
|
|
112 |
|
|
/sbin/modprobe module
|
113 |
|
|
|
114 |
|
|
without paying much attention to which kernel you are running, or what
|
115 |
|
|
other modules this module depends on.
|
116 |
|
|
|
117 |
|
|
With the help of the modprobe configuration file: "/etc/conf.modules"
|
118 |
|
|
you can tune the behaviour of modprobe in many ways, including an
|
119 |
|
|
automatic setting of insmod options for each module.
|
120 |
|
|
And, yes, there _are_ man-pages for all this...
|
121 |
|
|
|
122 |
|
|
To use modprobe successfully, you generally place the following
|
123 |
|
|
command in your /etc/rc.d/rc.S script. (Read more about this in the
|
124 |
|
|
"rc.hints" file in the module utilities package, "modules-x.y.z.tar.gz".)
|
125 |
|
|
|
126 |
|
|
/sbin/depmod -a
|
127 |
|
|
|
128 |
|
|
This computes the dependencies between the different modules.
|
129 |
|
|
Then if you do, for example
|
130 |
|
|
|
131 |
|
|
/sbin/modprobe umsdos
|
132 |
|
|
|
133 |
|
|
you will automatically load _both_ the msdos and umsdos modules,
|
134 |
|
|
since umsdos runs piggyback on msdos.
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
The "ultimate" utility:
|
138 |
|
|
-----------------------
|
139 |
|
|
|
140 |
|
|
OK, you have read all of the above, and feel amply impressed...
|
141 |
|
|
Now, we tell you to forget all about how to install and remove
|
142 |
|
|
loadable modules...
|
143 |
|
|
With the kerneld daemon, all of these chores will be taken care of
|
144 |
|
|
automatically. Just answer "Y" to CONFIG_KERNELD in "make config",
|
145 |
|
|
and make sure that /sbin/kerneld is started as soon as possible
|
146 |
|
|
after boot and that "/sbin/depmod -a" has been executed for the
|
147 |
|
|
current kernel. (Read more about this in the module utilities package.)
|
148 |
|
|
|
149 |
|
|
Whenever a program wants the kernel to use a feature that is only
|
150 |
|
|
available as a loadable module, and if the kernel hasn't got the
|
151 |
|
|
module installed yet, the kernel will ask the kerneld daemon to take
|
152 |
|
|
care of the situation and make the best of it.
|
153 |
|
|
|
154 |
|
|
This is what happens:
|
155 |
|
|
|
156 |
|
|
- The kernel notices that a feature is requested that is not
|
157 |
|
|
resident in the kernel.
|
158 |
|
|
- The kernel sends a message to kerneld, with a symbolic
|
159 |
|
|
description of the requested feature.
|
160 |
|
|
- The kerneld daemon asks e.g. modprobe to load a module that
|
161 |
|
|
fits this symbolic description.
|
162 |
|
|
- modprobe looks into its internal "alias" translation table
|
163 |
|
|
to see if there is a match. This table can be reconfigured
|
164 |
|
|
and expanded by having "alias" lines in "/etc/conf.modules".
|
165 |
|
|
- insmod is then asked to insert the module(s) that modprobe
|
166 |
|
|
has decided that the kernel needs. Every module will be
|
167 |
|
|
configured according to the "options" lines in "/etc/conf.modules".
|
168 |
|
|
- modprobe exits and kerneld tells the kernel that the request
|
169 |
|
|
succeeded (or failed...)
|
170 |
|
|
- The kernel uses the freshly installed feature just as if it
|
171 |
|
|
had been configured into the kernel as a "resident" part.
|
172 |
|
|
|
173 |
|
|
The icing of the cake is that when an automatically installed module
|
174 |
|
|
has been unused for a period of time (usually 1 minute), the module
|
175 |
|
|
will be automatically removed from the kernel as well.
|
176 |
|
|
|
177 |
|
|
This makes the kernel use the minimal amount of memory at any given time,
|
178 |
|
|
making it available for more productive use than as just a placeholder for
|
179 |
|
|
unused code.
|
180 |
|
|
|
181 |
|
|
Actually, this is only a side-effect from the _real_ benefit of kerneld:
|
182 |
|
|
You only have to create a minimal kernel, that is more or less independent
|
183 |
|
|
of the actual hardware setup. The setup of the "virtual" kernel is
|
184 |
|
|
instead controlled by a configuration file as well as the actual usage
|
185 |
|
|
pattern of the current machine and its kernel.
|
186 |
|
|
This should be good news for maintainers of multiple machines as well as
|
187 |
|
|
for maintainers of distributions.
|
188 |
|
|
|
189 |
|
|
To use kerneld with the least amount of "hassle", you need modprobe from
|
190 |
|
|
a release that can be considered "recent" w.r.t. your kernel, and also
|
191 |
|
|
a configuration file for modprobe ("/etc/conf.modules").
|
192 |
|
|
Since modprobe already knows about most modules, the minimal configuration
|
193 |
|
|
file could look something like this:
|
194 |
|
|
|
195 |
|
|
alias scsi_hostadapter aha1542 # or whatever SCSI adapter you have
|
196 |
|
|
alias eth0 3c509 # or whatever net adapter you have
|
197 |
|
|
# you might need an "options" line for some net adapters:
|
198 |
|
|
options 3c509 io=0x300 irq=10
|
199 |
|
|
# you might also need an "options" line for some other module:
|
200 |
|
|
options cdu31a cdu31a_port=0x1f88 sony_pas_init=1
|
201 |
|
|
|
202 |
|
|
You could add these lines as well, but they are only "cosmetic":
|
203 |
|
|
|
204 |
|
|
alias net-pf-3 off # no ax25 module available (yet)
|
205 |
|
|
alias net-pf-4 off # if you don't use the ipx module
|
206 |
|
|
alias net-pf-5 off # if you don't use the appletalk module
|
207 |
|
|
|
208 |
|
|
Finally, for the "purists":
|
209 |
|
|
You can name the modprobe configuration either "/etc/conf.modules" or
|
210 |
|
|
"/etc/modules.conf", since modprobe knows what to do in each case...
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
Written by:
|
214 |
|
|
Jacques Gelinas
|
215 |
|
|
Bjorn Ekwall
|