[aklug] Re: Grokking modprobe.conf

From: Arthur Corliss <acorliss@nevaeh-linux.org>
Date: Fri Feb 25 2011 - 11:25:08 AKST

On Fri, 25 Feb 2011, Kevin Miller wrote:

> Sorry for being dense but I'm still not getting it. In the breakdown
> above, what's the rule part, what's the module and what are the actions?
>
> Is the rule called fred? Which is also a module?

You'll have to pardon my poor vernacular. How about this:

   {type of rule} {module it applies to} {command/options}

The first field states what it applies to, i.e., is it an install, options,
remove, blacklist rule, etc. The second field is the name of the module
this specific rule applies to (fred, in this case). The remainder is the
relevant command, options, etc.

> Would the shell commands be:
> 1: modprobe barney
> 2: modprobe --ignore-install fred

Yes.

> If so, if we left #2 off why would we have a loop?

If you left #2 off entirely it would never actually load fred. If you left
#2 in, but omitted the --ignore-install option you would have a loop.

> That's where I'm confused. How many times does modprobe run? And when?
> Obviously at least once at boot up. And I can see it might when some
> event happens such as sticking a thumb drive or camera into the USB
> port. But if
>
> There's lots of modules referenced in modprobe.conf, so why don't they
> all need an --ignore-install afterwards? I presume that when modprobe
> runs it sees that my NIC is already up, so doesn't try to load the
> driver again. Why does that not happen with fred?

Modprobe may never run at all, it really depends on how the system is
configured. Some boot scripts may call modprobe explicitly to load
necessary modules. Udev can call it on demand whenever it sees a hardware
change with a device ID it knows is matched to a particular module. Some
modules, say for a random protocol, may need to be invoked manually before
usage.

Most modules don't need an install rule since many modules have explicit
dependencies that cause modprobe to autoload them. Once instance I can
think off off-hand, though, is the qla2xxx FC driver. It has an optional
dependency on scsi_dh_rdac *if* you need RDAC support, and in order for it
to enable RDAC functionality the RDAC module must be loaded prior to loading
the qlogic driver. That's a perfect test case for the install rule.

That said, any install rule that calls modprobe *for the same module* does
need an --ignore-install to avoid looping. If it's just an alias for other
modules, though, then it's not. Except in the "I hope you never see this in
the real world" case of one alias trigging an install rule to load another
alias which triggers another install rule to load the first alias. :-)

To answer your last question, you're right that if a module is already
loaded it isn't reloaded. That should hold true with fred as well. But an
install rule trumps the actual loading of a module, the shell commands are
executed in lieu of loading the module. Which is why you have to tell it to
modprobe it again in the install rule shell command section but tell it to
ignore the install rule this time so it does the default behavior of loading
the actual module instead of executing more shell commands.

I really hope I haven't made this more confusing...

         --Arthur Corliss
           Live Free or Die
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Feb 25 11:25:16 2011

This archive was generated by hypermail 2.1.8 : Fri Feb 25 2011 - 11:25:16 AKST