Article explaining how to tune kernel parameters in Linux system using command or using configuration file.
In this article we will be discussing how to set or tune kernel parameter in any Linux system. There are many ways you can do it like setting them in their configuration files or using system control command
sysctl command is used to configure kernel parameters at runtime. Your current kernel parameters values can be viewed with
# sysctl -a
abi.vsyscall32 = 1
crypto.fips_enabled = 0
debug.exception-trace = 1
debug.kprobes-optimization = 1
dev.hpet.max-user-freq = 64
dev.mac_hid.mouse_button2_keycode = 97
dev.mac_hid.mouse_button3_keycode = 100
dev.mac_hid.mouse_button_emulation = 0
dev.parport.default.spintime = 500
----- output clipped -----
In above output you can see parameters on left and their current value on right. Parameters are sorted with alphabetical order and both columns in output are delimited with
= sign so that you can sort this output easily using this delimiter.
There are few parameters you can even view using proc file system. You can cat their respective files and view values.
# cat /proc/sys/kernel/shmmni
In above example we can see
shmmni value is set to 2048.
How to tune kernel parameter
To change kernel parameter you can define it under configuration file
/etc/sysctl.conf and it will be applied at next reboot. You need to define parameter=value format in this file (ex. kernel.shmmni=4096).
Each new line represent new parameter and value pair. Values in this file will be loaded at next reboot. If you want to load this file immediately then you can can do it by using
sysctl -p command. It will load
/etc/sysctl.conf file in kernel. You can even define values with
-w switch explained below.
To change kernel parameter using
sysctl, you should use write switch
-w along with parameter and value. In below example we are changing
kernel.shmmni value to 2048.
# sysctl kernel.shmmni
kernel.shmmni = 4096
# sysctl -w kernel.shmmni=2048
kernel.shmmni = 2048
You can observe previously
kernel.shmmni value was 4096, using
-w we changed it to 2048. This change is immediate and does not need a reboot to comes in effect.