Auto load of kernel modules on startup and on-demand?

Rob Landley rob at landley.net
Sun Dec 25 03:48:42 UTC 2005


On Friday 23 December 2005 11:13, Marcus Crafter wrote:
> > If you want to force a module to load, what's wrong with calling
> > insmod from
> > your init scripts?
> >
> > I need a clearer idea of your requirements.
>
> Well, what I'm looking for is support for 2 scenarios:
>
> 1. Equivalent of /etc/modules (ie. put in the name of the modules
> you'd like to load at boot time always, each line in /etc/modules is
> modprobe'd).  This could be done as you describe above, I was just
> wondering if it was built into buildroot/busybox somehow already (eg.
> through another file or some other method).

This would be calling insmod from your init scripts, either in a for loop or 
just having a script that goes:

insmod module.ko
insmod module2.ko
insmod module3.ko -options

If you're using initramfs, that's gzipped and the repetitions should compress 
down marvelously.

> 2. Automatic load of modules for devices detected at boot time that
> might be for optional hardware, drivers, etc. As far as I understand
> kerneld (or similar daemons) do this on usual Linux systems to auto-
> load modules at runtime. eg. pcnet32 isn't loaded by default under
> VMware even though there's a network card device available. If
> there's something that supports this in buildroot/busybox by default,
> that would be great - if not, I'm just wondering how people handle it
> (if at all?) in their buildroot environments.

I have to come up to speed on this myself.  I know under 2.4 there was some 
autoloading done by the kernel itself (without ever bouncing off insmod in 
userspace), but that's before Rusty rewrote module loading for 2.6.  I have 
no idea how 2.6 handles this, I remember some talk about exporting known 
modules for a device in sysfs (based on pci vendor and device ids that 
matched), but couldn't find it when I spent 60 seconds poking around in /sys.

Wandering around the linux kernel source code, I notice that PCI vendor and 
device IDs are defined in include/linux//pci.h and used in all sorts of 
places (pci_serial_quirks[] in drivers/serial/8250_pci.c).  I vaguely 
remember there's some big master list here, and that Rusty's module utilities 
are likely to have some kind of lookup table that goes "vendor, device, 
subvendor, device, ok that would be the 'bananamatic.ko' driver with the 
'extra_slippery=comical' option."

The linux-kernel mailing list might be the place to ask about this.  And it's 
sounding like it would be an extra utility that hotplug calls before mdev, 
although I could see mdev having a CONFIG option to handle this too...

(I dunno, my kernels are statically linked.  I haven't gone there yet.)

Rob
-- 
Steve Ballmer: Innovation!  Inigo Montoya: You keep using that word.
I do not think it means what you think it means.



More information about the uClibc mailing list