For better performance of the system we must tune Linux kernel parameter. Once you know what to optimize it comes to doing it by writing a parameter to the /proc file system which will tune linux kernel parameter.This /proc filesystem is created by the kernel when your server comes up, and it normally contains the settings for your kernel which is being used.
Under /proc/sys, you can find many kernel parameters that can be changed. The easy way to do this is by echoing the new value to the configuration file.
For example, the /proc/sys/vm/swappiness file contains a value that indicates how willing your server is to swap. The range of this value is between 0 and 100. A low value means that your server will avoid swapping as long as possible, while a high value means that your server is more willing to swap. The default value in this file is 60. If you think your server is too eager to swap, you can change it as follows:
[read more=”Read more” less=”Read less”]
echo "30" > /proc/sys/vm/swappiness
This way is very easy however this method has one fault meaning that this configuration will get lost once you reboot your server. So best way is to store it in a configuration file “/etc/sysctl.conf” and make sure that configuration file is read when server restarts.When booting, your server starts the sysctl service automatically, which will read this configuration file settings and applies all of the settings in it.
In /etc/sysctl.conf file, you can refer to files that exist in the /proc/sys hierarchy. Thus, the name of the fie to which you are referring is relative to this directory. Also, instead of using a slash as the separator between directories, subdirectories, and files, it is common to use a dot (even if the slash is also accepted). This means that for applying the change to the swappiness parameter as explained earlier, you must include the following line in /etc/sysctl.conf:
vm.swappiness=30
The above setting is applied the next time your server reboots. Instead of just writing it to the configuration file, you can apply it to the current sysctl settings as well. To do that, following command can be used to apply this setting immediately:
sysctl -w vm.swappiness=30
Using sysctl -w is same as using the echo “30” > /proc/sys/vm/swappiness command—it does not also write the setting to the sysctl.conf file.
The most practical way to tune linux kernel paramter is to writing them to /etc/sysctl.conf first and then activate them using below command
sysctl -p /etc/sysctl.conf
Once activated in this manner, you can also get an overview of all current sysctl settings using sysctl -a. This how we can tune linux kernel parameter. Same way as per your requirement you can tune linux kernel parameter for your system. To learn more about how to create swap space please check. [/read]