Change kernel parameters at runtime

There are three kinds of things that can be called kernel parameters.

Core kernel parameters are options passed on the kernel command line. They can only be passed at boot time. They are documented in kernel-parameters.txt (this file also lists module parameters; core kernel parameters are the ones without a .). Some of these parameters only matter at boot time (e.g. root). For the ones that are used throughout the lifetime of the system, there may or may not be a mechanism to change them at runtime, there's no general rule.

Module parameters are like kernel parameters, but they specify a particular component of the kernel, usually a specific driver. Despite the name, these parameters apply whether the corresponding driver is compiled directly in the kernel or as a module. When the component is included in the main kernel image, you need to pass COMPONENT_NAME.PARAMETER_NAME=VALUE on the kernel command line. When the component is loaded as a module, you need to pass PARAMETER_NAME=VALUE to insmod.

Some module parameters are visible through sysfs. The directory /sys/module/MODULE_NAME/parameters contains one file per parameter; reading that file gives you the current value of the parameter. Writing to that file sets the parameter, if it can be modified; most parameters cannot be modified (and so the file is read-only). The directory /sys/module/kernel/parameters lists some of the core kernel parameters.

Module parameters are documented haphazardly; some of them are listed in kernel-parameters.txt, and the file contains references for some modules. If you can't find the documentation, search the source. Module parameters are declared by the module_param macro or one of its companions module_param_named, module_param_cb, etc. The last parameter of these macros determines the file permission (e.g. 0600 or S_IRUSR | S_IWUSR would rw------- i.e. readable and writable by root and inaccessible by anyone else). When the permission is 0, the entry in sysfs doesn't appear at all.

i8042.nomux and i8042.reset are parameters of the i8042 driver. Looking at the source code, both have the permission 0, so these two parameters are not modifiable or even queryable at runtime. You can set the parameters only when the driver is started. If the driver is compiled as a module, then unloading the module and loading it again allows you to supply different parameters when you reload it. If the driver is directly in the kernel or if your system's configuration makes it effectively impossible to unload the module, you need to reboot.

Finally, another kind of parameters in the kernel is sysctl. These settings can be viewed and changed with the sysctl command or via /proc/sys. I think the separation between sysctl and kernel parameters is mostly historical; hardware-related settings are traditionally kernel parameters while software-releated settings are traditionally sysctl but the distinction can be fuzzy at times.


I think the list of parameters which can be changed in runtime can be found using " sudo sysctl -a " command. I didn't see i8042.nomux in my system. Not sure why. May be you can check it in yours, if you see the parameter then you can modify it runtime.

Tags:

Linux Kernel