Search This Blog

Wednesday, December 30, 2009

What is sysctl and its relation to /proc/sys?

Introduction

Sysctl and the /proc/sys filesystem give the user the ability to tune parameters on the actively running kernel.

Definitinon

Sysctl is a mechanism for configuring kernel parameters at run time. At boot, the system reads the /etc/sysctl.conf file. Any parameter settings that are in the file become active once the file is read. The /proc/sys filesystem contains all of the actual parameters. These parameters can be changed at any time.

Examples

The kernel has a parameter that controls the tcp keep alive intervals. This parameter exists in:
/proc/sys/net/ipv4/tcp_keepalive_intvl

If you desire to look at the current value, you can do the following:
[root@station1 ~]# cat /proc/sys/net/ipv4/tcp_keepalive_intvl
75

If you wish to set this value to 100, you can do the following:
[root@station1 ~]# echo 100 > /proc/sys/net/ipv4/tcp_keepalive_intvl
[root@station1 ~]# cat /proc/sys/net/ipv4/tcp_keepalive_intvl
100

When you reboot, the value that you changed will be lost. In order to have this change made persistent, add the following line to /etc/sysctl.conf:
net.ipv4.tcp_keepalive_intvl=100

Or run:
# sysctl -w net.ipv4.tcp_keepalive_intvl=100

Once you have done this, save the file and run:
[root@station1 ~]# sysctl -p
net.ipv4.ip_foreward = 0
kernel.sysrq = 0
net.ipv4.tcp_keepalive_intvl = 100

You should see the last line of the above output somewhere in your output.

To search for a kernel parameter related to 'cache' , you can run the following:
# sysctl -a | grep page
vm.flush_mmap_pages = 1
vm.pagecache = 100
vm.percpu_pagelist_fraction = 0
vm.nr_hugepages = 0
vm.page-cluster = 3
fs.nfs.fscache_from_pages = 0
fs.nfs.fscache_to_pages = 0
fs.nfs.fscache_uncache_page = 0

No comments: