17.5.1. Kernel module parameters

The Linux kernel allows passing module parameters at insertion time through the init_module and finit_module system calls.

The insmod tool exposes that as:

insmod params.ko i=3 j=4

Parameters are declared in the module as:

static u32 i = 0;
module_param(i, int, S_IRUSR | S_IWUSR);
MODULE_PARM_DESC(i, "my favorite int");

Automated test:

./params.sh
echo $?

Outcome: the test passes:

0

Sources:

As shown in the example, module parameters can also be read and modified at runtime from sysfs.

We can obtain the help text of the parameters with:

modinfo params.ko

The output contains:

parm:           j:my second favorite int
parm:           i:my favorite int