Difference between modprobe and sysctl -w in terms of setting system parameters?
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
We know that sysctl command can change kernel parameters with :
# sysctl -w kernel.domainname="example.com"
or by directly editing the file in /proc/sys
directory. And for persistent changes, the parameters must be written to /etc/sysctl.d/<moduleName>.conf
files as:
# echo kernel.domainname="example.com" > /etc/sysctl.d/domainname.conf
However, we can also change the kernel parameters using the modprobe command:
# modprobe kernel domainname="example.com"
And then there's the modprobe.conf file in the /etc/modprobe.d
directories, which is present in multiple locations: /etc/modprobe.d
and /usr/lib/modprobe.d
. It contains multiple .conf
files, and the options can be provided in the appropriate conf file for the module as:
options kernel domainname="example.com"
So, what's the difference between each of these methods? Which method should be used under what specific circumstances?
kernel sysctl modprobe kernel-parameters
add a comment |Â
up vote
4
down vote
favorite
We know that sysctl command can change kernel parameters with :
# sysctl -w kernel.domainname="example.com"
or by directly editing the file in /proc/sys
directory. And for persistent changes, the parameters must be written to /etc/sysctl.d/<moduleName>.conf
files as:
# echo kernel.domainname="example.com" > /etc/sysctl.d/domainname.conf
However, we can also change the kernel parameters using the modprobe command:
# modprobe kernel domainname="example.com"
And then there's the modprobe.conf file in the /etc/modprobe.d
directories, which is present in multiple locations: /etc/modprobe.d
and /usr/lib/modprobe.d
. It contains multiple .conf
files, and the options can be provided in the appropriate conf file for the module as:
options kernel domainname="example.com"
So, what's the difference between each of these methods? Which method should be used under what specific circumstances?
kernel sysctl modprobe kernel-parameters
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
We know that sysctl command can change kernel parameters with :
# sysctl -w kernel.domainname="example.com"
or by directly editing the file in /proc/sys
directory. And for persistent changes, the parameters must be written to /etc/sysctl.d/<moduleName>.conf
files as:
# echo kernel.domainname="example.com" > /etc/sysctl.d/domainname.conf
However, we can also change the kernel parameters using the modprobe command:
# modprobe kernel domainname="example.com"
And then there's the modprobe.conf file in the /etc/modprobe.d
directories, which is present in multiple locations: /etc/modprobe.d
and /usr/lib/modprobe.d
. It contains multiple .conf
files, and the options can be provided in the appropriate conf file for the module as:
options kernel domainname="example.com"
So, what's the difference between each of these methods? Which method should be used under what specific circumstances?
kernel sysctl modprobe kernel-parameters
We know that sysctl command can change kernel parameters with :
# sysctl -w kernel.domainname="example.com"
or by directly editing the file in /proc/sys
directory. And for persistent changes, the parameters must be written to /etc/sysctl.d/<moduleName>.conf
files as:
# echo kernel.domainname="example.com" > /etc/sysctl.d/domainname.conf
However, we can also change the kernel parameters using the modprobe command:
# modprobe kernel domainname="example.com"
And then there's the modprobe.conf file in the /etc/modprobe.d
directories, which is present in multiple locations: /etc/modprobe.d
and /usr/lib/modprobe.d
. It contains multiple .conf
files, and the options can be provided in the appropriate conf file for the module as:
options kernel domainname="example.com"
So, what's the difference between each of these methods? Which method should be used under what specific circumstances?
kernel sysctl modprobe kernel-parameters
edited Dec 14 '17 at 8:23
asked Dec 14 '17 at 8:17
Somenath Sinha
22319
22319
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
As far as I know, you can use modprobe
to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d
directory. (Generally you should leave /usr/lib/modprobe.d
for distribution's default settings - any files in there may get overwritten by package updates.)
If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value>
syntax, typically as a boot option. If the parameter in question is available as a sysctl
setting, then you can use the sysctl -w
command to adjust it too.
All the available sysctl parameters are presented under /proc/sys
: for example, kernel.domainname
is at /proc/sys/kernel/domainname
. Not all module parameters are available as sysctls, but some might be.
If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>
. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.
At least on my system, kernel.domainname
is a sysctl parameter for the main kernel, and trying to change it with modprobe
won't work:
# sysctl kernel.domainname
kernel.domainname = (none)
# modprobe kernel domainname="example.com"
modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
# sysctl kernel.domainname
kernel.domainname = (none)
In a nutshell: If you are unsure, first look into /proc/sys
or the output of sysctl -a
: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).
Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe
(i.e. the respective <module>.ko
file exists somewhere in the /lib/modules/<kernel version>/
directory tree), then you can use modprobe
and/or /etc/modprobe.d/
.
So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
â Somenath Sinha
Dec 14 '17 at 9:15
I've edited my answer to hopefully clarify that.
â telcoM
Dec 14 '17 at 9:29
sysctl -a will also show you all the parameters that can be set with sysctl.
â Raman Sailopal
Dec 14 '17 at 9:33
That's a good point.
â telcoM
Dec 14 '17 at 9:52
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
As far as I know, you can use modprobe
to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d
directory. (Generally you should leave /usr/lib/modprobe.d
for distribution's default settings - any files in there may get overwritten by package updates.)
If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value>
syntax, typically as a boot option. If the parameter in question is available as a sysctl
setting, then you can use the sysctl -w
command to adjust it too.
All the available sysctl parameters are presented under /proc/sys
: for example, kernel.domainname
is at /proc/sys/kernel/domainname
. Not all module parameters are available as sysctls, but some might be.
If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>
. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.
At least on my system, kernel.domainname
is a sysctl parameter for the main kernel, and trying to change it with modprobe
won't work:
# sysctl kernel.domainname
kernel.domainname = (none)
# modprobe kernel domainname="example.com"
modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
# sysctl kernel.domainname
kernel.domainname = (none)
In a nutshell: If you are unsure, first look into /proc/sys
or the output of sysctl -a
: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).
Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe
(i.e. the respective <module>.ko
file exists somewhere in the /lib/modules/<kernel version>/
directory tree), then you can use modprobe
and/or /etc/modprobe.d/
.
So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
â Somenath Sinha
Dec 14 '17 at 9:15
I've edited my answer to hopefully clarify that.
â telcoM
Dec 14 '17 at 9:29
sysctl -a will also show you all the parameters that can be set with sysctl.
â Raman Sailopal
Dec 14 '17 at 9:33
That's a good point.
â telcoM
Dec 14 '17 at 9:52
add a comment |Â
up vote
4
down vote
accepted
As far as I know, you can use modprobe
to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d
directory. (Generally you should leave /usr/lib/modprobe.d
for distribution's default settings - any files in there may get overwritten by package updates.)
If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value>
syntax, typically as a boot option. If the parameter in question is available as a sysctl
setting, then you can use the sysctl -w
command to adjust it too.
All the available sysctl parameters are presented under /proc/sys
: for example, kernel.domainname
is at /proc/sys/kernel/domainname
. Not all module parameters are available as sysctls, but some might be.
If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>
. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.
At least on my system, kernel.domainname
is a sysctl parameter for the main kernel, and trying to change it with modprobe
won't work:
# sysctl kernel.domainname
kernel.domainname = (none)
# modprobe kernel domainname="example.com"
modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
# sysctl kernel.domainname
kernel.domainname = (none)
In a nutshell: If you are unsure, first look into /proc/sys
or the output of sysctl -a
: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).
Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe
(i.e. the respective <module>.ko
file exists somewhere in the /lib/modules/<kernel version>/
directory tree), then you can use modprobe
and/or /etc/modprobe.d/
.
So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
â Somenath Sinha
Dec 14 '17 at 9:15
I've edited my answer to hopefully clarify that.
â telcoM
Dec 14 '17 at 9:29
sysctl -a will also show you all the parameters that can be set with sysctl.
â Raman Sailopal
Dec 14 '17 at 9:33
That's a good point.
â telcoM
Dec 14 '17 at 9:52
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
As far as I know, you can use modprobe
to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d
directory. (Generally you should leave /usr/lib/modprobe.d
for distribution's default settings - any files in there may get overwritten by package updates.)
If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value>
syntax, typically as a boot option. If the parameter in question is available as a sysctl
setting, then you can use the sysctl -w
command to adjust it too.
All the available sysctl parameters are presented under /proc/sys
: for example, kernel.domainname
is at /proc/sys/kernel/domainname
. Not all module parameters are available as sysctls, but some might be.
If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>
. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.
At least on my system, kernel.domainname
is a sysctl parameter for the main kernel, and trying to change it with modprobe
won't work:
# sysctl kernel.domainname
kernel.domainname = (none)
# modprobe kernel domainname="example.com"
modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
# sysctl kernel.domainname
kernel.domainname = (none)
In a nutshell: If you are unsure, first look into /proc/sys
or the output of sysctl -a
: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).
Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe
(i.e. the respective <module>.ko
file exists somewhere in the /lib/modules/<kernel version>/
directory tree), then you can use modprobe
and/or /etc/modprobe.d/
.
As far as I know, you can use modprobe
to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d
directory. (Generally you should leave /usr/lib/modprobe.d
for distribution's default settings - any files in there may get overwritten by package updates.)
If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value>
syntax, typically as a boot option. If the parameter in question is available as a sysctl
setting, then you can use the sysctl -w
command to adjust it too.
All the available sysctl parameters are presented under /proc/sys
: for example, kernel.domainname
is at /proc/sys/kernel/domainname
. Not all module parameters are available as sysctls, but some might be.
If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>
. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.
At least on my system, kernel.domainname
is a sysctl parameter for the main kernel, and trying to change it with modprobe
won't work:
# sysctl kernel.domainname
kernel.domainname = (none)
# modprobe kernel domainname="example.com"
modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
# sysctl kernel.domainname
kernel.domainname = (none)
In a nutshell: If you are unsure, first look into /proc/sys
or the output of sysctl -a
: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).
Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe
(i.e. the respective <module>.ko
file exists somewhere in the /lib/modules/<kernel version>/
directory tree), then you can use modprobe
and/or /etc/modprobe.d/
.
edited Dec 14 '17 at 9:53
answered Dec 14 '17 at 9:12
telcoM
10.8k11232
10.8k11232
So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
â Somenath Sinha
Dec 14 '17 at 9:15
I've edited my answer to hopefully clarify that.
â telcoM
Dec 14 '17 at 9:29
sysctl -a will also show you all the parameters that can be set with sysctl.
â Raman Sailopal
Dec 14 '17 at 9:33
That's a good point.
â telcoM
Dec 14 '17 at 9:52
add a comment |Â
So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
â Somenath Sinha
Dec 14 '17 at 9:15
I've edited my answer to hopefully clarify that.
â telcoM
Dec 14 '17 at 9:29
sysctl -a will also show you all the parameters that can be set with sysctl.
â Raman Sailopal
Dec 14 '17 at 9:33
That's a good point.
â telcoM
Dec 14 '17 at 9:52
So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
â Somenath Sinha
Dec 14 '17 at 9:15
So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
â Somenath Sinha
Dec 14 '17 at 9:15
I've edited my answer to hopefully clarify that.
â telcoM
Dec 14 '17 at 9:29
I've edited my answer to hopefully clarify that.
â telcoM
Dec 14 '17 at 9:29
sysctl -a will also show you all the parameters that can be set with sysctl.
â Raman Sailopal
Dec 14 '17 at 9:33
sysctl -a will also show you all the parameters that can be set with sysctl.
â Raman Sailopal
Dec 14 '17 at 9:33
That's a good point.
â telcoM
Dec 14 '17 at 9:52
That's a good point.
â telcoM
Dec 14 '17 at 9:52
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f410811%2fdifference-between-modprobe-and-sysctl-w-in-terms-of-setting-system-parameters%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password