Passing modprobe options through environment

man modprobe says in the ENVIRONMENT section:

The MODPROBE_OPTIONS environment variable can also be used to pass
arguments to modprobe.

But this is unclear. Suppose for example that I want to force the module search path by faking the kernel version string. That is the -S option. Should it be:

  • MODPROBE_OPTIONS='-S fake-version' or
  • MODPROBE_OPTIONS='-Sfake-version' or
  • MODPROBE_OPTIONS='--set-version fake-version' or
  • MODPROBE_OPTIONS='--set-version=fake-version' or maybe
  • MODPROBE_OPTIONS='set-version=fake-version'

?? This is a situation where a single example would have made all the difference.

Thanks,

Ian

Asked By: q.undertow

||

The contents of MODPROBE_OPTIONS are prepended to any existing arguments, with no processing other than splitting on spaces.

So if you want to end up with

modprobe -S fake-version module-foo

you’d set

MODPROBE_OPTIONS="-S fake-version"

and then (with the variable exported) run

modprobe module-foo
Answered By: Stephen Kitt