Difference between revisions of "sysctl and sysfs"

From Noah.org
Jump to navigationJump to search
(Created page with 'Category:Engineering = sysctl vs. sysfs = Don't confuse these two. The '''sysctl''' interface is for stuff under '''/proc/sys''', whereas '''sysfs''' is for stuff under '''…')
 
 
Line 16: Line 16:
 
== sysctl settings -- "/etc/sysctl.conf" and "/etc/sysctl.d/" ==
 
== sysctl settings -- "/etc/sysctl.conf" and "/etc/sysctl.d/" ==
  
Sysctl will accept either '''.''' or '''/''' in key names. Often you see '''.''' used in config files, but it doesn't matter. I prefer to use '''/''' since this matches the paths in '''/proc/sys'''. Be sure to trim off the leading '''/proc/sys/''' before using it with '''sysctl'''. For example,
+
Sysctl will accept either '''.''' or '''/''' in key names. Most commonly you see '''.''' used in config files. Be sure to trim off the leading '''/proc/sys/''' before using it with '''sysctl'''. For example, the last two commands below are equivalent.
 
<pre>
 
<pre>
 
cat /proc/sys/vm/swappiness
 
cat /proc/sys/vm/swappiness
 
sysctl vm.swappiness
 
sysctl vm.swappiness
sysctl -w vm.swappiness=50
+
sysctl -w vm.swappiness=10
sysctl -w vm/swappiness=50
+
sysctl -w vm/swappiness=10
 
</pre>
 
</pre>
  
These settings can be put into '''/etc/sysctl.conf''' or under '''/etc/sysctl.d/''', such as '''/etc/sysctl.d/60-local.conf'''.
+
These settings are usually found in a conf file, '''/etc/sysctl.conf''' or in  a script under the directory, '''/etc/sysctl.d/''', such as '''/etc/sysctl.d/60-local.conf'''.

Latest revision as of 01:00, 22 January 2014


sysctl vs. sysfs

Don't confuse these two. The sysctl interface is for stuff under /proc/sys, whereas sysfs is for stuff under /sys (or anywhere a sysfs filesystem is mounted).

Under Ubuntu/Debian you may need to install the procps package to support sysctl and for processing /etc/sysctl.conf at boot. You may also need to install the sysfsutils package to support sys tool and for processing /etc/sysfs.conf at boot.

sysfs settings -- "/etc/sysfs.conf" and "/etc/sysfs.d/"

The systool' command is not often useful. It provides no way to modify attributes and most of the same information can be found under /sys/. The systool command can be used like this:

systool -c block sda -v

sysctl settings -- "/etc/sysctl.conf" and "/etc/sysctl.d/"

Sysctl will accept either . or / in key names. Most commonly you see . used in config files. Be sure to trim off the leading /proc/sys/ before using it with sysctl. For example, the last two commands below are equivalent.

cat /proc/sys/vm/swappiness
sysctl vm.swappiness
sysctl -w vm.swappiness=10
sysctl -w vm/swappiness=10

These settings are usually found in a conf file, /etc/sysctl.conf or in a script under the directory, /etc/sysctl.d/, such as /etc/sysctl.d/60-local.conf.