sysctl for the late-comers

Category: By AG
How to set a parameter using sysctl for a module thats going to be loaded at sometime after booting?

sysctl? huh?
- sysctl is a method to change the kernel parameters (from userspace of course ;)) at the runtime. It depends on sysfs and /proc filesystems. More here

Typically the init scripts execute the specific sysctls for the specific modules. But sysctl is wasted and pointless when module is not already loaded at "init-script" time, and when its going to be loaded sysctl will still have to be made for parameter values to reach the module.

So how to do it?

Lets take example of sunrpc module and the parameter being sunrpc.tcp_slot_table_entries.

1. An udev rule is handy:

$ cat /etc/udev/rules.d/23-sunrpc.rules
# udev rule to set sysctl values when
# sunrpc module is loaded
#
SUBSYSTEM=="module" ACTION=="add" DEVPATH=="*/sunrpc" RUN+="/sbin/sysctl -w sunrpc.tcp_slot_table_entries=64"

This rule says - whenever a 'module' called 'sunrpc' is 'add'ed, run the script.

2. Add a line to /etc/modprobe.conf
install sunrpc /sbin/modprobe sunrpc; /sbin/sysctl -w sunrpc.tcp_slot_table_entries=64;

This line says - execute the following command whenever the module sunrpc is being modprobed. And we just insert the module first and then do the sysctl.

3. Or use a method similar to the my patch here, against 2.6.9-42.EL. Its generic enough but there are limitations of this method and I think userspace fix is more appropriate.


Bug closed as NOTABUG :)

0 comments so far.

Something to say?