<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.linux-vserver.at/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.linux-vserver.at/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bobnormal</id>
		<title>Linux-VServer - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.linux-vserver.at/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bobnormal"/>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Special:Contributions/Bobnormal"/>
		<updated>2026-04-11T19:07:59Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.20.2</generator>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T13:51:04Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
To use &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt;'s Control Groups (&amp;lt;tt&amp;gt;cgroups&amp;lt;/tt&amp;gt;) support, you need to have &amp;lt;tt&amp;gt;/dev/cgroup&amp;lt;/tt&amp;gt; mounted.&lt;br /&gt;
&lt;br /&gt;
Recent versions of &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; sort this out for you by including the appropriate mount command in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; (ie: runlevel) script included in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; distribution, however this apparently only works for the &amp;lt;tt&amp;gt;sysv&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; script, and not the Debian or Gentoo ones.&lt;br /&gt;
&lt;br /&gt;
If you were to mount the &amp;lt;tt&amp;gt;cgroup&amp;lt;/tt&amp;gt; Control Groups filesystem manually, you would use something like:&lt;br /&gt;
: &amp;lt;tt&amp;gt;# mkdir /dev/cgroup&lt;br /&gt;
: # mount -t cgroup -o ''&amp;lt;subsystems&amp;gt;'' /dev/cgroup&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;tt&amp;gt;''&amp;lt;subsystems&amp;gt;''&amp;lt;/tt&amp;gt; is something like &amp;lt;tt&amp;gt;cpuset,memory&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To avoid the need for manual configuration after reboot, on Gentoo you may wish to add the cgroup mount to &amp;lt;tt&amp;gt;/etc/fstab&amp;lt;/tt&amp;gt;.  For Debian see the live examples section at the bottom of this page.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
none /dev/cgroup cgroup cpu,cpuset,memory 0 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= Real world Examples of Scheduling =&lt;br /&gt;
&lt;br /&gt;
This section is for working and tested examples you have put in place.&lt;br /&gt;
&lt;br /&gt;
Please add the following information for each example you put here (use &amp;lt;tt&amp;gt;vserver-info&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* Base kernel version&lt;br /&gt;
* vServer version&lt;br /&gt;
* Other kernel patches in use (&amp;lt;tt&amp;gt;grsec&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; release&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T13:50:42Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
To use &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt;'s Control Groups (&amp;lt;tt&amp;gt;cgroups&amp;lt;/tt&amp;gt;) support, you need to have &amp;lt;tt&amp;gt;/dev/cgroup&amp;lt;/tt&amp;gt; mounted.&lt;br /&gt;
&lt;br /&gt;
Recent versions of &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; sort this out for you by including the appropriate mount command in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; (ie: runlevel) script included in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; distribution, however this apparently only works for the &amp;lt;tt&amp;gt;sysv&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; script, and not the Debian or Gentoo ones.&lt;br /&gt;
&lt;br /&gt;
If you were to mount the &amp;lt;tt&amp;gt;cgroup&amp;lt;/tt&amp;gt; Control Groups filesystem manually, you would use something like:&lt;br /&gt;
: &amp;lt;tt&amp;gt;# mkdir /dev/cgroup&lt;br /&gt;
: # mount -t cgroup -o ''&amp;lt;subsystems&amp;gt;'' /dev/cgroup&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;tt&amp;gt;''&amp;lt;subsystems&amp;gt;''&amp;lt;/tt&amp;gt; is something like &amp;lt;tt&amp;gt;cpuset,memory&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To avoid the need for manual configuration after reboot, on Gentoo you may wish to add the cgroup mount to &amp;lt;tt&amp;gt;/etc/fstab&amp;lt;/tt&amp;gt;.  For Debian see the live examples section at the bottom of this page.&lt;br /&gt;
: &amp;lt;tt&amp;gt;none /dev/cgroup cgroup cpu,cpuset,memory 0 2&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= Real world Examples of Scheduling =&lt;br /&gt;
&lt;br /&gt;
This section is for working and tested examples you have put in place.&lt;br /&gt;
&lt;br /&gt;
Please add the following information for each example you put here (use &amp;lt;tt&amp;gt;vserver-info&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* Base kernel version&lt;br /&gt;
* vServer version&lt;br /&gt;
* Other kernel patches in use (&amp;lt;tt&amp;gt;grsec&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; release&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T13:50:26Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
To use &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt;'s Control Groups (&amp;lt;tt&amp;gt;cgroups&amp;lt;/tt&amp;gt;) support, you need to have &amp;lt;tt&amp;gt;/dev/cgroup&amp;lt;/tt&amp;gt; mounted.&lt;br /&gt;
&lt;br /&gt;
Recent versions of &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; sort this out for you by including the appropriate mount command in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; (ie: runlevel) script included in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; distribution, however this apparently only works for the &amp;lt;tt&amp;gt;sysv&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; script, and not the Debian or Gentoo ones.&lt;br /&gt;
&lt;br /&gt;
If you were to mount the &amp;lt;tt&amp;gt;cgroup&amp;lt;/tt&amp;gt; Control Groups filesystem manually, you would use something like:&lt;br /&gt;
: &amp;lt;tt&amp;gt;# mkdir /dev/cgroup&lt;br /&gt;
: # mount -t cgroup -o ''&amp;lt;subsystems&amp;gt;'' /dev/cgroup&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;tt&amp;gt;''&amp;lt;subsystems&amp;gt;''&amp;lt;/tt&amp;gt; is something like &amp;lt;tt&amp;gt;cpuset,memory&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To avoid the need for manual configuration after reboot, on Gentoo you may wish to add the cgroup mount to &amp;lt;tt&amp;gt;/etc/fstab&amp;lt;/tt&amp;gt;.  For Debian see the live examples section at the bottom of this page.&lt;br /&gt;
: &amp;lt;tt&amp;gt;none /dev/cgroup cgroup cpu,cpuset,memory&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= Real world Examples of Scheduling =&lt;br /&gt;
&lt;br /&gt;
This section is for working and tested examples you have put in place.&lt;br /&gt;
&lt;br /&gt;
Please add the following information for each example you put here (use &amp;lt;tt&amp;gt;vserver-info&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* Base kernel version&lt;br /&gt;
* vServer version&lt;br /&gt;
* Other kernel patches in use (&amp;lt;tt&amp;gt;grsec&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; release&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:51:46Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
To use &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt;'s Control Groups (&amp;lt;tt&amp;gt;cgroups&amp;lt;/tt&amp;gt;) support, you need to have &amp;lt;tt&amp;gt;/dev/cgroup&amp;lt;/tt&amp;gt; mounted.&lt;br /&gt;
&lt;br /&gt;
Recent versions of &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; sort this out for you by including the appropriate mount command in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; (ie: runlevel) script included in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; distribution.&lt;br /&gt;
&lt;br /&gt;
If you were to mount the &amp;lt;tt&amp;gt;cgroup&amp;lt;/tt&amp;gt; Control Groups filesystem manually, you would use something like:&lt;br /&gt;
: &amp;lt;tt&amp;gt;# mkdir /dev/cgroup&lt;br /&gt;
: # mount -t cgroup -o ''&amp;lt;subsystems&amp;gt;'' /dev/cgroup&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;tt&amp;gt;''&amp;lt;subsystems&amp;gt;''&amp;lt;/tt&amp;gt; is something like &amp;lt;tt&amp;gt;cpuset,memory&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= Real world Examples of Scheduling =&lt;br /&gt;
&lt;br /&gt;
This section is for working and tested examples you have put in place.&lt;br /&gt;
&lt;br /&gt;
Please add the following information for each example you put here (use &amp;lt;tt&amp;gt;vserver-info&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* Base kernel version&lt;br /&gt;
* vServer version&lt;br /&gt;
* Other kernel patches in use (&amp;lt;tt&amp;gt;grsec&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; release&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:37:41Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
To use &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt;'s Control Groups (&amp;lt;tt&amp;gt;cgroups&amp;lt;/tt&amp;gt;) support, you will need to have /dev/cgroup mounted.&lt;br /&gt;
&lt;br /&gt;
Recent versions of &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; sort this out for you by including the appropriate mount command in the &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; (runlevel) script included in the &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; distribution.&lt;br /&gt;
&lt;br /&gt;
To mount manually, you could use something like:&lt;br /&gt;
: &amp;lt;tt&amp;gt;# mkdir /dev/cgroup&lt;br /&gt;
: # mount -t cgroup -o cpuset,memory /dev/cgroup&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= Real world Examples of Scheduling =&lt;br /&gt;
&lt;br /&gt;
This section is for working and tested examples you have put in place.&lt;br /&gt;
&lt;br /&gt;
Please add the following information for each example you put here (use &amp;lt;tt&amp;gt;vserver-info&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* Base kernel version&lt;br /&gt;
* vServer version&lt;br /&gt;
* Other kernel patches in use (&amp;lt;tt&amp;gt;grsec&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; release&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:37:14Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Kernel configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
To use &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt;'s Control Groups (&amp;lt;tt&amp;gt;cgroups&amp;lt;/tt&amp;gt;) support, you will need to have /dev/cgroup mounted.  Recent versions of util-vserver sort this out for you by including the appropriate mount command in the &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; (runlevel) script.  To mount manually, you could use something like:&lt;br /&gt;
: &amp;lt;tt&amp;gt;# mkdir /dev/cgroup&lt;br /&gt;
: # mount -t cgroup -o cpuset,memory /dev/cgroup&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= Real world Examples of Scheduling =&lt;br /&gt;
&lt;br /&gt;
This section is for working and tested examples you have put in place.&lt;br /&gt;
&lt;br /&gt;
Please add the following information for each example you put here (use &amp;lt;tt&amp;gt;vserver-info&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* Base kernel version&lt;br /&gt;
* vServer version&lt;br /&gt;
* Other kernel patches in use (&amp;lt;tt&amp;gt;grsec&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; release&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:20:45Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Real world Examples of Scheduling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= Real world Examples of Scheduling =&lt;br /&gt;
&lt;br /&gt;
This section is for working and tested examples you have put in place.&lt;br /&gt;
&lt;br /&gt;
Please add the following information for each example you put here (use &amp;lt;tt&amp;gt;vserver-info&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* Base kernel version&lt;br /&gt;
* vServer version&lt;br /&gt;
* Other kernel patches in use (&amp;lt;tt&amp;gt;grsec&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
* &amp;lt;tt&amp;gt;util-vserver&amp;lt;/tt&amp;gt; release&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:19:45Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* real world exemples of scheduling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= Real world Examples of Scheduling =&lt;br /&gt;
&lt;br /&gt;
This section is for working and tested examples you have put in place.  Please add the vServer patch, base kernel version, util-vserver release for each example you put here (use &amp;lt;tt&amp;gt;vserver-info&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:17:43Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Kernel configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('''CGroup Namespaces''') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
'''CGroup Namespaces''' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= real world exemples of scheduling =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
this part is to be filled with exemple you have put in place and are working and have been tested, please add the patch and kernel version for each exemple you put here.&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:17:20Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Kernel configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; (''CGroup Namespaces'') is unset for the time being.&lt;br /&gt;
&lt;br /&gt;
''CGroup Namespaces'' are a different approach to namespaces than that used by Linux vServer, and are not currently supported.&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= real world exemples of scheduling =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
this part is to be filled with exemple you have put in place and are working and have been tested, please add the patch and kernel version for each exemple you put here.&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:16:49Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Kernel configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; (''CGroup Namespaces'') is unset for the time being (''CGroup Namespaces'' are a different approach to namespaces than that used by Linux vServer, and are not currently supported)&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= real world exemples of scheduling =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
this part is to be filled with exemple you have put in place and are working and have been tested, please add the patch and kernel version for each exemple you put here.&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-18T10:16:33Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Kernel configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure &amp;lt;tt&amp;gt;CONFIG_CGROUP_NS&amp;lt;/tt&amp;gt; ('CGroup Namespaces') is unset for the time being ('CGroup Namespaces' are a different approach to namespaces than that used by Linux vServer, and are not currently supported)&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= real world exemples of scheduling =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
this part is to be filled with exemple you have put in place and are working and have been tested, please add the patch and kernel version for each exemple you put here.&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Resource_Limits</id>
		<title>Resource Limits</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Resource_Limits"/>
				<updated>2010-02-18T10:12:52Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: add leading reference to cgroups&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''NOTE: This page describes Linux &amp;lt;tt&amp;gt;rlimit&amp;lt;/tt&amp;gt; support (an SVr4/BSD4.3/POSIX.1-2001 standard).  vServers can also be managed using the Linux Control Group (&amp;lt;tt&amp;gt;cgroup&amp;lt;/tt&amp;gt;) system, for information on Control Group based resource management, see [[util-vserver:Cgroups|util-vserver - Cgroups]].'''&lt;br /&gt;
&lt;br /&gt;
Most properties related to system resources, might it be the memory consumption, the number of processes or file-handles, qualify for imposing limits on them.&lt;br /&gt;
&lt;br /&gt;
The Linux kernel provides the getrlimit and setrlimit system calls to get and set resource limits ''per process''.  Each resource has an associated soft and hard limit. The soft limit is the value that the kernel enforces for the corresponding resource.  The hard limit acts as a ceiling for the soft limit: an unprivileged process may only set its soft limit to a value in the range from 0 up to the hard limit, and (irreversibly) lower its hard limit.  A privileged process (one with the CAP_SYS_RESOURCE capability) may make arbitrary changes to either limit value.&lt;br /&gt;
&lt;br /&gt;
The Linux-VServer kernel extends this system to provide resource limits for ''whole contexts'', not just single processes. Additionally a few new limit types missing in the vanilla kernel were introduced.&lt;br /&gt;
&lt;br /&gt;
Additionally the context limit system keeps track of observed maxima and resource limit hits, to provide some feedback for the administrator. See [[Context Accounting]] for details.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;br /&gt;
&lt;br /&gt;
== List of Resource Limits ==&lt;br /&gt;
&lt;br /&gt;
Below is a list of resource limits used for contexts and processes within. The tables contain the following information:&lt;br /&gt;
&lt;br /&gt;
; ID : Resource limit ID&lt;br /&gt;
; Name : Human readable identifier used in userspace utilities&lt;br /&gt;
; procfs : Name used in /proc/virtual/*/limit&lt;br /&gt;
; ulimit : command line switch for the ulimit utility&lt;br /&gt;
; Unit : Aprropriate unit for the limit&lt;br /&gt;
; Tag : Special resource limit code to denote if resources are accounted, enforced (see below)&lt;br /&gt;
; Description : Description of capability/flag effects&lt;br /&gt;
&lt;br /&gt;
=== Special Resource Limit Codes ===&lt;br /&gt;
&lt;br /&gt;
The tag column may contain one or more of the following tags:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_inline&amp;quot;&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| A&lt;br /&gt;
| Limit will be accounted&lt;br /&gt;
|-&lt;br /&gt;
| E&lt;br /&gt;
| Limit will be enforced&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Linux Resource Limits ===&lt;br /&gt;
&lt;br /&gt;
Below is a list of resource limits available in vanilla Linux (&amp;gt;=2.6.18).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! ID&lt;br /&gt;
! Name&lt;br /&gt;
! procfs&lt;br /&gt;
! ulimit&lt;br /&gt;
! Tag&lt;br /&gt;
! Unit&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| CPU&lt;br /&gt;
| --&lt;br /&gt;
| -t&lt;br /&gt;
|&lt;br /&gt;
| ms&lt;br /&gt;
| CPU time in ms&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| FSIZE&lt;br /&gt;
| --&lt;br /&gt;
| -f&lt;br /&gt;
|&lt;br /&gt;
| KiB&lt;br /&gt;
| Maximum file size&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| DATA&lt;br /&gt;
| --&lt;br /&gt;
| -d&lt;br /&gt;
|&lt;br /&gt;
| KiB&lt;br /&gt;
| Maximum size of the data segment&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| STACK&lt;br /&gt;
| --&lt;br /&gt;
| -s&lt;br /&gt;
|&lt;br /&gt;
| KiB&lt;br /&gt;
| Maximum stack size&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| CORE&lt;br /&gt;
| --&lt;br /&gt;
| -c&lt;br /&gt;
|&lt;br /&gt;
| KiB&lt;br /&gt;
| Maximum core file size&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| RSS&lt;br /&gt;
| RSS&lt;br /&gt;
| -m&lt;br /&gt;
| AE&lt;br /&gt;
| page&lt;br /&gt;
| Maximum resident set size&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| NPROC&lt;br /&gt;
| PROC&lt;br /&gt;
| -u&lt;br /&gt;
| AE&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum number of processes&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| NOFILE&lt;br /&gt;
| FILES&lt;br /&gt;
| -n&lt;br /&gt;
| AE&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum number of open files&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| MEMLOCK&lt;br /&gt;
| VML&lt;br /&gt;
| -l&lt;br /&gt;
| AE&lt;br /&gt;
| page&lt;br /&gt;
| Maximum locked-in-memory address space&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| AS&lt;br /&gt;
| VM&lt;br /&gt;
| -v&lt;br /&gt;
| AE&lt;br /&gt;
| page&lt;br /&gt;
| Maximum address space size&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| LOCKS&lt;br /&gt;
| LOCKS&lt;br /&gt;
| -x&lt;br /&gt;
| AE&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum file locks held&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| SIGPENDING&lt;br /&gt;
| --&lt;br /&gt;
| -i&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum number of pending signals&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| MSGQUEUE&lt;br /&gt;
| MSGQ&lt;br /&gt;
| -q&lt;br /&gt;
| AE&lt;br /&gt;
| Byte&lt;br /&gt;
| Maximum bytes in POSIX mqueues&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| NICE&lt;br /&gt;
| --&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum nice prio allowed to raise to&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| RTPRIO&lt;br /&gt;
| --&lt;br /&gt;
| -r&lt;br /&gt;
|&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum realtime priority&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Linux-VServer Resource Limits ===&lt;br /&gt;
&lt;br /&gt;
Below is a list of additional resource limits available in the Linux-VServer kernel.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! ID&lt;br /&gt;
! Name&lt;br /&gt;
! procfs&lt;br /&gt;
! Tag&lt;br /&gt;
! Unit&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| NSOCK&lt;br /&gt;
| SOCK&lt;br /&gt;
| AE&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum number of open sockets&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OPENFD&lt;br /&gt;
| OFD&lt;br /&gt;
| AE&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum number of open file descriptors&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| ANON&lt;br /&gt;
| ANON&lt;br /&gt;
| A&lt;br /&gt;
| page&lt;br /&gt;
| Maximum anonymous memory size&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| SHMEM&lt;br /&gt;
| SHM&lt;br /&gt;
| AE&lt;br /&gt;
| page&lt;br /&gt;
| Maximum shared memory size&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| SEMARY&lt;br /&gt;
| SEMA&lt;br /&gt;
| A&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum number of semaphore arrays&lt;br /&gt;
|-&lt;br /&gt;
| 21&lt;br /&gt;
| NSEMS&lt;br /&gt;
| SEMS&lt;br /&gt;
| A&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum number of semaphores&lt;br /&gt;
|-&lt;br /&gt;
| 22&lt;br /&gt;
| DENTRY&lt;br /&gt;
| DENT&lt;br /&gt;
| AE&lt;br /&gt;
| 1&lt;br /&gt;
| Maximum number of dentry structs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Determining the Page Size ==&lt;br /&gt;
&lt;br /&gt;
You can use the following program to determine the page size for your architecture (if it supports the getpagesize() function)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
        int page_size = getpagesize();&lt;br /&gt;
        printf(&amp;quot;The page size is %d\n&amp;quot;, page_size);&lt;br /&gt;
        exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here's how to compile and run it (assuming you save it as pagesize.c):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# gcc pagesize.c -o pagesize&lt;br /&gt;
# ./pagesize &lt;br /&gt;
The page size is 4096&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note''': Whether getpagesize() is present as a Linux system call depends on the architecture. If it is, it returns the kernel symbol PAGE_SIZE, which is architecture and machine model dependent. Generally, one uses binaries that are architecture but not machine model dependent, in order to have a single binary distribution per architecture. This means that a user program should not find  PAGE_SIZE at compile time from a header file, but use an actual system call, at least for those architectures (like sun4) where this dependency exists. Here libc4, libc5, glibc 2.0 fail because their getpagesize() returns a statically derived value, and does not use a system call. Things are OK in glibc 2.1.&lt;br /&gt;
&lt;br /&gt;
If you prefer, you can get the pagesize using python, just start a python console and write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; import resource&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; resource.getpagesize()&lt;br /&gt;
4096&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are some typical page sizes ...&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! arch&lt;br /&gt;
! pagesize&lt;br /&gt;
|-&lt;br /&gt;
| arm, extensa, s390, sh64, x86, x86_64, v850&lt;br /&gt;
| 4k&lt;br /&gt;
|-&lt;br /&gt;
| alpha, cris&lt;br /&gt;
| 8k&lt;br /&gt;
|-&lt;br /&gt;
| m68k, sparc&lt;br /&gt;
| 4k, 8k&lt;br /&gt;
|- &lt;br /&gt;
| powerpc&lt;br /&gt;
| 4k, 64k&lt;br /&gt;
|- &lt;br /&gt;
| parisc&lt;br /&gt;
| 4k, 16k, 64k&lt;br /&gt;
|-&lt;br /&gt;
| ia64, mips&lt;br /&gt;
| 4k, 8k, 16k, 64k&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Configure Resource Limits in util-vserver ==&lt;br /&gt;
&lt;br /&gt;
For example, if the adress space size (AS) and the resident set size (RSS) should be limited, the appropriate config files should be the following. You might have to create parent directories first.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -al /etc/vservers/myguest/rlimits&lt;br /&gt;
total 28&lt;br /&gt;
drwxr-xr-x  2 root root 4096 2005-08-24 12:37 .&lt;br /&gt;
drwxr-xr-x  5 root root 4096 2005-08-24 00:22 ..&lt;br /&gt;
-rw-r--r--  1 root root    6 2005-08-24 12:43 as&lt;br /&gt;
-rw-r--r--  1 root root    6 2005-08-24 12:37 rss&lt;br /&gt;
&lt;br /&gt;
# cat /etc/vservers/myguest/rlimits/as&lt;br /&gt;
90000&lt;br /&gt;
&lt;br /&gt;
# cat /etc/vservers/myguest/rlimits/rss&lt;br /&gt;
10000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cheatsheet</id>
		<title>util-vserver:Cheatsheet</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cheatsheet"/>
				<updated>2010-02-16T16:56:22Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* What are the services that need to be running in a basic setup ? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a cheatsheet for util-vserver. Some of these recipes have been arrived at by users, using trial and error, so they may not always be the &amp;quot;official&amp;quot; solutions.&lt;br /&gt;
&lt;br /&gt;
== Where to find the latest util-vserver ? ==&lt;br /&gt;
&lt;br /&gt;
:Look here:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;http://people.linux-vserver.org/~dhozac/t/uv-testing/&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:or checkout subversion repository:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;svn co http://svn.linux-vserver.org/svn/util-vserver/trunk util-vserver&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:And for the lastest kernel patch:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;http://vserver.13thfloor.at/Experimental/&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to add an IP address to a live guest ?==&lt;br /&gt;
&lt;br /&gt;
# create the address on the host: &amp;lt;pre&amp;gt;ifconfig eth0:10 172.16.0.145/12&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;ip addr add dev eth0 172.16.0.145/12&amp;lt;/pre&amp;gt; or even &amp;lt;pre&amp;gt;ip addr add dev dummy0 172.16.0.145/12&amp;lt;/pre&amp;gt;&lt;br /&gt;
# add the adress:&amp;lt;pre&amp;gt;naddress --nid guestname --add --ip 172.16.0.145 --bcast 172.31.255.255&amp;lt;/pre&amp;gt;&lt;br /&gt;
#* Depending on what you use the vserver for, you may not want the broadcast thing at all; you can also use a /32 mask for the IP in this case.&lt;br /&gt;
# add the ip to the config directory to make it stick if you restart &amp;lt;br/&amp;gt;&lt;br /&gt;
# enter the guest and verify services that need to listen on the ip, restart if necessary (for me it was not).&lt;br /&gt;
&lt;br /&gt;
== How to change the machine type live ?==&lt;br /&gt;
&lt;br /&gt;
: For this you can use the '''vuname''' command, &lt;br /&gt;
:: &amp;lt;pre&amp;gt;sudo vuname --xid 40133 -s -t 'machine=i686'&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: Possible values for TAG are:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;context, sysname, nodename, release, version, machine, domainname&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:To make those change permanent you have to modify the files in your /etc/vservers/&amp;lt;vserver-name&amp;gt;/uts/machine file see the great flower page for details.&lt;br /&gt;
&lt;br /&gt;
== What are the main vutils commands ?==&lt;br /&gt;
&lt;br /&gt;
: '''Main ones are''' :&lt;br /&gt;
&lt;br /&gt;
:# vserver : to create enter , start, stop, destroy etc the vserver guests.&lt;br /&gt;
:# vuname :  to change live guest : context, sysname, nodename, release, version, machine or domainname.&lt;br /&gt;
:# vattribute: to change capabilities of a live guest (bcap, ccap and flags).&lt;br /&gt;
:# nattribute: to change network capabilities and flags of a live guest (ncaps and flags).&lt;br /&gt;
:# vlimit :    to change the limits of a live guest (cpu, fsize, data, stack, core, rss, nproc,nofile, memlock, as, locks, msgqueue, nsock, openfd, anon, shmem, semary,nsems, and dentry).&lt;br /&gt;
:# vsched :    to change schheduling parameters of live guest.&lt;br /&gt;
:# vdevmap :   to remap device or  give permission to a guest to create/read/open specific devices.&lt;br /&gt;
:# vdlimit :   to change the directory limits of a live guest.&lt;br /&gt;
:: those parameters can be '''setup permanently''' in the configuration files, see the vutil flower page for details ([http://www.nongnu.org/util-vserver/doc/conf/configuration.html The Great Flower Page]).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
:'''Other usefull vutils''' :&lt;br /&gt;
&lt;br /&gt;
:# vapt-get : to run apt-get from the host in one or more guest.&lt;br /&gt;
:# vemerge  : to run emerge from the host in one or more guest.&lt;br /&gt;
:# vmount : to mount file systems inside guest from the host.&lt;br /&gt;
:# vsomething : to run one command to all vserver in one go.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: '''daily usage one''':&lt;br /&gt;
&lt;br /&gt;
:# vps : ps in a guest aware way (see all the process of host+guest).&lt;br /&gt;
:# vtop : top in a guest aware way (see all the process of host+guest).&lt;br /&gt;
:# vserver-info : gives version and other usefull information about the utils installed.&lt;br /&gt;
:# vserver-stat : gives informations about running guests.&lt;br /&gt;
&lt;br /&gt;
== What are the services that need to be running in a basic setup ?==&lt;br /&gt;
&lt;br /&gt;
: '''Services to allow on boot''' :&lt;br /&gt;
&lt;br /&gt;
:# vprocunhide : this one is mandatory to allow access to required parts of /proc on the guest&lt;br /&gt;
:# vservers-default:  this one will start the vservers on reboot, most users need this one&lt;br /&gt;
:# util-vserver : ? do not know what it does.&lt;br /&gt;
&lt;br /&gt;
: this article in incomplete, please do not hesistate to add your comments !&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-16T10:51:22Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* cgroup and CFS based CPU hard limiting that replaces sched_hard */ formatting, link to prerelease util-vserver, grammar, etc.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure CONFIG_CGROUP_NS is unset so guests start properly for the time being.&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
You can find documentation about the CFS hard limiting in &amp;lt;tt&amp;gt;Documentation/scheduler/sched-cfs-hard-limits.txt&amp;lt;/tt&amp;gt; inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
This feature is currently available in &amp;lt;tt&amp;gt;patch-2.6.31.2-vs2.3.0.36.15.diff&amp;lt;/tt&amp;gt; and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vServer start you need a recent utils package. It worked for me with: &amp;lt;tt&amp;gt;0.30.216-pre2864&amp;lt;/tt&amp;gt;.  (Download from [http://people.linux-vserver.org/~dhozac/t/uv-testing/ util-vserver prereleases])&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all CPU power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the resources used by the cgroup.&lt;br /&gt;
&lt;br /&gt;
If you set both CPU share AND hard limit the system will do fine but hard limits takes priority over CPU share scheduling, so CPU share will do the job but each cgroup will have an upper bound that it cannot cross even if the CPU share you gave it is higher.&lt;br /&gt;
&lt;br /&gt;
The hard limit feature adds 3 cgroup files for the CFS group scheduler:&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_runtime_us&amp;lt;/tt&amp;gt;: Hard limit for the group in microseconds.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_period_us&amp;lt;/tt&amp;gt;: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;cfs_hard_limit&amp;lt;/tt&amp;gt;: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= real world exemples of scheduling =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
this part is to be filled with exemple you have put in place and are working and have been tested, please add the patch and kernel version for each exemple you put here.&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/util-vserver:Cgroups</id>
		<title>util-vserver:Cgroups</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/util-vserver:Cgroups"/>
				<updated>2010-02-16T09:44:16Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: joke&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bears run away when you yell at them, even &amp;lt;tt&amp;gt;lynx&amp;lt;/tt&amp;gt;es.&lt;br /&gt;
&lt;br /&gt;
== Kernel configuration ==&lt;br /&gt;
&lt;br /&gt;
When configuring your kernel for cgroups with util-vserver you must make sure CONFIG_CGROUP_NS is unset so guests start properly for the time being.&lt;br /&gt;
&lt;br /&gt;
== Draft - Distributing cpu shares with cgroups ==&lt;br /&gt;
&lt;br /&gt;
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]&lt;br /&gt;
&lt;br /&gt;
This is simply done by adjusting the cpu.shares. Just do:&lt;br /&gt;
&lt;br /&gt;
echo '512' &amp;gt; /dev/cgroup/&amp;lt;guest name&amp;gt;/cpu.shares&lt;br /&gt;
&lt;br /&gt;
The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512   &lt;br /&gt;
vserver guest 2 =&amp;gt; 512&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048&lt;br /&gt;
vserver guest 4 =&amp;gt; 512&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so you have a total of 3584 cpu shares (2048+512+512+512) , then you get :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver guest 1 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 2 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
vserver guest 3 =&amp;gt; 2048 / 3584 = 57% cpu&lt;br /&gt;
vserver guest 4 =&amp;gt; 512 / 3584 = 14%  cpu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).&lt;br /&gt;
&lt;br /&gt;
== Making share permanent with util vserver ==&lt;br /&gt;
&lt;br /&gt;
You must use the &amp;quot;cgroup&amp;quot; directory. You can apply defaults to all vservers or choose different settings for each guest:&lt;br /&gt;
&lt;br /&gt;
* /etc/vservers/.default/cgroup    , this directory contains settings applying to all guest when they start&lt;br /&gt;
* /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup , this directory contains settings for the guest when it starts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup&lt;br /&gt;
echo '2048' &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.shares&lt;br /&gt;
# List of CPUs&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.cpus&lt;br /&gt;
# NUMA nodes&lt;br /&gt;
echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpuset.mems&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that /etc/vservers is an example, in my Aqueos install i use /usr/local/etc/vservers but /etc/vservers seems to be the defaults for the classic installs.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Ghislain.&lt;br /&gt;
&lt;br /&gt;
== cgroup and CFS based CPU hard limiting that replaces sched_hard ==&lt;br /&gt;
&lt;br /&gt;
You can find documentation about the cfs hard limiting in Documentation/scheduler/sched-cfs-hard-limits.txt inside your kernel source dir.&lt;br /&gt;
&lt;br /&gt;
This feature is currently available in patch-2.6.31.2-vs2.3.0.36.15.diff and is in testing phase as of this patch set so report any bugs to the mailing list.&lt;br /&gt;
&lt;br /&gt;
To get the hard limit setup on every vserver start you need a recent utils package. It worked for me with: 0.30.216-pre2864.&lt;br /&gt;
&lt;br /&gt;
Before trying to setup limits for one guest you should mount the cgroup filesystem:&lt;br /&gt;
&lt;br /&gt;
 [ -d /dev/cgroup ] || mkdir /dev/cgroup&lt;br /&gt;
 mount -t cgroup -ocpu none /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
Example for an upper bound of 2/5th (or 40%) of the all cpu power that a guest/cgroup can use :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# force CFS hard limit (only needed for older kernel versions)&lt;br /&gt;
# echo 1 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_hard_limit&lt;br /&gt;
# time assigned to guest (in microseconds) 200000 = 0,2 sec &lt;br /&gt;
echo 200000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_runtime_us&lt;br /&gt;
# in each specified period (in microseconds) 500000 = 0,5 sec &lt;br /&gt;
echo 500000 &amp;gt; /etc/vservers/&amp;lt;guestname&amp;gt;/cgroup/cpu.cfs_period_us&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This limit is an hard limit, see it like an upper wall for the ressources used by the cgroup. &lt;br /&gt;
If you set both cpu share AND hard limit the system will do fine but hard limits takes priority over cpu share scheduling, so cpu share will do the job but each cgroup will have an upper bound that it cannot cross even if the cpu share you gived it is higher.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  Hard limit feature adds 3 cgroup files for CFS group scheduler:&lt;br /&gt;
cfs_runtime_us: Hard limit for the group in microseconds.&lt;br /&gt;
cfs_period_us: Time period in microseconds within which hard limits is enforced.&lt;br /&gt;
cfs_hard_limit: The control file to enable or disable hard limiting for the group.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== using cgroup to enforce memory limits ==&lt;br /&gt;
&lt;br /&gt;
in linux-vserver patch version vs2.3.0.36.29 memory limiting by cgroup is introduced. to use it you need to have the following config lines in your kernel build (aditionally to the others mentioned for cgroup cpu limits):&lt;br /&gt;
&lt;br /&gt;
* CONFIG_RESOURCE_COUNTERS=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR=y&lt;br /&gt;
* CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y&lt;br /&gt;
&lt;br /&gt;
make sure /dev/cgroup is mounted with -o...,memory to be able to use this feature. The following files let you adjust memory limits of a running vserver (create them in /etc/vservers/-vserver-name-&lt;br /&gt;
/cgroup/ to make them permanent):&lt;br /&gt;
&lt;br /&gt;
* memory.memsw.limit_in_bytes the total memory limit (memory+swap) of your cgroup context&lt;br /&gt;
* memory.limit_in_bytes the total memory limit&lt;br /&gt;
&lt;br /&gt;
values are stored in bytes. When writing to those files you can use suffixes: K,M,G.&lt;br /&gt;
&lt;br /&gt;
Note: cgroup memory limits are to replace rss.soft and rss.hard some time in the future.&lt;br /&gt;
As for vs2.3.0.36.29 the tools top and free do not show the limited memory amount asigned to the guest.&lt;br /&gt;
&lt;br /&gt;
For a deeper understanding check out Documentation/cgroups/memory.txt of your kernel source tree.&lt;br /&gt;
&lt;br /&gt;
= real world exemples of scheduling =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
this part is to be filled with exemple you have put in place and are working and have been tested, please add the patch and kernel version for each exemple you put here.&lt;br /&gt;
&lt;br /&gt;
== Ben's install on Debian Lenny ==&lt;br /&gt;
&lt;br /&gt;
I used the kernels from [http://repo.psand.net], described at [http://kernels.bristolwireless.net/]. I've done this on a few versions, works for 2.6.31.7 with patch vs2.3.0.36.27 on amd64, also 2.6.31.11 with patch vs2.3.0.36.28. I used the stock Lenny util-vserver, patched as described below. The kernel config is critically important, with specific cgroup options necessary in order to get cgroups working in this way. Check the configs for the [http://repo.psand.net] kernels to see which ones I used.&lt;br /&gt;
&lt;br /&gt;
==== Getting Lenny Ready ====&lt;br /&gt;
&lt;br /&gt;
There's a very old version of util-vserver on Lenny, it needs this patch applying before it will set the cgroups properly, it basically only adds one line:&lt;br /&gt;
&lt;br /&gt;
 --- /usr/lib/util-vserver/vserver.suexec.orig	2008-12-12 22:56:25.000000000 -0600&lt;br /&gt;
 +++ /usr/lib/util-vserver/vserver.suexec	2009-08-20 02:11:42.000000000 -0500&lt;br /&gt;
 @@ -22,7 +22,8 @@ test -z &amp;quot;$is_stopped&amp;quot; -o &amp;quot;$OPTION_INSECU&lt;br /&gt;
      exit 1&lt;br /&gt;
  }&lt;br /&gt;
  generateOptions  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 -addtoCPUSET  &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +addtoCPUSET      &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
 +attachToCgroup   &amp;quot;$VSERVER_DIR&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  user=$1&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
Next I added a correctly mounted cgroup file system on /dev/cgroup/. &lt;br /&gt;
&lt;br /&gt;
 $ mkdir /dev/cgroup&lt;br /&gt;
 $ mount -t cgroup vserver /dev/cgroup&lt;br /&gt;
&lt;br /&gt;
For the util-vserver to do the right thing, this directory needed adding too:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
&lt;br /&gt;
==== Sharing out the CPU between guest servers ====&lt;br /&gt;
&lt;br /&gt;
I have a few test guests hanging around that I play with, call onetime, twotime, threetime, fourtime and fivetime. I order to set the shares for each guest I did this:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/vservers/fivetime/cgroup/ /etc/vservers/fourtime/cgroup/ /etc/vservers/threetime/cgroup/ /etc/vservers/twotime/cgroup/ /etc/vservers/twotime/cgroup/&lt;br /&gt;
 echo &amp;quot;512&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1536&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpu.shares&lt;br /&gt;
 echo &amp;quot;1024&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Then started the guests. When the system was loaded (I used one instance of cpuburn on each server - not advised but a useful test) they each should have got the following percentage of CPU.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Guest Name !! cpu.share given !! percentage of cpu&lt;br /&gt;
|-&lt;br /&gt;
| fivetime || 512 || 10% &lt;br /&gt;
|-&lt;br /&gt;
| fourtime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| threetime || 1024 || 20%&lt;br /&gt;
|-&lt;br /&gt;
| twotime || 1536 || 30%&lt;br /&gt;
|-&lt;br /&gt;
| onetime || 1024 || 20%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This didn't quite happen, as each process could migrate to other CPUs. When I fixed every guest to use only one of the available CPUs (see below how I did this) the percentage of processing time alloted to each guest were then pretty much exact! Each process was given exactly it's designated percentage of time according to vtop.&lt;br /&gt;
&lt;br /&gt;
==== Dishing out different processors sets to different guest servers ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;cpuset&amp;quot; for each guest is the subset of CPUs which it is permitted to use. I found out the number of CPUs available on my system by doing this:&lt;br /&gt;
&lt;br /&gt;
 $ cat /dev/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
This gave me the result 0-1, meaning that the overall set for my cgroups consists of CPUs 0 and 1 (for a quad core system one would expect the result 0-3, or for quad core with HT, 0-7). I stopped my guests, then for each guest specified a cpuset containing only CPU 0 for each of them:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/onetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/twotime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/threetime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fourtime/cgroup/cpuset.cpus&lt;br /&gt;
 $ echo &amp;quot;0&amp;quot; &amp;gt; /etc/vservers/fivetime/cgroup/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
On restarting the guest, I could see (using vtop) that these guest were only using the CPU 0 (the column &amp;quot;Last used cpu (SMP)&amp;quot; needs to be on in vtop in order to see this). This set up isn't particularly useful, but did allow me to check that the cpu.shares I specified for my guest were working as expected.&lt;br /&gt;
&lt;br /&gt;
==== Doing this to servers live ====&lt;br /&gt;
&lt;br /&gt;
The parameters in the last two sections can be set when the servers are running. For example to move the guest &amp;quot;threetime&amp;quot; so that it could use both CPUs I did this:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;0-1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
The processes running on threetime instantly were allocated cycle on both CPUs. Then:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;1&amp;quot; &amp;gt; /dev/cgroup/threetime/cpuset.cpus&lt;br /&gt;
&lt;br /&gt;
Shifts them all to CPU 1. One can change where cycles are allocated with impunity. The same with CPU shares:&lt;br /&gt;
&lt;br /&gt;
 $ echo &amp;quot;4096&amp;quot; &amp;gt; /dev/cgroup/threetime/cpu.shares&lt;br /&gt;
&lt;br /&gt;
Gave threetime a much bigger slice of the processors when it was under load.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The range &amp;quot;0-1&amp;quot; is not the only way of specifying a set of CPUs, I could have used &amp;quot;0,1&amp;quot;. On bigger systems, with say 8 CPUs one could use &amp;quot;0-2,4,5&amp;quot;, which would be the same as &amp;quot;0,1,2,4,5&amp;quot; or &amp;quot;0-2,4-5&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Making sure all of this gets set up after a reboot ====&lt;br /&gt;
&lt;br /&gt;
This process will make sure /dev/cgroup is present at boot and correctly mounted:&lt;br /&gt;
&lt;br /&gt;
* patch util-vserver (see above)&lt;br /&gt;
* mkdir /etc/vservers/.defaults/cgroup&lt;br /&gt;
* mkdir /lib/udev/devices/cgroup (this will mean that the /dev/cgroup is created early in the boot process)&lt;br /&gt;
* add the following line to /etc/fstab&lt;br /&gt;
 vserver    /dev/cgroup    cgroup    defaults    0 0&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Applying_CPU_Limits</id>
		<title>Applying CPU Limits</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Applying_CPU_Limits"/>
				<updated>2010-02-16T09:40:03Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Kernel config */ zcat &amp;gt; gzip -d&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Applying CPU limits =&lt;br /&gt;
&lt;br /&gt;
This is a short summary on how to apply limits. This doesn't cover how to choose the values but just on how to apply the numbers in a running vserver without saving the configuration.&lt;br /&gt;
 note: you can find soft/hard cpu limit with cgroups for vserver2.3 on [[util-vserver:Cgroups]]&lt;br /&gt;
&lt;br /&gt;
== Kernel config ==&lt;br /&gt;
&lt;br /&gt;
First check whether the kernel is with '''CONFIG_VSERVER_HARDCPU''' enabled:&lt;br /&gt;
 &lt;br /&gt;
   # cat /boot/config-blah | grep CONFIG_VSERVER_HARDCPU&lt;br /&gt;
   CONFIG_VSERVER_HARDCPU=y&lt;br /&gt;
&lt;br /&gt;
Note: With newer kernels, the config of the currently running kernel can be found with `zcat /proc/config.gz | grep VSERVER`.&lt;br /&gt;
&lt;br /&gt;
== Context flag ==&lt;br /&gt;
&lt;br /&gt;
Then check if the vserver you want to apply limits has the [http://linux-vserver.org/Capabilities_and_Flags#Context_flags_.28cflags.29 sched_hard] context flag enabled by checking the contents of ''/proc/virtual/&amp;lt;xid&amp;gt;/status''. The sched_hard flag is ''0x00000100'', so you have to find this value summed up in the vserver flag (see [http://www.mail-archive.com/vserver@list.linux-vserver.org/msg10448.html this message] for details). If its not enabled, use the following command (more info [http://www.mail-archive.com/vserver@list.linux-vserver.org/msg08385.html here]):&lt;br /&gt;
&lt;br /&gt;
  vattribute --set --xid &amp;lt;xid&amp;gt; --flag sched_hard&lt;br /&gt;
&lt;br /&gt;
== Setting the limits ==&lt;br /&gt;
&lt;br /&gt;
Then you should be able to set the limits with a command like this one (more info [http://oldwiki.linux-vserver.org/vsched+explained here]):&lt;br /&gt;
&lt;br /&gt;
  vsched --xid &amp;lt;xid&amp;gt; --fill-rate &amp;lt;fill-rate&amp;gt; --interval &amp;lt;interval&amp;gt; \&lt;br /&gt;
         --fill-rate2 &amp;lt;fill-rate2&amp;gt; --interval2 &amp;lt;interval2&amp;gt; \&lt;br /&gt;
         --tokens-max &amp;lt;tokens-max&amp;gt; --tokens-min &amp;lt;tokens-min&amp;gt; --idle-time --force &lt;br /&gt;
&lt;br /&gt;
it's important to use the option ''--force'' so the limit is applied at the same time in the cpus. If you want to enable fair share (i.e, idle-time) for the vserver, make sure to use the ''--idle-time'' option at the previous command.&lt;br /&gt;
&lt;br /&gt;
Then you should check at ''/proc/virtual/&amp;lt;xid&amp;gt;/sched'' (more info [http://linux-vserver.org/ProcFS#sched here]). Try a command like&lt;br /&gt;
&lt;br /&gt;
  watch -n1 cat /proc/virtual/&amp;lt;xid&amp;gt;/sched&lt;br /&gt;
&lt;br /&gt;
If the collum &amp;quot;Ticks spent on hold&amp;quot; is greater than zero and the flag &amp;quot;On hold (H) or running (R)&amp;quot; assumes the hold value, then its working :)&lt;br /&gt;
 &lt;br /&gt;
If you want to remove the scheduling, use the command&lt;br /&gt;
&lt;br /&gt;
  vattribute --set --xid &amp;lt;xid&amp;gt; --flag ~sched_hard&lt;br /&gt;
&lt;br /&gt;
But remember that these instructions just cover setting limits in a running vserver. To save the values you choose please refer to the [http://www.nongnu.org/util-vserver/doc/conf/configuration.html great flower page].&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Capabilities_and_Flags</id>
		<title>Capabilities and Flags</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Capabilities_and_Flags"/>
				<updated>2010-02-15T16:01:19Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Network context flags (nflags) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In computer science, a capability is a token used by a process to prove that it is allowed to perform an operation on an object. The Linux Capability System is based on &amp;quot;POSIX Capabilities&amp;quot;, a somewhat different concept, designed to split up the all powerful root privilege into a set of distinct privileges.&lt;br /&gt;
&lt;br /&gt;
== The Capability/Flag System ==&lt;br /&gt;
&lt;br /&gt;
=== POSIX Capabilities ===&lt;br /&gt;
&lt;br /&gt;
A process has three sets of bitmaps called the inheritable(I), permitted(P), and effective(E) capabilities. Each capability is implemented as a bit in each of these bitmaps that is either set or unset.&lt;br /&gt;
&lt;br /&gt;
When a process tries to do a privileged operation, the operating system will check the appropriate bit in the effective set of the process (instead of checking whether the effective uid of the process is 0 as is normally done). &lt;br /&gt;
&lt;br /&gt;
For example, when a process tries to set the clock, the Linux kernel will check that the process has the CAP_SYS_TIME bit (which is currently bit 25) set in its effective set. &lt;br /&gt;
&lt;br /&gt;
The permitted set of the process indicates the capabilities the process can use. The process can have capabilities set in the permitted set that are not in the effective set. &lt;br /&gt;
&lt;br /&gt;
This indicates that the process has temporarily disabled this capability. A process is allowed to set a bit in its effective set only if it is available in the permitted set. The distinction between effective and permitted exists so that processes can &amp;quot;bracket&amp;quot; operations that need privilege.&lt;br /&gt;
&lt;br /&gt;
The inheritable capabilities are the capabilities of the current process that should be inherited by a program executed by the current process. The permitted set of a process is masked against the inheritable set during exec(). Nothing special happens during fork() or clone(). Child processes and threads are given an exact copy of the capabilities of the parent process.&lt;br /&gt;
&lt;br /&gt;
The implementation in Linux stopped at this point, whereas POSIX Capabilities require the addition of capability sets to files too, to replace the SUID flag (at least for executables)&lt;br /&gt;
&lt;br /&gt;
=== Upper Bound for Capabilities ===&lt;br /&gt;
&lt;br /&gt;
Because the current Linux Capability system does not implement the filesystem related portions of POSIX Capabilities which would make setuid and setgid executables secure, and because it is much safer to have a secure upper bound for all processes within a context, an additional per-context capability mask has been added to limit all processes belonging to that context to this mask. &lt;br /&gt;
The meaning of the individual caps (bits) of the capability bound mask is exactly the same as with the permitted capability set.&lt;br /&gt;
&lt;br /&gt;
=== Context Capabilities ===&lt;br /&gt;
&lt;br /&gt;
As the Linux capabilities have almost reached the maximum number that is possible without heavy modifications to the kernel, it was a natural step to add a context-specific capability system.&lt;br /&gt;
&lt;br /&gt;
The Linux-VServer context capability set acts as a mechanism to fine tune existing Linux capabilities. It is not visible to the processes within a context, as they would not know how to modify or verify it.&lt;br /&gt;
&lt;br /&gt;
In general there are two ways to use those capabilities:&lt;br /&gt;
* Require one or a number of context capabilities to be set in addition to a given Linux capability, each one controlling a distinct part of the functionality. For example the CAP_NET_ADMIN could be split into RAW and PACKET sockets, so you could take away each of them separately by not providing the required context capability.&lt;br /&gt;
* Consider the context capability sufficient for a specified functionality, even if the Linux Capability says something different. For example mount() requires CAP_SYS_ADMIN which adds a dozen other things we do not want, so we define VXC_SECURE_MOUNT to allow mounts for certain contexts. &lt;br /&gt;
&lt;br /&gt;
The difference between the context flags and the context capabilities is more an abstract logical separation than a functional one, because they are handled in a very similar way.&lt;br /&gt;
&lt;br /&gt;
== List of capabilities/flags ==&lt;br /&gt;
&lt;br /&gt;
Below is a list of capabilities and flags used for contexts and processes within. The tables contain the following information:&lt;br /&gt;
&lt;br /&gt;
; Bit : The bit number to enable the capability/flag&lt;br /&gt;
; Mask : The bit number in hexadecimal notation&lt;br /&gt;
; Name : Human readable identifier used in userspace utilities&lt;br /&gt;
; Tag : Special capability/flag code to denote special behaviour, legacy usage and others (see below)&lt;br /&gt;
; Description : Description of capability/flag effects&lt;br /&gt;
&lt;br /&gt;
=== Special capability/flags codes ===&lt;br /&gt;
&lt;br /&gt;
The tag column may contain one or more of the following tags:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_inline&amp;quot;&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| I&lt;br /&gt;
| Internal use only&lt;br /&gt;
|-&lt;br /&gt;
| L&lt;br /&gt;
| Only supported with legacy enabled&lt;br /&gt;
|-&lt;br /&gt;
| O&lt;br /&gt;
| One time capability/flag (once it's cleared, it can't be re-enabled again)&lt;br /&gt;
|-&lt;br /&gt;
| U&lt;br /&gt;
| Unsupported&lt;br /&gt;
|-&lt;br /&gt;
| X&lt;br /&gt;
| Slightly different meaning in legacy&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Context capabilities (ccaps) ===&lt;br /&gt;
&lt;br /&gt;
The set of available context capabilities is specific to Linux-VServer and applied to all processes contained within a context. Below is a list of capabilities currently available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| SET_UTSNAME&lt;br /&gt;
|&lt;br /&gt;
| Allow setdomainname(2) and sethostname(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| SET_RLIMIT&lt;br /&gt;
|&lt;br /&gt;
| Allow setrlimit(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| FS_SECURITY&lt;br /&gt;
|&lt;br /&gt;
| Allow setxattr for security attributes &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| TIOCSTI&lt;br /&gt;
|&lt;br /&gt;
| Allow the tiocsti ioctl (fake input character)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| RAW_ICMP&lt;br /&gt;
| L&lt;br /&gt;
| Allow usage of raw ICMP sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 12&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00001000&lt;br /&gt;
| SYSLOG&lt;br /&gt;
|&lt;br /&gt;
| Allow syslog(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 13&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00002000&lt;br /&gt;
| OOM_ADJUST&lt;br /&gt;
|&lt;br /&gt;
| Allow 'safe' oom adjustments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 14&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00004000&lt;br /&gt;
| AUDIT_CONTROL&lt;br /&gt;
|&lt;br /&gt;
| Allow loginuid write (for auditing)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 16&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| SECURE_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow secure mount(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 17&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| SECURE_REMOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow secure remount&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 18&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| BINARY_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow binary/network mounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| QUOTA_CTL&lt;br /&gt;
|&lt;br /&gt;
| Allow quota ioctls&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00200000&lt;br /&gt;
| ADMIN_MAPPER&lt;br /&gt;
|&lt;br /&gt;
| Allow access to device mapper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00400000&lt;br /&gt;
| ADMIN_CLOOP&lt;br /&gt;
|&lt;br /&gt;
| Allow access to loop devices&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| KTHREAD&lt;br /&gt;
|&lt;br /&gt;
| Allow creating kernel threads&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 25&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| NAMESPACE&lt;br /&gt;
|&lt;br /&gt;
| Allow namespace related operations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Context flags (cflags) ===&lt;br /&gt;
&lt;br /&gt;
The set of available context flags is specific to Linux-VServer and applied to all processes contained within a context. Below is a list of flags available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| INFO_LOCK&lt;br /&gt;
| L&lt;br /&gt;
| Prohibit further context migration&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| INFO_SCHED&lt;br /&gt;
| L&lt;br /&gt;
| Account all processes as one&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| INFO_NPROC&lt;br /&gt;
| L&lt;br /&gt;
| Apply process limits to context&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| INFO_PRIVATE&lt;br /&gt;
| L&lt;br /&gt;
| Context cannot be entered&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| INFO_INIT&lt;br /&gt;
| X&lt;br /&gt;
| Show a fake init process&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 5&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000020&lt;br /&gt;
| INFO_HIDE&lt;br /&gt;
| X&lt;br /&gt;
| Hide context information in task status&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 6&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000040&lt;br /&gt;
| INFO_ULIMIT&lt;br /&gt;
| L&lt;br /&gt;
| Apply ulimits to context&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 7&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000080&lt;br /&gt;
| INFO_NSPACE&lt;br /&gt;
| L&lt;br /&gt;
| Use private namespace&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SCHED_HARD&lt;br /&gt;
|&lt;br /&gt;
| Enable hard scheduler&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| SCHED_PRIO&lt;br /&gt;
|&lt;br /&gt;
| Enable priority scheduler&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| SCHED_PAUSE&lt;br /&gt;
|&lt;br /&gt;
| Pause context (unschedule)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| VIRT_MEM&lt;br /&gt;
|&lt;br /&gt;
| Virtualize memory information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| VIRT_UPTIME&lt;br /&gt;
|&lt;br /&gt;
| Virtualize uptime information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| VIRT_CPU&lt;br /&gt;
|&lt;br /&gt;
| Virtualize cpu usage information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 23&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00080000&lt;br /&gt;
| VIRT_LOAD&lt;br /&gt;
|&lt;br /&gt;
| Virtualize load average information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| VIRT_TIME&lt;br /&gt;
|&lt;br /&gt;
| Allow per guest time offsets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 28&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| HIDE_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Hide entries in /proc/$pid/mounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| HIDE_NETIF&lt;br /&gt;
| L&lt;br /&gt;
| Hide foreign network interfaces&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| HIDE_VINFO&lt;br /&gt;
|&lt;br /&gt;
| Hide context information in task status&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 32&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_SETUP&lt;br /&gt;
| IO&lt;br /&gt;
| Enable setup state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 33&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0002&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_INIT&lt;br /&gt;
| IO&lt;br /&gt;
| Enable init state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 34&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0004&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_ADMIN&lt;br /&gt;
| O&lt;br /&gt;
| Enable admin state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 36&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;32&lt;br /&gt;
| SC_HELPER&lt;br /&gt;
| I&lt;br /&gt;
| Enable state change helper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 37&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0020&amp;lt;&amp;lt;32&lt;br /&gt;
| REBOOT_KILL&lt;br /&gt;
|&lt;br /&gt;
| Kill all processes on reboot(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 38&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0040&amp;lt;&amp;lt;32&lt;br /&gt;
| PERSISTENT&lt;br /&gt;
|&lt;br /&gt;
| Make context persistent&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 48&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;48&lt;br /&gt;
| FORK_RSS&lt;br /&gt;
|&lt;br /&gt;
| Block fork when RSS limit is exceeded&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 49&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0002&amp;lt;&amp;lt;48&lt;br /&gt;
| PROLIFIC&lt;br /&gt;
|&lt;br /&gt;
| Allow context to create new contexts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 52&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;48&lt;br /&gt;
| IGNEG_NICE&lt;br /&gt;
|&lt;br /&gt;
| Ignore priority raise&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Network capabilities (ncaps) ===&lt;br /&gt;
The set of available network capabilities is specific to Linux-VServer and applied to all processes contained within a network context.  Below is a list of flags available since ''at least'' 2.3.0.34&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| TUN_CREATE&lt;br /&gt;
| &lt;br /&gt;
| Allows the guest to open TUN devices (from the kernel's TUN/TAP-interface / network devices which link to userspace).  ie: &amp;lt;code&amp;gt;tun_set_iff()&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| RAW_ICMP&lt;br /&gt;
| &lt;br /&gt;
| Allow usage of raw ICMP sockets.  (Makes &amp;lt;code&amp;gt;ping&amp;lt;/code&amp;gt; work)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Network context flags (nflags) ===&lt;br /&gt;
&lt;br /&gt;
The set of available network context flags is specific to Linux-VServer and applied to all processes contained within a network context. Below is a list of flags available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| INFO_LOCK&lt;br /&gt;
| L&lt;br /&gt;
| Prohibit further context migration&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| INFO_PRIVATE&lt;br /&gt;
| &lt;br /&gt;
| Context cannot be entered&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SINGLE_IP&lt;br /&gt;
|&lt;br /&gt;
| Enable special handling of network contexts with a single IP only&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| LBACK_REMAP&lt;br /&gt;
|&lt;br /&gt;
| use loopback-virtualisation (will only work in 2.3.0.xx or greater)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| LBACK_ALLOW&lt;br /&gt;
|&lt;br /&gt;
| if set, allows guests without LBACK_REMAP to connect to 127.0.0.0/8&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| HIDE_NETIF&lt;br /&gt;
|&lt;br /&gt;
| Hide foreign network interfaces (ie: network interfaces not carrying and IP belonging to the guest)&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| HIDE_LBACK&lt;br /&gt;
|&lt;br /&gt;
| hides the real loopback-address from the guest (rewrites to 127.0.0.1 when queried) (will only work in 2.3.0.xx or greater)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 32&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_SETUP&lt;br /&gt;
| IO&lt;br /&gt;
| Enable setup state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 34&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0004&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_ADMIN&lt;br /&gt;
| O&lt;br /&gt;
| Enable admin state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 36&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;32&lt;br /&gt;
| SC_HELPER&lt;br /&gt;
| I&lt;br /&gt;
| Enable state change helper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 38&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0040&amp;lt;&amp;lt;32&lt;br /&gt;
| PERSISTENT&lt;br /&gt;
|&lt;br /&gt;
| Make network context persistent.  Allows you to configure a network context to use a certain IP with specific flags, and quickly run processes at later points with long pauses between them, rather than re-creating it every time a process needs to be executed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== System capabilities (bcaps) ===&lt;br /&gt;
&lt;br /&gt;
The set of available system capabilities is inherited from the Linux kernel and applied to all processes contained within a context. Below is a list of capabilities currently available in the vanilla kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color: red; font-weight: bold;&amp;quot;&amp;gt;&lt;br /&gt;
BIG FAT WARNING: Adding any system capability to your virtual server WILL reduce security. Do not change the default values unless you absolutely know what you are doing!&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| CHOWN&lt;br /&gt;
| In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this overrides the restriction of changing file ownership and group ownership.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| DAC_OVERRIDE&lt;br /&gt;
| Override all DAC access, including ACL execute access if [_POSIX_ACL] is defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| DAC_READ_SEARCH&lt;br /&gt;
| Overrides all DAC restrictions regarding read and search on files and directories, including ACL restrictions if [_POSIX_ACL] is defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| FOWNER&lt;br /&gt;
| Overrides all restrictions about allowed operations on files, where file owner ID must be equal to the user ID, except where CAP_FSETID is applicable. It doesn't override MAC and DAC restrictions.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| FSETID&lt;br /&gt;
| Overrides the following restrictions that the effective user ID shall match the file owner ID when setting the S_ISUID and S_ISGID bits on that file; that the effective group ID (or one of the supplementary group IDs) shall match the file owner ID when setting the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are cleared on successful return from chown(2) (not implemented).&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 5&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000020&lt;br /&gt;
| KILL&lt;br /&gt;
| Overrides the restriction that the real or effective user ID of a process sending a signal must match the real or effective user ID of the process receiving the signal.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 6&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000040&lt;br /&gt;
| SETGID&lt;br /&gt;
|&lt;br /&gt;
* Allows setgid(2) manipulation&lt;br /&gt;
* Allows setgroups(2)&lt;br /&gt;
* Allows forged gids on socket credentials passing.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 7&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000080&lt;br /&gt;
| SETUID&lt;br /&gt;
|&lt;br /&gt;
* Allows set*uid(2) manipulation (including fsuid).&lt;br /&gt;
* Allows forged pids on socket credentials passing.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SETPCAP&lt;br /&gt;
| Transfer any capability in your permitted set to any pid, remove any capability in your permitted set from any pid&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| LINUX_IMMUTABLE&lt;br /&gt;
| Allow modification of S_IMMUTABLE and S_APPEND file attributes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| NET_BIND_SERVICE&lt;br /&gt;
|&lt;br /&gt;
* Allows binding to TCP/UDP sockets below 1024&lt;br /&gt;
* Allows binding to ATM VCIs below 32&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 11&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000800&lt;br /&gt;
| NET_BROADCAST&lt;br /&gt;
| Allow broadcasting, listen to multicast&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 12&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00001000&lt;br /&gt;
| NET_ADMIN&lt;br /&gt;
|&lt;br /&gt;
* Allow interface configuration&lt;br /&gt;
* Allow administration of IP firewall, masquerading and accounting&lt;br /&gt;
* Allow setting debug option on sockets&lt;br /&gt;
* Allow modification of routing tables&lt;br /&gt;
* Allow setting arbitrary process / process group ownership on sockets&lt;br /&gt;
* Allow binding to any address for transparent proxying&lt;br /&gt;
* Allow setting TOS (type of service)&lt;br /&gt;
* Allow setting promiscuous mode&lt;br /&gt;
* Allow clearing driver statistics&lt;br /&gt;
* Allow multicasting&lt;br /&gt;
* Allow read/write of device-specific registers&lt;br /&gt;
* Allow activation of ATM control sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 13&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00002000&lt;br /&gt;
| NET_RAW&lt;br /&gt;
|&lt;br /&gt;
* Allow use of RAW sockets&lt;br /&gt;
* Allow use of PACKET sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 14&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00004000&lt;br /&gt;
| IPC_LOCK&lt;br /&gt;
|&lt;br /&gt;
* Allow locking of shared memory segments&lt;br /&gt;
* Allow mlock and mlockall (which doesn't really have anything to do with IPC)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 15&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00008000&lt;br /&gt;
| IPC_OWNER&lt;br /&gt;
| Override IPC ownership checks&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 16&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| SYS_MODULE&lt;br /&gt;
|&lt;br /&gt;
* Insert and remove kernel modules - modify kernel without limit&lt;br /&gt;
* Modify cap_bset&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 17&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| SYS_RAWIO&lt;br /&gt;
|&lt;br /&gt;
* Allow ioperm/iopl access&lt;br /&gt;
* Allow sending USB messages to any device via /proc/bus/usb&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 18&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| SYS_CHROOT&lt;br /&gt;
| Allow use of chroot()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 19&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00080000&lt;br /&gt;
| SYS_PTRACE&lt;br /&gt;
| Allow ptrace() of any process&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| SYS_PACCT&lt;br /&gt;
| Allow configuration of process accounting&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00200000&lt;br /&gt;
| SYS_ADMIN&lt;br /&gt;
|&lt;br /&gt;
* Allow configuration of the secure attention key&lt;br /&gt;
* Allow administration of the random device&lt;br /&gt;
* Allow examination and configuration of disk quotas&lt;br /&gt;
* Allow configuring the kernel's syslog (printk behaviour)&lt;br /&gt;
* Allow setting the domainname&lt;br /&gt;
* Allow setting the hostname&lt;br /&gt;
* Allow calling bdflush()&lt;br /&gt;
* Allow mount() and umount(), setting up new smb connection&lt;br /&gt;
* Allow some autofs root ioctls&lt;br /&gt;
* Allow nfsservctl&lt;br /&gt;
* Allow VM86_REQUEST_IRQ&lt;br /&gt;
* Allow to read/write pci config on alpha&lt;br /&gt;
* Allow irix_prctl on mips (setstacksize)&lt;br /&gt;
* Allow flushing all cache on m68k (sys_cacheflush)&lt;br /&gt;
* Allow removing semaphores (Used instead of CAP_CHOWN to &amp;quot;chown&amp;quot; IPC message queues, semaphores and shared memory)&lt;br /&gt;
* Allow locking/unlocking of shared memory segment&lt;br /&gt;
* Allow turning swap on/off&lt;br /&gt;
* Allow forged pids on socket credentials passing&lt;br /&gt;
* Allow setting readahead and flushing buffers on block devices&lt;br /&gt;
* Allow setting geometry in floppy driver&lt;br /&gt;
* Allow turning DMA on/off in xd driver&lt;br /&gt;
* Allow administration of md devices (mostly the above, but some extra ioctls)&lt;br /&gt;
* Allow tuning the ide driver&lt;br /&gt;
* Allow access to the nvram device&lt;br /&gt;
* Allow administration of apm_bios, serial and bttv (TV) device&lt;br /&gt;
* Allow manufacturer commands in isdn CAPI support driver&lt;br /&gt;
* Allow reading non-standardized portions of pci configuration space&lt;br /&gt;
* Allow DDI debug ioctl on sbpcd driver&lt;br /&gt;
* Allow setting up serial ports&lt;br /&gt;
* Allow sending raw qic-117 commands&lt;br /&gt;
* Allow enabling/disabling tagged queuing on SCSI controllers and sending arbitrary SCSI commands&lt;br /&gt;
* Allow setting encryption key on loopback filesystem&lt;br /&gt;
* Allow setting zone reclaim policy&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00400000&lt;br /&gt;
| SYS_BOOT&lt;br /&gt;
| Allow use of reboot()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 23&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00800000&lt;br /&gt;
| SYS_NICE&lt;br /&gt;
|&lt;br /&gt;
* Allow raising priority and setting priority on other (different UID) processes&lt;br /&gt;
* Allow use of FIFO and round-robin (realtime) scheduling on own processes and setting the scheduling algorithm used by another process.&lt;br /&gt;
* Allow setting cpu affinity on other processes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| SYS_RESOURCE&lt;br /&gt;
|&lt;br /&gt;
* Override resource limits. Set resource limits.&lt;br /&gt;
* Override quota limits.&lt;br /&gt;
* Override reserved space on ext2 filesystem&lt;br /&gt;
* Modify data journaling mode on ext3 filesystem (uses journaling resources)&lt;br /&gt;
* ''NOTE:'' ext2 honors fsuid when checking for resource overrides, so you can override using fsuid too&lt;br /&gt;
* Override size restrictions on IPC message queues&lt;br /&gt;
* Allow more than 64hz interrupts from the real-time clock&lt;br /&gt;
* Override max number of consoles on console allocation&lt;br /&gt;
* Override max number of keymaps&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 25&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| SYS_TIME&lt;br /&gt;
|&lt;br /&gt;
* Allow manipulation of system clock&lt;br /&gt;
* Allow irix_stime on mips&lt;br /&gt;
* Allow setting the real-time clock&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 26&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| SYS_TTY_CONFIG&lt;br /&gt;
|&lt;br /&gt;
* Allow configuration of tty devices&lt;br /&gt;
* Allow vhangup() of tty&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 27&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x08000000&lt;br /&gt;
| MKNOD&lt;br /&gt;
| Allow the privileged aspects of mknod()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 28&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x10000000&lt;br /&gt;
| LEASE&lt;br /&gt;
| Allow taking of leases on files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x20000000&lt;br /&gt;
| AUDIT_WRITE&lt;br /&gt;
| ??&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x40000000&lt;br /&gt;
| AUDIT_CONTROL&lt;br /&gt;
| ??&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Setting flags and capabilities ==&lt;br /&gt;
To see how to set the flags and capabilities, see [[util-vserver:Capabilities and Flags]] if you're using util-vserver.&lt;br /&gt;
&lt;br /&gt;
If you would like to edit those flags without restarting the vservers, you can use vattribute and nattribute. See [[util-vserver:Cheatsheet]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Capabilities_and_Flags</id>
		<title>Capabilities and Flags</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Capabilities_and_Flags"/>
				<updated>2010-02-15T15:18:27Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Network capabilities (ncaps) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In computer science, a capability is a token used by a process to prove that it is allowed to perform an operation on an object. The Linux Capability System is based on &amp;quot;POSIX Capabilities&amp;quot;, a somewhat different concept, designed to split up the all powerful root privilege into a set of distinct privileges.&lt;br /&gt;
&lt;br /&gt;
== The Capability/Flag System ==&lt;br /&gt;
&lt;br /&gt;
=== POSIX Capabilities ===&lt;br /&gt;
&lt;br /&gt;
A process has three sets of bitmaps called the inheritable(I), permitted(P), and effective(E) capabilities. Each capability is implemented as a bit in each of these bitmaps that is either set or unset.&lt;br /&gt;
&lt;br /&gt;
When a process tries to do a privileged operation, the operating system will check the appropriate bit in the effective set of the process (instead of checking whether the effective uid of the process is 0 as is normally done). &lt;br /&gt;
&lt;br /&gt;
For example, when a process tries to set the clock, the Linux kernel will check that the process has the CAP_SYS_TIME bit (which is currently bit 25) set in its effective set. &lt;br /&gt;
&lt;br /&gt;
The permitted set of the process indicates the capabilities the process can use. The process can have capabilities set in the permitted set that are not in the effective set. &lt;br /&gt;
&lt;br /&gt;
This indicates that the process has temporarily disabled this capability. A process is allowed to set a bit in its effective set only if it is available in the permitted set. The distinction between effective and permitted exists so that processes can &amp;quot;bracket&amp;quot; operations that need privilege.&lt;br /&gt;
&lt;br /&gt;
The inheritable capabilities are the capabilities of the current process that should be inherited by a program executed by the current process. The permitted set of a process is masked against the inheritable set during exec(). Nothing special happens during fork() or clone(). Child processes and threads are given an exact copy of the capabilities of the parent process.&lt;br /&gt;
&lt;br /&gt;
The implementation in Linux stopped at this point, whereas POSIX Capabilities require the addition of capability sets to files too, to replace the SUID flag (at least for executables)&lt;br /&gt;
&lt;br /&gt;
=== Upper Bound for Capabilities ===&lt;br /&gt;
&lt;br /&gt;
Because the current Linux Capability system does not implement the filesystem related portions of POSIX Capabilities which would make setuid and setgid executables secure, and because it is much safer to have a secure upper bound for all processes within a context, an additional per-context capability mask has been added to limit all processes belonging to that context to this mask. &lt;br /&gt;
The meaning of the individual caps (bits) of the capability bound mask is exactly the same as with the permitted capability set.&lt;br /&gt;
&lt;br /&gt;
=== Context Capabilities ===&lt;br /&gt;
&lt;br /&gt;
As the Linux capabilities have almost reached the maximum number that is possible without heavy modifications to the kernel, it was a natural step to add a context-specific capability system.&lt;br /&gt;
&lt;br /&gt;
The Linux-VServer context capability set acts as a mechanism to fine tune existing Linux capabilities. It is not visible to the processes within a context, as they would not know how to modify or verify it.&lt;br /&gt;
&lt;br /&gt;
In general there are two ways to use those capabilities:&lt;br /&gt;
* Require one or a number of context capabilities to be set in addition to a given Linux capability, each one controlling a distinct part of the functionality. For example the CAP_NET_ADMIN could be split into RAW and PACKET sockets, so you could take away each of them separately by not providing the required context capability.&lt;br /&gt;
* Consider the context capability sufficient for a specified functionality, even if the Linux Capability says something different. For example mount() requires CAP_SYS_ADMIN which adds a dozen other things we do not want, so we define VXC_SECURE_MOUNT to allow mounts for certain contexts. &lt;br /&gt;
&lt;br /&gt;
The difference between the context flags and the context capabilities is more an abstract logical separation than a functional one, because they are handled in a very similar way.&lt;br /&gt;
&lt;br /&gt;
== List of capabilities/flags ==&lt;br /&gt;
&lt;br /&gt;
Below is a list of capabilities and flags used for contexts and processes within. The tables contain the following information:&lt;br /&gt;
&lt;br /&gt;
; Bit : The bit number to enable the capability/flag&lt;br /&gt;
; Mask : The bit number in hexadecimal notation&lt;br /&gt;
; Name : Human readable identifier used in userspace utilities&lt;br /&gt;
; Tag : Special capability/flag code to denote special behaviour, legacy usage and others (see below)&lt;br /&gt;
; Description : Description of capability/flag effects&lt;br /&gt;
&lt;br /&gt;
=== Special capability/flags codes ===&lt;br /&gt;
&lt;br /&gt;
The tag column may contain one or more of the following tags:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_inline&amp;quot;&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| I&lt;br /&gt;
| Internal use only&lt;br /&gt;
|-&lt;br /&gt;
| L&lt;br /&gt;
| Only supported with legacy enabled&lt;br /&gt;
|-&lt;br /&gt;
| O&lt;br /&gt;
| One time capability/flag (once it's cleared, it can't be re-enabled again)&lt;br /&gt;
|-&lt;br /&gt;
| U&lt;br /&gt;
| Unsupported&lt;br /&gt;
|-&lt;br /&gt;
| X&lt;br /&gt;
| Slightly different meaning in legacy&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Context capabilities (ccaps) ===&lt;br /&gt;
&lt;br /&gt;
The set of available context capabilities is specific to Linux-VServer and applied to all processes contained within a context. Below is a list of capabilities currently available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| SET_UTSNAME&lt;br /&gt;
|&lt;br /&gt;
| Allow setdomainname(2) and sethostname(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| SET_RLIMIT&lt;br /&gt;
|&lt;br /&gt;
| Allow setrlimit(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| FS_SECURITY&lt;br /&gt;
|&lt;br /&gt;
| Allow setxattr for security attributes &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| TIOCSTI&lt;br /&gt;
|&lt;br /&gt;
| Allow the tiocsti ioctl (fake input character)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| RAW_ICMP&lt;br /&gt;
| L&lt;br /&gt;
| Allow usage of raw ICMP sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 12&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00001000&lt;br /&gt;
| SYSLOG&lt;br /&gt;
|&lt;br /&gt;
| Allow syslog(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 13&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00002000&lt;br /&gt;
| OOM_ADJUST&lt;br /&gt;
|&lt;br /&gt;
| Allow 'safe' oom adjustments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 14&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00004000&lt;br /&gt;
| AUDIT_CONTROL&lt;br /&gt;
|&lt;br /&gt;
| Allow loginuid write (for auditing)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 16&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| SECURE_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow secure mount(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 17&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| SECURE_REMOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow secure remount&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 18&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| BINARY_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow binary/network mounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| QUOTA_CTL&lt;br /&gt;
|&lt;br /&gt;
| Allow quota ioctls&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00200000&lt;br /&gt;
| ADMIN_MAPPER&lt;br /&gt;
|&lt;br /&gt;
| Allow access to device mapper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00400000&lt;br /&gt;
| ADMIN_CLOOP&lt;br /&gt;
|&lt;br /&gt;
| Allow access to loop devices&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| KTHREAD&lt;br /&gt;
|&lt;br /&gt;
| Allow creating kernel threads&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 25&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| NAMESPACE&lt;br /&gt;
|&lt;br /&gt;
| Allow namespace related operations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Context flags (cflags) ===&lt;br /&gt;
&lt;br /&gt;
The set of available context flags is specific to Linux-VServer and applied to all processes contained within a context. Below is a list of flags available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| INFO_LOCK&lt;br /&gt;
| L&lt;br /&gt;
| Prohibit further context migration&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| INFO_SCHED&lt;br /&gt;
| L&lt;br /&gt;
| Account all processes as one&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| INFO_NPROC&lt;br /&gt;
| L&lt;br /&gt;
| Apply process limits to context&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| INFO_PRIVATE&lt;br /&gt;
| L&lt;br /&gt;
| Context cannot be entered&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| INFO_INIT&lt;br /&gt;
| X&lt;br /&gt;
| Show a fake init process&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 5&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000020&lt;br /&gt;
| INFO_HIDE&lt;br /&gt;
| X&lt;br /&gt;
| Hide context information in task status&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 6&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000040&lt;br /&gt;
| INFO_ULIMIT&lt;br /&gt;
| L&lt;br /&gt;
| Apply ulimits to context&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 7&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000080&lt;br /&gt;
| INFO_NSPACE&lt;br /&gt;
| L&lt;br /&gt;
| Use private namespace&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SCHED_HARD&lt;br /&gt;
|&lt;br /&gt;
| Enable hard scheduler&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| SCHED_PRIO&lt;br /&gt;
|&lt;br /&gt;
| Enable priority scheduler&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| SCHED_PAUSE&lt;br /&gt;
|&lt;br /&gt;
| Pause context (unschedule)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| VIRT_MEM&lt;br /&gt;
|&lt;br /&gt;
| Virtualize memory information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| VIRT_UPTIME&lt;br /&gt;
|&lt;br /&gt;
| Virtualize uptime information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| VIRT_CPU&lt;br /&gt;
|&lt;br /&gt;
| Virtualize cpu usage information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 23&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00080000&lt;br /&gt;
| VIRT_LOAD&lt;br /&gt;
|&lt;br /&gt;
| Virtualize load average information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| VIRT_TIME&lt;br /&gt;
|&lt;br /&gt;
| Allow per guest time offsets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 28&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| HIDE_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Hide entries in /proc/$pid/mounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| HIDE_NETIF&lt;br /&gt;
| L&lt;br /&gt;
| Hide foreign network interfaces&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| HIDE_VINFO&lt;br /&gt;
|&lt;br /&gt;
| Hide context information in task status&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 32&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_SETUP&lt;br /&gt;
| IO&lt;br /&gt;
| Enable setup state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 33&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0002&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_INIT&lt;br /&gt;
| IO&lt;br /&gt;
| Enable init state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 34&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0004&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_ADMIN&lt;br /&gt;
| O&lt;br /&gt;
| Enable admin state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 36&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;32&lt;br /&gt;
| SC_HELPER&lt;br /&gt;
| I&lt;br /&gt;
| Enable state change helper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 37&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0020&amp;lt;&amp;lt;32&lt;br /&gt;
| REBOOT_KILL&lt;br /&gt;
|&lt;br /&gt;
| Kill all processes on reboot(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 38&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0040&amp;lt;&amp;lt;32&lt;br /&gt;
| PERSISTENT&lt;br /&gt;
|&lt;br /&gt;
| Make context persistent&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 48&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;48&lt;br /&gt;
| FORK_RSS&lt;br /&gt;
|&lt;br /&gt;
| Block fork when RSS limit is exceeded&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 49&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0002&amp;lt;&amp;lt;48&lt;br /&gt;
| PROLIFIC&lt;br /&gt;
|&lt;br /&gt;
| Allow context to create new contexts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 52&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;48&lt;br /&gt;
| IGNEG_NICE&lt;br /&gt;
|&lt;br /&gt;
| Ignore priority raise&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Network capabilities (ncaps) ===&lt;br /&gt;
The set of available network capabilities is specific to Linux-VServer and applied to all processes contained within a network context.  Below is a list of flags available since ''at least'' 2.3.0.34&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| TUN_CREATE&lt;br /&gt;
| &lt;br /&gt;
| Allows the guest to open TUN devices (from the kernel's TUN/TAP-interface / network devices which link to userspace).  ie: &amp;lt;code&amp;gt;tun_set_iff()&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| RAW_ICMP&lt;br /&gt;
| &lt;br /&gt;
| Allow usage of raw ICMP sockets.  (Makes &amp;lt;code&amp;gt;ping&amp;lt;/code&amp;gt; work)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Network context flags (nflags) ===&lt;br /&gt;
&lt;br /&gt;
The set of available network context flags is specific to Linux-VServer and applied to all processes contained within a network context. Below is a list of flags available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| INFO_LOCK&lt;br /&gt;
| L&lt;br /&gt;
| Prohibit further context migration&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| INFO_PRIVATE&lt;br /&gt;
| &lt;br /&gt;
| Context cannot be entered&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SINGLE_IP&lt;br /&gt;
|&lt;br /&gt;
| Enable special handling of network contexts with a single IP only&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| LBACK_REMAP&lt;br /&gt;
|&lt;br /&gt;
| use loopback-virtualisation (will only work in 2.3.0.xx or greater)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| LBACK_ALLOW&lt;br /&gt;
|&lt;br /&gt;
| if set, allows guests without LBACK_REMAP to connect to 127.0.0.0/8&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| HIDE_NETIF&lt;br /&gt;
|&lt;br /&gt;
| Hide foreign network interfaces (ie: network interfaces not carrying and IP belonging to the guest)&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| HIDE_LBACK&lt;br /&gt;
|&lt;br /&gt;
| hides the real loopback-address from the guest (rewrites to 127.0.0.1 when queried) (will only work in 2.3.0.xx or greater)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 32&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_SETUP&lt;br /&gt;
| IO&lt;br /&gt;
| Enable setup state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 34&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0004&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_ADMIN&lt;br /&gt;
| O&lt;br /&gt;
| Enable admin state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 36&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;32&lt;br /&gt;
| SC_HELPER&lt;br /&gt;
| I&lt;br /&gt;
| Enable state change helper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 38&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0040&amp;lt;&amp;lt;32&lt;br /&gt;
| PERSISTENT&lt;br /&gt;
|&lt;br /&gt;
| Make network context persistent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== System capabilities (bcaps) ===&lt;br /&gt;
&lt;br /&gt;
The set of available system capabilities is inherited from the Linux kernel and applied to all processes contained within a context. Below is a list of capabilities currently available in the vanilla kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color: red; font-weight: bold;&amp;quot;&amp;gt;&lt;br /&gt;
BIG FAT WARNING: Adding any system capability to your virtual server WILL reduce security. Do not change the default values unless you absolutely know what you are doing!&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| CHOWN&lt;br /&gt;
| In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this overrides the restriction of changing file ownership and group ownership.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| DAC_OVERRIDE&lt;br /&gt;
| Override all DAC access, including ACL execute access if [_POSIX_ACL] is defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| DAC_READ_SEARCH&lt;br /&gt;
| Overrides all DAC restrictions regarding read and search on files and directories, including ACL restrictions if [_POSIX_ACL] is defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| FOWNER&lt;br /&gt;
| Overrides all restrictions about allowed operations on files, where file owner ID must be equal to the user ID, except where CAP_FSETID is applicable. It doesn't override MAC and DAC restrictions.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| FSETID&lt;br /&gt;
| Overrides the following restrictions that the effective user ID shall match the file owner ID when setting the S_ISUID and S_ISGID bits on that file; that the effective group ID (or one of the supplementary group IDs) shall match the file owner ID when setting the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are cleared on successful return from chown(2) (not implemented).&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 5&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000020&lt;br /&gt;
| KILL&lt;br /&gt;
| Overrides the restriction that the real or effective user ID of a process sending a signal must match the real or effective user ID of the process receiving the signal.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 6&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000040&lt;br /&gt;
| SETGID&lt;br /&gt;
|&lt;br /&gt;
* Allows setgid(2) manipulation&lt;br /&gt;
* Allows setgroups(2)&lt;br /&gt;
* Allows forged gids on socket credentials passing.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 7&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000080&lt;br /&gt;
| SETUID&lt;br /&gt;
|&lt;br /&gt;
* Allows set*uid(2) manipulation (including fsuid).&lt;br /&gt;
* Allows forged pids on socket credentials passing.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SETPCAP&lt;br /&gt;
| Transfer any capability in your permitted set to any pid, remove any capability in your permitted set from any pid&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| LINUX_IMMUTABLE&lt;br /&gt;
| Allow modification of S_IMMUTABLE and S_APPEND file attributes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| NET_BIND_SERVICE&lt;br /&gt;
|&lt;br /&gt;
* Allows binding to TCP/UDP sockets below 1024&lt;br /&gt;
* Allows binding to ATM VCIs below 32&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 11&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000800&lt;br /&gt;
| NET_BROADCAST&lt;br /&gt;
| Allow broadcasting, listen to multicast&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 12&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00001000&lt;br /&gt;
| NET_ADMIN&lt;br /&gt;
|&lt;br /&gt;
* Allow interface configuration&lt;br /&gt;
* Allow administration of IP firewall, masquerading and accounting&lt;br /&gt;
* Allow setting debug option on sockets&lt;br /&gt;
* Allow modification of routing tables&lt;br /&gt;
* Allow setting arbitrary process / process group ownership on sockets&lt;br /&gt;
* Allow binding to any address for transparent proxying&lt;br /&gt;
* Allow setting TOS (type of service)&lt;br /&gt;
* Allow setting promiscuous mode&lt;br /&gt;
* Allow clearing driver statistics&lt;br /&gt;
* Allow multicasting&lt;br /&gt;
* Allow read/write of device-specific registers&lt;br /&gt;
* Allow activation of ATM control sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 13&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00002000&lt;br /&gt;
| NET_RAW&lt;br /&gt;
|&lt;br /&gt;
* Allow use of RAW sockets&lt;br /&gt;
* Allow use of PACKET sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 14&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00004000&lt;br /&gt;
| IPC_LOCK&lt;br /&gt;
|&lt;br /&gt;
* Allow locking of shared memory segments&lt;br /&gt;
* Allow mlock and mlockall (which doesn't really have anything to do with IPC)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 15&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00008000&lt;br /&gt;
| IPC_OWNER&lt;br /&gt;
| Override IPC ownership checks&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 16&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| SYS_MODULE&lt;br /&gt;
|&lt;br /&gt;
* Insert and remove kernel modules - modify kernel without limit&lt;br /&gt;
* Modify cap_bset&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 17&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| SYS_RAWIO&lt;br /&gt;
|&lt;br /&gt;
* Allow ioperm/iopl access&lt;br /&gt;
* Allow sending USB messages to any device via /proc/bus/usb&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 18&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| SYS_CHROOT&lt;br /&gt;
| Allow use of chroot()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 19&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00080000&lt;br /&gt;
| SYS_PTRACE&lt;br /&gt;
| Allow ptrace() of any process&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| SYS_PACCT&lt;br /&gt;
| Allow configuration of process accounting&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00200000&lt;br /&gt;
| SYS_ADMIN&lt;br /&gt;
|&lt;br /&gt;
* Allow configuration of the secure attention key&lt;br /&gt;
* Allow administration of the random device&lt;br /&gt;
* Allow examination and configuration of disk quotas&lt;br /&gt;
* Allow configuring the kernel's syslog (printk behaviour)&lt;br /&gt;
* Allow setting the domainname&lt;br /&gt;
* Allow setting the hostname&lt;br /&gt;
* Allow calling bdflush()&lt;br /&gt;
* Allow mount() and umount(), setting up new smb connection&lt;br /&gt;
* Allow some autofs root ioctls&lt;br /&gt;
* Allow nfsservctl&lt;br /&gt;
* Allow VM86_REQUEST_IRQ&lt;br /&gt;
* Allow to read/write pci config on alpha&lt;br /&gt;
* Allow irix_prctl on mips (setstacksize)&lt;br /&gt;
* Allow flushing all cache on m68k (sys_cacheflush)&lt;br /&gt;
* Allow removing semaphores (Used instead of CAP_CHOWN to &amp;quot;chown&amp;quot; IPC message queues, semaphores and shared memory)&lt;br /&gt;
* Allow locking/unlocking of shared memory segment&lt;br /&gt;
* Allow turning swap on/off&lt;br /&gt;
* Allow forged pids on socket credentials passing&lt;br /&gt;
* Allow setting readahead and flushing buffers on block devices&lt;br /&gt;
* Allow setting geometry in floppy driver&lt;br /&gt;
* Allow turning DMA on/off in xd driver&lt;br /&gt;
* Allow administration of md devices (mostly the above, but some extra ioctls)&lt;br /&gt;
* Allow tuning the ide driver&lt;br /&gt;
* Allow access to the nvram device&lt;br /&gt;
* Allow administration of apm_bios, serial and bttv (TV) device&lt;br /&gt;
* Allow manufacturer commands in isdn CAPI support driver&lt;br /&gt;
* Allow reading non-standardized portions of pci configuration space&lt;br /&gt;
* Allow DDI debug ioctl on sbpcd driver&lt;br /&gt;
* Allow setting up serial ports&lt;br /&gt;
* Allow sending raw qic-117 commands&lt;br /&gt;
* Allow enabling/disabling tagged queuing on SCSI controllers and sending arbitrary SCSI commands&lt;br /&gt;
* Allow setting encryption key on loopback filesystem&lt;br /&gt;
* Allow setting zone reclaim policy&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00400000&lt;br /&gt;
| SYS_BOOT&lt;br /&gt;
| Allow use of reboot()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 23&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00800000&lt;br /&gt;
| SYS_NICE&lt;br /&gt;
|&lt;br /&gt;
* Allow raising priority and setting priority on other (different UID) processes&lt;br /&gt;
* Allow use of FIFO and round-robin (realtime) scheduling on own processes and setting the scheduling algorithm used by another process.&lt;br /&gt;
* Allow setting cpu affinity on other processes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| SYS_RESOURCE&lt;br /&gt;
|&lt;br /&gt;
* Override resource limits. Set resource limits.&lt;br /&gt;
* Override quota limits.&lt;br /&gt;
* Override reserved space on ext2 filesystem&lt;br /&gt;
* Modify data journaling mode on ext3 filesystem (uses journaling resources)&lt;br /&gt;
* ''NOTE:'' ext2 honors fsuid when checking for resource overrides, so you can override using fsuid too&lt;br /&gt;
* Override size restrictions on IPC message queues&lt;br /&gt;
* Allow more than 64hz interrupts from the real-time clock&lt;br /&gt;
* Override max number of consoles on console allocation&lt;br /&gt;
* Override max number of keymaps&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 25&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| SYS_TIME&lt;br /&gt;
|&lt;br /&gt;
* Allow manipulation of system clock&lt;br /&gt;
* Allow irix_stime on mips&lt;br /&gt;
* Allow setting the real-time clock&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 26&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| SYS_TTY_CONFIG&lt;br /&gt;
|&lt;br /&gt;
* Allow configuration of tty devices&lt;br /&gt;
* Allow vhangup() of tty&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 27&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x08000000&lt;br /&gt;
| MKNOD&lt;br /&gt;
| Allow the privileged aspects of mknod()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 28&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x10000000&lt;br /&gt;
| LEASE&lt;br /&gt;
| Allow taking of leases on files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x20000000&lt;br /&gt;
| AUDIT_WRITE&lt;br /&gt;
| ??&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x40000000&lt;br /&gt;
| AUDIT_CONTROL&lt;br /&gt;
| ??&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Setting flags and capabilities ==&lt;br /&gt;
To see how to set the flags and capabilities, see [[util-vserver:Capabilities and Flags]] if you're using util-vserver.&lt;br /&gt;
&lt;br /&gt;
If you would like to edit those flags without restarting the vservers, you can use vattribute and nattribute. See [[util-vserver:Cheatsheet]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Capabilities_and_Flags</id>
		<title>Capabilities and Flags</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Capabilities_and_Flags"/>
				<updated>2010-02-15T15:17:17Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Network context flags (nflags) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In computer science, a capability is a token used by a process to prove that it is allowed to perform an operation on an object. The Linux Capability System is based on &amp;quot;POSIX Capabilities&amp;quot;, a somewhat different concept, designed to split up the all powerful root privilege into a set of distinct privileges.&lt;br /&gt;
&lt;br /&gt;
== The Capability/Flag System ==&lt;br /&gt;
&lt;br /&gt;
=== POSIX Capabilities ===&lt;br /&gt;
&lt;br /&gt;
A process has three sets of bitmaps called the inheritable(I), permitted(P), and effective(E) capabilities. Each capability is implemented as a bit in each of these bitmaps that is either set or unset.&lt;br /&gt;
&lt;br /&gt;
When a process tries to do a privileged operation, the operating system will check the appropriate bit in the effective set of the process (instead of checking whether the effective uid of the process is 0 as is normally done). &lt;br /&gt;
&lt;br /&gt;
For example, when a process tries to set the clock, the Linux kernel will check that the process has the CAP_SYS_TIME bit (which is currently bit 25) set in its effective set. &lt;br /&gt;
&lt;br /&gt;
The permitted set of the process indicates the capabilities the process can use. The process can have capabilities set in the permitted set that are not in the effective set. &lt;br /&gt;
&lt;br /&gt;
This indicates that the process has temporarily disabled this capability. A process is allowed to set a bit in its effective set only if it is available in the permitted set. The distinction between effective and permitted exists so that processes can &amp;quot;bracket&amp;quot; operations that need privilege.&lt;br /&gt;
&lt;br /&gt;
The inheritable capabilities are the capabilities of the current process that should be inherited by a program executed by the current process. The permitted set of a process is masked against the inheritable set during exec(). Nothing special happens during fork() or clone(). Child processes and threads are given an exact copy of the capabilities of the parent process.&lt;br /&gt;
&lt;br /&gt;
The implementation in Linux stopped at this point, whereas POSIX Capabilities require the addition of capability sets to files too, to replace the SUID flag (at least for executables)&lt;br /&gt;
&lt;br /&gt;
=== Upper Bound for Capabilities ===&lt;br /&gt;
&lt;br /&gt;
Because the current Linux Capability system does not implement the filesystem related portions of POSIX Capabilities which would make setuid and setgid executables secure, and because it is much safer to have a secure upper bound for all processes within a context, an additional per-context capability mask has been added to limit all processes belonging to that context to this mask. &lt;br /&gt;
The meaning of the individual caps (bits) of the capability bound mask is exactly the same as with the permitted capability set.&lt;br /&gt;
&lt;br /&gt;
=== Context Capabilities ===&lt;br /&gt;
&lt;br /&gt;
As the Linux capabilities have almost reached the maximum number that is possible without heavy modifications to the kernel, it was a natural step to add a context-specific capability system.&lt;br /&gt;
&lt;br /&gt;
The Linux-VServer context capability set acts as a mechanism to fine tune existing Linux capabilities. It is not visible to the processes within a context, as they would not know how to modify or verify it.&lt;br /&gt;
&lt;br /&gt;
In general there are two ways to use those capabilities:&lt;br /&gt;
* Require one or a number of context capabilities to be set in addition to a given Linux capability, each one controlling a distinct part of the functionality. For example the CAP_NET_ADMIN could be split into RAW and PACKET sockets, so you could take away each of them separately by not providing the required context capability.&lt;br /&gt;
* Consider the context capability sufficient for a specified functionality, even if the Linux Capability says something different. For example mount() requires CAP_SYS_ADMIN which adds a dozen other things we do not want, so we define VXC_SECURE_MOUNT to allow mounts for certain contexts. &lt;br /&gt;
&lt;br /&gt;
The difference between the context flags and the context capabilities is more an abstract logical separation than a functional one, because they are handled in a very similar way.&lt;br /&gt;
&lt;br /&gt;
== List of capabilities/flags ==&lt;br /&gt;
&lt;br /&gt;
Below is a list of capabilities and flags used for contexts and processes within. The tables contain the following information:&lt;br /&gt;
&lt;br /&gt;
; Bit : The bit number to enable the capability/flag&lt;br /&gt;
; Mask : The bit number in hexadecimal notation&lt;br /&gt;
; Name : Human readable identifier used in userspace utilities&lt;br /&gt;
; Tag : Special capability/flag code to denote special behaviour, legacy usage and others (see below)&lt;br /&gt;
; Description : Description of capability/flag effects&lt;br /&gt;
&lt;br /&gt;
=== Special capability/flags codes ===&lt;br /&gt;
&lt;br /&gt;
The tag column may contain one or more of the following tags:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_inline&amp;quot;&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| I&lt;br /&gt;
| Internal use only&lt;br /&gt;
|-&lt;br /&gt;
| L&lt;br /&gt;
| Only supported with legacy enabled&lt;br /&gt;
|-&lt;br /&gt;
| O&lt;br /&gt;
| One time capability/flag (once it's cleared, it can't be re-enabled again)&lt;br /&gt;
|-&lt;br /&gt;
| U&lt;br /&gt;
| Unsupported&lt;br /&gt;
|-&lt;br /&gt;
| X&lt;br /&gt;
| Slightly different meaning in legacy&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Context capabilities (ccaps) ===&lt;br /&gt;
&lt;br /&gt;
The set of available context capabilities is specific to Linux-VServer and applied to all processes contained within a context. Below is a list of capabilities currently available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| SET_UTSNAME&lt;br /&gt;
|&lt;br /&gt;
| Allow setdomainname(2) and sethostname(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| SET_RLIMIT&lt;br /&gt;
|&lt;br /&gt;
| Allow setrlimit(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| FS_SECURITY&lt;br /&gt;
|&lt;br /&gt;
| Allow setxattr for security attributes &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| TIOCSTI&lt;br /&gt;
|&lt;br /&gt;
| Allow the tiocsti ioctl (fake input character)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| RAW_ICMP&lt;br /&gt;
| L&lt;br /&gt;
| Allow usage of raw ICMP sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 12&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00001000&lt;br /&gt;
| SYSLOG&lt;br /&gt;
|&lt;br /&gt;
| Allow syslog(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 13&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00002000&lt;br /&gt;
| OOM_ADJUST&lt;br /&gt;
|&lt;br /&gt;
| Allow 'safe' oom adjustments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 14&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00004000&lt;br /&gt;
| AUDIT_CONTROL&lt;br /&gt;
|&lt;br /&gt;
| Allow loginuid write (for auditing)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 16&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| SECURE_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow secure mount(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 17&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| SECURE_REMOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow secure remount&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 18&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| BINARY_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow binary/network mounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| QUOTA_CTL&lt;br /&gt;
|&lt;br /&gt;
| Allow quota ioctls&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00200000&lt;br /&gt;
| ADMIN_MAPPER&lt;br /&gt;
|&lt;br /&gt;
| Allow access to device mapper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00400000&lt;br /&gt;
| ADMIN_CLOOP&lt;br /&gt;
|&lt;br /&gt;
| Allow access to loop devices&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| KTHREAD&lt;br /&gt;
|&lt;br /&gt;
| Allow creating kernel threads&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 25&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| NAMESPACE&lt;br /&gt;
|&lt;br /&gt;
| Allow namespace related operations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Context flags (cflags) ===&lt;br /&gt;
&lt;br /&gt;
The set of available context flags is specific to Linux-VServer and applied to all processes contained within a context. Below is a list of flags available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| INFO_LOCK&lt;br /&gt;
| L&lt;br /&gt;
| Prohibit further context migration&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| INFO_SCHED&lt;br /&gt;
| L&lt;br /&gt;
| Account all processes as one&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| INFO_NPROC&lt;br /&gt;
| L&lt;br /&gt;
| Apply process limits to context&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| INFO_PRIVATE&lt;br /&gt;
| L&lt;br /&gt;
| Context cannot be entered&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| INFO_INIT&lt;br /&gt;
| X&lt;br /&gt;
| Show a fake init process&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 5&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000020&lt;br /&gt;
| INFO_HIDE&lt;br /&gt;
| X&lt;br /&gt;
| Hide context information in task status&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 6&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000040&lt;br /&gt;
| INFO_ULIMIT&lt;br /&gt;
| L&lt;br /&gt;
| Apply ulimits to context&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 7&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000080&lt;br /&gt;
| INFO_NSPACE&lt;br /&gt;
| L&lt;br /&gt;
| Use private namespace&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SCHED_HARD&lt;br /&gt;
|&lt;br /&gt;
| Enable hard scheduler&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| SCHED_PRIO&lt;br /&gt;
|&lt;br /&gt;
| Enable priority scheduler&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| SCHED_PAUSE&lt;br /&gt;
|&lt;br /&gt;
| Pause context (unschedule)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| VIRT_MEM&lt;br /&gt;
|&lt;br /&gt;
| Virtualize memory information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| VIRT_UPTIME&lt;br /&gt;
|&lt;br /&gt;
| Virtualize uptime information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| VIRT_CPU&lt;br /&gt;
|&lt;br /&gt;
| Virtualize cpu usage information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 23&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00080000&lt;br /&gt;
| VIRT_LOAD&lt;br /&gt;
|&lt;br /&gt;
| Virtualize load average information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| VIRT_TIME&lt;br /&gt;
|&lt;br /&gt;
| Allow per guest time offsets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 28&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| HIDE_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Hide entries in /proc/$pid/mounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| HIDE_NETIF&lt;br /&gt;
| L&lt;br /&gt;
| Hide foreign network interfaces&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| HIDE_VINFO&lt;br /&gt;
|&lt;br /&gt;
| Hide context information in task status&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 32&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_SETUP&lt;br /&gt;
| IO&lt;br /&gt;
| Enable setup state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 33&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0002&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_INIT&lt;br /&gt;
| IO&lt;br /&gt;
| Enable init state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 34&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0004&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_ADMIN&lt;br /&gt;
| O&lt;br /&gt;
| Enable admin state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 36&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;32&lt;br /&gt;
| SC_HELPER&lt;br /&gt;
| I&lt;br /&gt;
| Enable state change helper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 37&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0020&amp;lt;&amp;lt;32&lt;br /&gt;
| REBOOT_KILL&lt;br /&gt;
|&lt;br /&gt;
| Kill all processes on reboot(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 38&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0040&amp;lt;&amp;lt;32&lt;br /&gt;
| PERSISTENT&lt;br /&gt;
|&lt;br /&gt;
| Make context persistent&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 48&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;48&lt;br /&gt;
| FORK_RSS&lt;br /&gt;
|&lt;br /&gt;
| Block fork when RSS limit is exceeded&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 49&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0002&amp;lt;&amp;lt;48&lt;br /&gt;
| PROLIFIC&lt;br /&gt;
|&lt;br /&gt;
| Allow context to create new contexts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 52&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;48&lt;br /&gt;
| IGNEG_NICE&lt;br /&gt;
|&lt;br /&gt;
| Ignore priority raise&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Network capabilities (ncaps) ===&lt;br /&gt;
The set of available network capabilities is specific to Linux-VServer and applied to all processes contained with a network context.  Below is a list of flags available since ''at least'' 2.3.0.34&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| TUN_CREATE&lt;br /&gt;
| &lt;br /&gt;
| Allows the guest to open TUN devices (from the kernel's TUN/TAP-interface / network devices which link to userspace).  ie: &amp;lt;code&amp;gt;tun_set_iff()&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| RAW_ICMP&lt;br /&gt;
| &lt;br /&gt;
| Allow usage of raw ICMP sockets.  (Makes &amp;lt;code&amp;gt;ping&amp;lt;/code&amp;gt; work)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Network context flags (nflags) ===&lt;br /&gt;
&lt;br /&gt;
The set of available network context flags is specific to Linux-VServer and applied to all processes contained within a network context. Below is a list of flags available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| INFO_LOCK&lt;br /&gt;
| L&lt;br /&gt;
| Prohibit further context migration&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| INFO_PRIVATE&lt;br /&gt;
| &lt;br /&gt;
| Context cannot be entered&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SINGLE_IP&lt;br /&gt;
|&lt;br /&gt;
| Enable special handling of network contexts with a single IP only&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| LBACK_REMAP&lt;br /&gt;
|&lt;br /&gt;
| use loopback-virtualisation (will only work in 2.3.0.xx or greater)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| LBACK_ALLOW&lt;br /&gt;
|&lt;br /&gt;
| if set, allows guests without LBACK_REMAP to connect to 127.0.0.0/8&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| HIDE_NETIF&lt;br /&gt;
|&lt;br /&gt;
| Hide foreign network interfaces (ie: network interfaces not carrying and IP belonging to the guest)&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| HIDE_LBACK&lt;br /&gt;
|&lt;br /&gt;
| hides the real loopback-address from the guest (rewrites to 127.0.0.1 when queried) (will only work in 2.3.0.xx or greater)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 32&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_SETUP&lt;br /&gt;
| IO&lt;br /&gt;
| Enable setup state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 34&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0004&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_ADMIN&lt;br /&gt;
| O&lt;br /&gt;
| Enable admin state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 36&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;32&lt;br /&gt;
| SC_HELPER&lt;br /&gt;
| I&lt;br /&gt;
| Enable state change helper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 38&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0040&amp;lt;&amp;lt;32&lt;br /&gt;
| PERSISTENT&lt;br /&gt;
|&lt;br /&gt;
| Make network context persistent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== System capabilities (bcaps) ===&lt;br /&gt;
&lt;br /&gt;
The set of available system capabilities is inherited from the Linux kernel and applied to all processes contained within a context. Below is a list of capabilities currently available in the vanilla kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color: red; font-weight: bold;&amp;quot;&amp;gt;&lt;br /&gt;
BIG FAT WARNING: Adding any system capability to your virtual server WILL reduce security. Do not change the default values unless you absolutely know what you are doing!&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| CHOWN&lt;br /&gt;
| In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this overrides the restriction of changing file ownership and group ownership.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| DAC_OVERRIDE&lt;br /&gt;
| Override all DAC access, including ACL execute access if [_POSIX_ACL] is defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| DAC_READ_SEARCH&lt;br /&gt;
| Overrides all DAC restrictions regarding read and search on files and directories, including ACL restrictions if [_POSIX_ACL] is defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| FOWNER&lt;br /&gt;
| Overrides all restrictions about allowed operations on files, where file owner ID must be equal to the user ID, except where CAP_FSETID is applicable. It doesn't override MAC and DAC restrictions.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| FSETID&lt;br /&gt;
| Overrides the following restrictions that the effective user ID shall match the file owner ID when setting the S_ISUID and S_ISGID bits on that file; that the effective group ID (or one of the supplementary group IDs) shall match the file owner ID when setting the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are cleared on successful return from chown(2) (not implemented).&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 5&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000020&lt;br /&gt;
| KILL&lt;br /&gt;
| Overrides the restriction that the real or effective user ID of a process sending a signal must match the real or effective user ID of the process receiving the signal.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 6&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000040&lt;br /&gt;
| SETGID&lt;br /&gt;
|&lt;br /&gt;
* Allows setgid(2) manipulation&lt;br /&gt;
* Allows setgroups(2)&lt;br /&gt;
* Allows forged gids on socket credentials passing.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 7&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000080&lt;br /&gt;
| SETUID&lt;br /&gt;
|&lt;br /&gt;
* Allows set*uid(2) manipulation (including fsuid).&lt;br /&gt;
* Allows forged pids on socket credentials passing.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SETPCAP&lt;br /&gt;
| Transfer any capability in your permitted set to any pid, remove any capability in your permitted set from any pid&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| LINUX_IMMUTABLE&lt;br /&gt;
| Allow modification of S_IMMUTABLE and S_APPEND file attributes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| NET_BIND_SERVICE&lt;br /&gt;
|&lt;br /&gt;
* Allows binding to TCP/UDP sockets below 1024&lt;br /&gt;
* Allows binding to ATM VCIs below 32&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 11&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000800&lt;br /&gt;
| NET_BROADCAST&lt;br /&gt;
| Allow broadcasting, listen to multicast&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 12&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00001000&lt;br /&gt;
| NET_ADMIN&lt;br /&gt;
|&lt;br /&gt;
* Allow interface configuration&lt;br /&gt;
* Allow administration of IP firewall, masquerading and accounting&lt;br /&gt;
* Allow setting debug option on sockets&lt;br /&gt;
* Allow modification of routing tables&lt;br /&gt;
* Allow setting arbitrary process / process group ownership on sockets&lt;br /&gt;
* Allow binding to any address for transparent proxying&lt;br /&gt;
* Allow setting TOS (type of service)&lt;br /&gt;
* Allow setting promiscuous mode&lt;br /&gt;
* Allow clearing driver statistics&lt;br /&gt;
* Allow multicasting&lt;br /&gt;
* Allow read/write of device-specific registers&lt;br /&gt;
* Allow activation of ATM control sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 13&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00002000&lt;br /&gt;
| NET_RAW&lt;br /&gt;
|&lt;br /&gt;
* Allow use of RAW sockets&lt;br /&gt;
* Allow use of PACKET sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 14&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00004000&lt;br /&gt;
| IPC_LOCK&lt;br /&gt;
|&lt;br /&gt;
* Allow locking of shared memory segments&lt;br /&gt;
* Allow mlock and mlockall (which doesn't really have anything to do with IPC)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 15&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00008000&lt;br /&gt;
| IPC_OWNER&lt;br /&gt;
| Override IPC ownership checks&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 16&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| SYS_MODULE&lt;br /&gt;
|&lt;br /&gt;
* Insert and remove kernel modules - modify kernel without limit&lt;br /&gt;
* Modify cap_bset&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 17&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| SYS_RAWIO&lt;br /&gt;
|&lt;br /&gt;
* Allow ioperm/iopl access&lt;br /&gt;
* Allow sending USB messages to any device via /proc/bus/usb&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 18&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| SYS_CHROOT&lt;br /&gt;
| Allow use of chroot()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 19&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00080000&lt;br /&gt;
| SYS_PTRACE&lt;br /&gt;
| Allow ptrace() of any process&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| SYS_PACCT&lt;br /&gt;
| Allow configuration of process accounting&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00200000&lt;br /&gt;
| SYS_ADMIN&lt;br /&gt;
|&lt;br /&gt;
* Allow configuration of the secure attention key&lt;br /&gt;
* Allow administration of the random device&lt;br /&gt;
* Allow examination and configuration of disk quotas&lt;br /&gt;
* Allow configuring the kernel's syslog (printk behaviour)&lt;br /&gt;
* Allow setting the domainname&lt;br /&gt;
* Allow setting the hostname&lt;br /&gt;
* Allow calling bdflush()&lt;br /&gt;
* Allow mount() and umount(), setting up new smb connection&lt;br /&gt;
* Allow some autofs root ioctls&lt;br /&gt;
* Allow nfsservctl&lt;br /&gt;
* Allow VM86_REQUEST_IRQ&lt;br /&gt;
* Allow to read/write pci config on alpha&lt;br /&gt;
* Allow irix_prctl on mips (setstacksize)&lt;br /&gt;
* Allow flushing all cache on m68k (sys_cacheflush)&lt;br /&gt;
* Allow removing semaphores (Used instead of CAP_CHOWN to &amp;quot;chown&amp;quot; IPC message queues, semaphores and shared memory)&lt;br /&gt;
* Allow locking/unlocking of shared memory segment&lt;br /&gt;
* Allow turning swap on/off&lt;br /&gt;
* Allow forged pids on socket credentials passing&lt;br /&gt;
* Allow setting readahead and flushing buffers on block devices&lt;br /&gt;
* Allow setting geometry in floppy driver&lt;br /&gt;
* Allow turning DMA on/off in xd driver&lt;br /&gt;
* Allow administration of md devices (mostly the above, but some extra ioctls)&lt;br /&gt;
* Allow tuning the ide driver&lt;br /&gt;
* Allow access to the nvram device&lt;br /&gt;
* Allow administration of apm_bios, serial and bttv (TV) device&lt;br /&gt;
* Allow manufacturer commands in isdn CAPI support driver&lt;br /&gt;
* Allow reading non-standardized portions of pci configuration space&lt;br /&gt;
* Allow DDI debug ioctl on sbpcd driver&lt;br /&gt;
* Allow setting up serial ports&lt;br /&gt;
* Allow sending raw qic-117 commands&lt;br /&gt;
* Allow enabling/disabling tagged queuing on SCSI controllers and sending arbitrary SCSI commands&lt;br /&gt;
* Allow setting encryption key on loopback filesystem&lt;br /&gt;
* Allow setting zone reclaim policy&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00400000&lt;br /&gt;
| SYS_BOOT&lt;br /&gt;
| Allow use of reboot()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 23&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00800000&lt;br /&gt;
| SYS_NICE&lt;br /&gt;
|&lt;br /&gt;
* Allow raising priority and setting priority on other (different UID) processes&lt;br /&gt;
* Allow use of FIFO and round-robin (realtime) scheduling on own processes and setting the scheduling algorithm used by another process.&lt;br /&gt;
* Allow setting cpu affinity on other processes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| SYS_RESOURCE&lt;br /&gt;
|&lt;br /&gt;
* Override resource limits. Set resource limits.&lt;br /&gt;
* Override quota limits.&lt;br /&gt;
* Override reserved space on ext2 filesystem&lt;br /&gt;
* Modify data journaling mode on ext3 filesystem (uses journaling resources)&lt;br /&gt;
* ''NOTE:'' ext2 honors fsuid when checking for resource overrides, so you can override using fsuid too&lt;br /&gt;
* Override size restrictions on IPC message queues&lt;br /&gt;
* Allow more than 64hz interrupts from the real-time clock&lt;br /&gt;
* Override max number of consoles on console allocation&lt;br /&gt;
* Override max number of keymaps&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 25&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| SYS_TIME&lt;br /&gt;
|&lt;br /&gt;
* Allow manipulation of system clock&lt;br /&gt;
* Allow irix_stime on mips&lt;br /&gt;
* Allow setting the real-time clock&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 26&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| SYS_TTY_CONFIG&lt;br /&gt;
|&lt;br /&gt;
* Allow configuration of tty devices&lt;br /&gt;
* Allow vhangup() of tty&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 27&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x08000000&lt;br /&gt;
| MKNOD&lt;br /&gt;
| Allow the privileged aspects of mknod()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 28&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x10000000&lt;br /&gt;
| LEASE&lt;br /&gt;
| Allow taking of leases on files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x20000000&lt;br /&gt;
| AUDIT_WRITE&lt;br /&gt;
| ??&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x40000000&lt;br /&gt;
| AUDIT_CONTROL&lt;br /&gt;
| ??&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Setting flags and capabilities ==&lt;br /&gt;
To see how to set the flags and capabilities, see [[util-vserver:Capabilities and Flags]] if you're using util-vserver.&lt;br /&gt;
&lt;br /&gt;
If you would like to edit those flags without restarting the vservers, you can use vattribute and nattribute. See [[util-vserver:Cheatsheet]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Networking_vserver_guests</id>
		<title>Networking vserver guests</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Networking_vserver_guests"/>
				<updated>2010-02-15T14:22:44Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Guests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up network access to and from your vserver guests.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Lets imagine, you have only one external IP -- &amp;lt;code&amp;gt;$EXTIP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You want to have several vservers running without worrying about port overlapping.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Two vservers run a default webserver, running on port 80. If each &amp;quot;guest&amp;quot; vserver shares an IP with the host, then the two webservers will conflict.&lt;br /&gt;
&lt;br /&gt;
One solution is:&lt;br /&gt;
&lt;br /&gt;
* All vservers are contained in a &amp;quot;virtual lan&amp;quot;, say 192.168.1.x&lt;br /&gt;
* Each vserver has its own IP&lt;br /&gt;
* Control port forwarding on &amp;quot;parent&amp;quot; host. That is, run a router.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
===Host===&lt;br /&gt;
&lt;br /&gt;
===Optional: Load 'dummy' device(s)===&lt;br /&gt;
&lt;br /&gt;
====Why?====&lt;br /&gt;
This driver allows you to associate vServer guests with a ''virtual'' network device rather than the host's real network interface, which functions to hide packet counters from vServer guests.  '''There is no other use for this step''', so feel free to skip it if you are not worried about sharing packet counters.  (Packet counts ''may'' be useful to an attacker with control of a vServer guest who wishes to perform side-channel attacks during cryptanalysis, or network traffic analysis against your host or other vServer guests.  If you did not understand the last sentence and your installation is not particularly security sensitive, then the chances that you will encounter a skilled attacker and this will actually matter are slim to none and you should feel free to skip this section.)&lt;br /&gt;
&lt;br /&gt;
====Process====&lt;br /&gt;
First you need to load the dummy interface driver (requires CONFIG_DUMMY=m in your kernel configuration)&lt;br /&gt;
 # modprobe dummy&lt;br /&gt;
&lt;br /&gt;
To have it automatically loaded on startup, add&lt;br /&gt;
&amp;quot;loopback&amp;quot; to /etc/modules&lt;br /&gt;
&lt;br /&gt;
Set up &amp;lt;code&amp;gt;dummy0&amp;lt;/code&amp;gt; interface on the parent host&lt;br /&gt;
 # /etc/network/interfaces on a Debian box, &lt;br /&gt;
 # configure on other distros with your preferred way&lt;br /&gt;
 auto dummy0&lt;br /&gt;
 iface dummy0 inet static&lt;br /&gt;
     address 192.168.1.250&lt;br /&gt;
     netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
====Optional Extra Step====&lt;br /&gt;
It is possible to facilitate further segregation (such that even dummy packet counters are never shared between guests).  To do so, use:&lt;br /&gt;
 # modprobe dummy numdummies=&amp;lt;number-of-devices-required&amp;gt;&lt;br /&gt;
... and associate each vServer with a unique dummy device.&lt;br /&gt;
&lt;br /&gt;
===Guests===&lt;br /&gt;
Set up each guest vserver.  If you skipped the host configuration above, you will need to replace dummy0 with the name of your host's primary network interface, for example eth0.&lt;br /&gt;
&lt;br /&gt;
 cd /etc/vservers/$VSERVER/interfaces/0&lt;br /&gt;
 echo dummy0 &amp;gt; dev&lt;br /&gt;
 echo 192.168.1.1 &amp;gt; ip&lt;br /&gt;
 echo 1 &amp;gt; name&lt;br /&gt;
 echo 24 &amp;gt; prefix&lt;br /&gt;
&lt;br /&gt;
Consider using a value of &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; equal to the last digit of the IP for easy separation.&lt;br /&gt;
&lt;br /&gt;
===Host as router===&lt;br /&gt;
Configure the host to act as a router.&lt;br /&gt;
&lt;br /&gt;
For internal packets going outside, pretend each packet came from our external IP (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A POSTROUTING -s 192.168.1.0/24 \ &lt;br /&gt;
   -d ! 192.168.1.0/24 -j SNAT --to-source $EXTIP&lt;br /&gt;
For each service that runs on a vserver, map it to an external port. Vserver local address &amp;lt;code&amp;gt;$VHOST&amp;lt;/code&amp;gt; and port &amp;lt;code&amp;gt;$INTPORT&amp;lt;/code&amp;gt; you select one external port &amp;lt;code&amp;gt;$EXTPORT&amp;lt;/code&amp;gt; and run the following (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A PREROUTING -s ! 192.168.1.0/24 \&lt;br /&gt;
   -m tcp -p tcp --dport $EXTPORT &lt;br /&gt;
   -j DNAT --to-destination $VHOST:$INTPORT&lt;br /&gt;
That's all!&lt;br /&gt;
&lt;br /&gt;
==Verifying==&lt;br /&gt;
Try &amp;lt;code&amp;gt;ping pool.ntp.org&amp;lt;/code&amp;gt; from your vserver -- it should ping fine.&lt;br /&gt;
&lt;br /&gt;
Try to connect to your &amp;lt;code&amp;gt;$EXTIP:$EXTPORT&amp;lt;/code&amp;gt; (from another external host) -- you will successfully connect to service running on a guest vserver.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Frequently_Asked_Questions#If_my_host_has_only_one_a_single_public_IP.2C_can_I_use_RFC1918_IP_.28e.g._192.168.foo.bar.29_for_the_guest_vservers.3F |FAQ on private networking]]&lt;br /&gt;
* [[Frequently_Asked_Questions#When_I_try_to_ssh_to_the_guest.2C_I_log_into_the_host.2C_even_if_I_installed_sshd_on_the_guest._What.27s_wrong_here.3F |Permit guest sshd to bind to its IP address's port 22]]&lt;br /&gt;
* [[Networking_vserver_guests_RHEL|Networking_vserver_guests_RHEL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;br /&gt;
[[Category:Network]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Networking_vserver_guests</id>
		<title>Networking vserver guests</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Networking_vserver_guests"/>
				<updated>2010-02-15T14:22:06Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Process */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up network access to and from your vserver guests.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Lets imagine, you have only one external IP -- &amp;lt;code&amp;gt;$EXTIP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You want to have several vservers running without worrying about port overlapping.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Two vservers run a default webserver, running on port 80. If each &amp;quot;guest&amp;quot; vserver shares an IP with the host, then the two webservers will conflict.&lt;br /&gt;
&lt;br /&gt;
One solution is:&lt;br /&gt;
&lt;br /&gt;
* All vservers are contained in a &amp;quot;virtual lan&amp;quot;, say 192.168.1.x&lt;br /&gt;
* Each vserver has its own IP&lt;br /&gt;
* Control port forwarding on &amp;quot;parent&amp;quot; host. That is, run a router.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
===Host===&lt;br /&gt;
&lt;br /&gt;
===Optional: Load 'dummy' device(s)===&lt;br /&gt;
&lt;br /&gt;
====Why?====&lt;br /&gt;
This driver allows you to associate vServer guests with a ''virtual'' network device rather than the host's real network interface, which functions to hide packet counters from vServer guests.  '''There is no other use for this step''', so feel free to skip it if you are not worried about sharing packet counters.  (Packet counts ''may'' be useful to an attacker with control of a vServer guest who wishes to perform side-channel attacks during cryptanalysis, or network traffic analysis against your host or other vServer guests.  If you did not understand the last sentence and your installation is not particularly security sensitive, then the chances that you will encounter a skilled attacker and this will actually matter are slim to none and you should feel free to skip this section.)&lt;br /&gt;
&lt;br /&gt;
====Process====&lt;br /&gt;
First you need to load the dummy interface driver (requires CONFIG_DUMMY=m in your kernel configuration)&lt;br /&gt;
 # modprobe dummy&lt;br /&gt;
&lt;br /&gt;
To have it automatically loaded on startup, add&lt;br /&gt;
&amp;quot;loopback&amp;quot; to /etc/modules&lt;br /&gt;
&lt;br /&gt;
Set up &amp;lt;code&amp;gt;dummy0&amp;lt;/code&amp;gt; interface on the parent host&lt;br /&gt;
 # /etc/network/interfaces on a Debian box, &lt;br /&gt;
 # configure on other distros with your preferred way&lt;br /&gt;
 auto dummy0&lt;br /&gt;
 iface dummy0 inet static&lt;br /&gt;
     address 192.168.1.250&lt;br /&gt;
     netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
====Optional Extra Step====&lt;br /&gt;
It is possible to facilitate further segregation (such that even dummy packet counters are never shared between guests).  To do so, use:&lt;br /&gt;
 # modprobe dummy numdummies=&amp;lt;number-of-devices-required&amp;gt;&lt;br /&gt;
... and associate each vServer with a unique dummy device.&lt;br /&gt;
&lt;br /&gt;
===Guests===&lt;br /&gt;
Set up each guest vserver.  If you skipped the above step, replace dummy0 with the name of your host's primary network interface, for example eth0.&lt;br /&gt;
&lt;br /&gt;
 cd /etc/vservers/$VSERVER/interfaces/0&lt;br /&gt;
 echo dummy0 &amp;gt; dev&lt;br /&gt;
 echo 192.168.1.1 &amp;gt; ip&lt;br /&gt;
 echo 1 &amp;gt; name&lt;br /&gt;
 echo 24 &amp;gt; prefix&lt;br /&gt;
&lt;br /&gt;
Consider using a value of &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; equal to the last digit of the IP for easy separation.&lt;br /&gt;
&lt;br /&gt;
===Host as router===&lt;br /&gt;
Configure the host to act as a router.&lt;br /&gt;
&lt;br /&gt;
For internal packets going outside, pretend each packet came from our external IP (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A POSTROUTING -s 192.168.1.0/24 \ &lt;br /&gt;
   -d ! 192.168.1.0/24 -j SNAT --to-source $EXTIP&lt;br /&gt;
For each service that runs on a vserver, map it to an external port. Vserver local address &amp;lt;code&amp;gt;$VHOST&amp;lt;/code&amp;gt; and port &amp;lt;code&amp;gt;$INTPORT&amp;lt;/code&amp;gt; you select one external port &amp;lt;code&amp;gt;$EXTPORT&amp;lt;/code&amp;gt; and run the following (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A PREROUTING -s ! 192.168.1.0/24 \&lt;br /&gt;
   -m tcp -p tcp --dport $EXTPORT &lt;br /&gt;
   -j DNAT --to-destination $VHOST:$INTPORT&lt;br /&gt;
That's all!&lt;br /&gt;
&lt;br /&gt;
==Verifying==&lt;br /&gt;
Try &amp;lt;code&amp;gt;ping pool.ntp.org&amp;lt;/code&amp;gt; from your vserver -- it should ping fine.&lt;br /&gt;
&lt;br /&gt;
Try to connect to your &amp;lt;code&amp;gt;$EXTIP:$EXTPORT&amp;lt;/code&amp;gt; (from another external host) -- you will successfully connect to service running on a guest vserver.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Frequently_Asked_Questions#If_my_host_has_only_one_a_single_public_IP.2C_can_I_use_RFC1918_IP_.28e.g._192.168.foo.bar.29_for_the_guest_vservers.3F |FAQ on private networking]]&lt;br /&gt;
* [[Frequently_Asked_Questions#When_I_try_to_ssh_to_the_guest.2C_I_log_into_the_host.2C_even_if_I_installed_sshd_on_the_guest._What.27s_wrong_here.3F |Permit guest sshd to bind to its IP address's port 22]]&lt;br /&gt;
* [[Networking_vserver_guests_RHEL|Networking_vserver_guests_RHEL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;br /&gt;
[[Category:Network]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Networking_vserver_guests</id>
		<title>Networking vserver guests</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Networking_vserver_guests"/>
				<updated>2010-02-15T14:16:38Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up network access to and from your vserver guests.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Lets imagine, you have only one external IP -- &amp;lt;code&amp;gt;$EXTIP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You want to have several vservers running without worrying about port overlapping.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Two vservers run a default webserver, running on port 80. If each &amp;quot;guest&amp;quot; vserver shares an IP with the host, then the two webservers will conflict.&lt;br /&gt;
&lt;br /&gt;
One solution is:&lt;br /&gt;
&lt;br /&gt;
* All vservers are contained in a &amp;quot;virtual lan&amp;quot;, say 192.168.1.x&lt;br /&gt;
* Each vserver has its own IP&lt;br /&gt;
* Control port forwarding on &amp;quot;parent&amp;quot; host. That is, run a router.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
===Host===&lt;br /&gt;
&lt;br /&gt;
===Optional: Load 'dummy' device(s)===&lt;br /&gt;
&lt;br /&gt;
====Why?====&lt;br /&gt;
This driver allows you to associate vServer guests with a ''virtual'' network device rather than the host's real network interface, which functions to hide packet counters from vServer guests.  '''There is no other use for this step''', so feel free to skip it if you are not worried about sharing packet counters.  (Packet counts ''may'' be useful to an attacker with control of a vServer guest who wishes to perform side-channel attacks during cryptanalysis, or network traffic analysis against your host or other vServer guests.  If you did not understand the last sentence and your installation is not particularly security sensitive, then the chances that you will encounter a skilled attacker and this will actually matter are slim to none and you should feel free to skip this section.)&lt;br /&gt;
&lt;br /&gt;
====Process====&lt;br /&gt;
First you need to load the dummy interface driver (requires CONFIG_DUMMY=m in your kernel configuration)&lt;br /&gt;
 # modprobe dummy&lt;br /&gt;
&lt;br /&gt;
To have it automatically loaded on startup, add&lt;br /&gt;
&amp;quot;loopback&amp;quot; to /etc/modules&lt;br /&gt;
&lt;br /&gt;
Set up &amp;lt;code&amp;gt;dummy0&amp;lt;/code&amp;gt; interface on the parent host&lt;br /&gt;
 # /etc/network/interfaces on a Debian box, &lt;br /&gt;
 # configure on other distros with your preferred way&lt;br /&gt;
 auto dummy0&lt;br /&gt;
 iface dummy0 inet static&lt;br /&gt;
     address 192.168.1.250&lt;br /&gt;
     netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
===Guests===&lt;br /&gt;
Set up each guest vserver.  If you skipped the above step, replace dummy0 with the name of your host's primary network interface, for example eth0.&lt;br /&gt;
&lt;br /&gt;
 cd /etc/vservers/$VSERVER/interfaces/0&lt;br /&gt;
 echo dummy0 &amp;gt; dev&lt;br /&gt;
 echo 192.168.1.1 &amp;gt; ip&lt;br /&gt;
 echo 1 &amp;gt; name&lt;br /&gt;
 echo 24 &amp;gt; prefix&lt;br /&gt;
&lt;br /&gt;
Consider using a value of &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; equal to the last digit of the IP for easy separation.&lt;br /&gt;
&lt;br /&gt;
===Host as router===&lt;br /&gt;
Configure the host to act as a router.&lt;br /&gt;
&lt;br /&gt;
For internal packets going outside, pretend each packet came from our external IP (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A POSTROUTING -s 192.168.1.0/24 \ &lt;br /&gt;
   -d ! 192.168.1.0/24 -j SNAT --to-source $EXTIP&lt;br /&gt;
For each service that runs on a vserver, map it to an external port. Vserver local address &amp;lt;code&amp;gt;$VHOST&amp;lt;/code&amp;gt; and port &amp;lt;code&amp;gt;$INTPORT&amp;lt;/code&amp;gt; you select one external port &amp;lt;code&amp;gt;$EXTPORT&amp;lt;/code&amp;gt; and run the following (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A PREROUTING -s ! 192.168.1.0/24 \&lt;br /&gt;
   -m tcp -p tcp --dport $EXTPORT &lt;br /&gt;
   -j DNAT --to-destination $VHOST:$INTPORT&lt;br /&gt;
That's all!&lt;br /&gt;
&lt;br /&gt;
==Verifying==&lt;br /&gt;
Try &amp;lt;code&amp;gt;ping pool.ntp.org&amp;lt;/code&amp;gt; from your vserver -- it should ping fine.&lt;br /&gt;
&lt;br /&gt;
Try to connect to your &amp;lt;code&amp;gt;$EXTIP:$EXTPORT&amp;lt;/code&amp;gt; (from another external host) -- you will successfully connect to service running on a guest vserver.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Frequently_Asked_Questions#If_my_host_has_only_one_a_single_public_IP.2C_can_I_use_RFC1918_IP_.28e.g._192.168.foo.bar.29_for_the_guest_vservers.3F |FAQ on private networking]]&lt;br /&gt;
* [[Frequently_Asked_Questions#When_I_try_to_ssh_to_the_guest.2C_I_log_into_the_host.2C_even_if_I_installed_sshd_on_the_guest._What.27s_wrong_here.3F |Permit guest sshd to bind to its IP address's port 22]]&lt;br /&gt;
* [[Networking_vserver_guests_RHEL|Networking_vserver_guests_RHEL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;br /&gt;
[[Category:Network]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Networking_vserver_guests</id>
		<title>Networking vserver guests</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Networking_vserver_guests"/>
				<updated>2010-02-15T13:55:52Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Guests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up network access to and from your vserver guests.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Lets imagine, you have only one external IP -- &amp;lt;code&amp;gt;$EXTIP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You want to have several vservers running without worrying about port overlapping.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Two vservers run a default webserver, running on port 80. If each &amp;quot;guest&amp;quot; vserver shares an IP with the host, then the two webservers will conflict.&lt;br /&gt;
&lt;br /&gt;
One solution is:&lt;br /&gt;
&lt;br /&gt;
* All vservers are contained in a &amp;quot;virtual lan&amp;quot;, say 192.168.1.x&lt;br /&gt;
* Each vserver has its own IP&lt;br /&gt;
* Control port forwarding on &amp;quot;parent&amp;quot; host. That is, run a router.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
===Host===&lt;br /&gt;
&lt;br /&gt;
===Optional: Load 'dummy' device(s)===&lt;br /&gt;
&lt;br /&gt;
====Why?====&lt;br /&gt;
This driver allows you to associate vServer guests with a ''virtual'' network device rather than the host's real network interface, which functions to hide packet counters from vServer guests.  There is no other use for this step, so feel free to skip it if you are not worried about sharing packet counters.  Packet counts ''may'' be useful to an attacker with control of a vServer guest who wishes to perform side-channel attacks during cryptanalysis, or network traffic analysis against your host or other vServer guests.  If you did not understand the last sentence and your installation is not particularly security sensitive, then the chances that you will encounter a skilled attacker are slim to none and you should feel free to skip this section.&lt;br /&gt;
&lt;br /&gt;
====Process====&lt;br /&gt;
First you need to load the dummy interface driver&lt;br /&gt;
 # modprobe dummy&lt;br /&gt;
&lt;br /&gt;
To have it automatically loaded on startup, add&lt;br /&gt;
&amp;quot;loopback&amp;quot; to /etc/modules&lt;br /&gt;
&lt;br /&gt;
Set up &amp;lt;code&amp;gt;dummy0&amp;lt;/code&amp;gt; interface on the parent host&lt;br /&gt;
 # /etc/network/interfaces on a Debian box, &lt;br /&gt;
 # configure on other distros with your preferred way&lt;br /&gt;
 auto dummy0&lt;br /&gt;
 iface dummy0 inet static&lt;br /&gt;
     address 192.168.1.250&lt;br /&gt;
     netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
===Guests===&lt;br /&gt;
Set up each guest vserver.  If you skipped the above step, replace dummy0 with the name of your host's primary network interface, for example eth0.&lt;br /&gt;
&lt;br /&gt;
 cd /etc/vservers/$VSERVER/interfaces/0&lt;br /&gt;
 echo dummy0 &amp;gt; dev&lt;br /&gt;
 echo 192.168.1.1 &amp;gt; ip&lt;br /&gt;
 echo 1 &amp;gt; name&lt;br /&gt;
 echo 24 &amp;gt; prefix&lt;br /&gt;
&lt;br /&gt;
Consider using a value of &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; equal to the last digit of the IP for easy separation.&lt;br /&gt;
&lt;br /&gt;
===Host as router===&lt;br /&gt;
Configure the host to act as a router.&lt;br /&gt;
&lt;br /&gt;
For internal packets going outside, pretend each packet came from our external IP (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A POSTROUTING -s 192.168.1.0/24 \ &lt;br /&gt;
   -d ! 192.168.1.0/24 -j SNAT --to-source $EXTIP&lt;br /&gt;
For each service that runs on a vserver, map it to an external port. Vserver local address &amp;lt;code&amp;gt;$VHOST&amp;lt;/code&amp;gt; and port &amp;lt;code&amp;gt;$INTPORT&amp;lt;/code&amp;gt; you select one external port &amp;lt;code&amp;gt;$EXTPORT&amp;lt;/code&amp;gt; and run the following (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A PREROUTING -s ! 192.168.1.0/24 \&lt;br /&gt;
   -m tcp -p tcp --dport $EXTPORT &lt;br /&gt;
   -j DNAT --to-destination $VHOST:$INTPORT&lt;br /&gt;
That's all!&lt;br /&gt;
&lt;br /&gt;
==Verifying==&lt;br /&gt;
Try &amp;lt;code&amp;gt;ping pool.ntp.org&amp;lt;/code&amp;gt; from your vserver -- it should ping fine.&lt;br /&gt;
&lt;br /&gt;
Try to connect to your &amp;lt;code&amp;gt;$EXTIP:$EXTPORT&amp;lt;/code&amp;gt; (from another external host) -- you will successfully connect to service running on a guest vserver.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Frequently_Asked_Questions#If_my_host_has_only_one_a_single_public_IP.2C_can_I_use_RFC1918_IP_.28e.g._192.168.foo.bar.29_for_the_guest_vservers.3F |FAQ on private networking]]&lt;br /&gt;
* [[Frequently_Asked_Questions#When_I_try_to_ssh_to_the_guest.2C_I_log_into_the_host.2C_even_if_I_installed_sshd_on_the_guest._What.27s_wrong_here.3F |Permit guest sshd to bind to its IP address's port 22]]&lt;br /&gt;
* [[Networking_vserver_guests_RHEL|Networking_vserver_guests_RHEL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;br /&gt;
[[Category:Network]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Networking_vserver_guests</id>
		<title>Networking vserver guests</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Networking_vserver_guests"/>
				<updated>2010-02-15T13:55:45Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Guests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up network access to and from your vserver guests.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Lets imagine, you have only one external IP -- &amp;lt;code&amp;gt;$EXTIP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You want to have several vservers running without worrying about port overlapping.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Two vservers run a default webserver, running on port 80. If each &amp;quot;guest&amp;quot; vserver shares an IP with the host, then the two webservers will conflict.&lt;br /&gt;
&lt;br /&gt;
One solution is:&lt;br /&gt;
&lt;br /&gt;
* All vservers are contained in a &amp;quot;virtual lan&amp;quot;, say 192.168.1.x&lt;br /&gt;
* Each vserver has its own IP&lt;br /&gt;
* Control port forwarding on &amp;quot;parent&amp;quot; host. That is, run a router.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
===Host===&lt;br /&gt;
&lt;br /&gt;
===Optional: Load 'dummy' device(s)===&lt;br /&gt;
&lt;br /&gt;
====Why?====&lt;br /&gt;
This driver allows you to associate vServer guests with a ''virtual'' network device rather than the host's real network interface, which functions to hide packet counters from vServer guests.  There is no other use for this step, so feel free to skip it if you are not worried about sharing packet counters.  Packet counts ''may'' be useful to an attacker with control of a vServer guest who wishes to perform side-channel attacks during cryptanalysis, or network traffic analysis against your host or other vServer guests.  If you did not understand the last sentence and your installation is not particularly security sensitive, then the chances that you will encounter a skilled attacker are slim to none and you should feel free to skip this section.&lt;br /&gt;
&lt;br /&gt;
====Process====&lt;br /&gt;
First you need to load the dummy interface driver&lt;br /&gt;
 # modprobe dummy&lt;br /&gt;
&lt;br /&gt;
To have it automatically loaded on startup, add&lt;br /&gt;
&amp;quot;loopback&amp;quot; to /etc/modules&lt;br /&gt;
&lt;br /&gt;
Set up &amp;lt;code&amp;gt;dummy0&amp;lt;/code&amp;gt; interface on the parent host&lt;br /&gt;
 # /etc/network/interfaces on a Debian box, &lt;br /&gt;
 # configure on other distros with your preferred way&lt;br /&gt;
 auto dummy0&lt;br /&gt;
 iface dummy0 inet static&lt;br /&gt;
     address 192.168.1.250&lt;br /&gt;
     netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
===Guests===&lt;br /&gt;
Set up each guest vserver.  If you skipped the above step, replace dummy0 with the name of your host's primary network interface.&lt;br /&gt;
&lt;br /&gt;
 cd /etc/vservers/$VSERVER/interfaces/0&lt;br /&gt;
 echo dummy0 &amp;gt; dev&lt;br /&gt;
 echo 192.168.1.1 &amp;gt; ip&lt;br /&gt;
 echo 1 &amp;gt; name&lt;br /&gt;
 echo 24 &amp;gt; prefix&lt;br /&gt;
&lt;br /&gt;
Consider using a value of &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; equal to the last digit of the IP for easy separation.&lt;br /&gt;
&lt;br /&gt;
===Host as router===&lt;br /&gt;
Configure the host to act as a router.&lt;br /&gt;
&lt;br /&gt;
For internal packets going outside, pretend each packet came from our external IP (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A POSTROUTING -s 192.168.1.0/24 \ &lt;br /&gt;
   -d ! 192.168.1.0/24 -j SNAT --to-source $EXTIP&lt;br /&gt;
For each service that runs on a vserver, map it to an external port. Vserver local address &amp;lt;code&amp;gt;$VHOST&amp;lt;/code&amp;gt; and port &amp;lt;code&amp;gt;$INTPORT&amp;lt;/code&amp;gt; you select one external port &amp;lt;code&amp;gt;$EXTPORT&amp;lt;/code&amp;gt; and run the following (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A PREROUTING -s ! 192.168.1.0/24 \&lt;br /&gt;
   -m tcp -p tcp --dport $EXTPORT &lt;br /&gt;
   -j DNAT --to-destination $VHOST:$INTPORT&lt;br /&gt;
That's all!&lt;br /&gt;
&lt;br /&gt;
==Verifying==&lt;br /&gt;
Try &amp;lt;code&amp;gt;ping pool.ntp.org&amp;lt;/code&amp;gt; from your vserver -- it should ping fine.&lt;br /&gt;
&lt;br /&gt;
Try to connect to your &amp;lt;code&amp;gt;$EXTIP:$EXTPORT&amp;lt;/code&amp;gt; (from another external host) -- you will successfully connect to service running on a guest vserver.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Frequently_Asked_Questions#If_my_host_has_only_one_a_single_public_IP.2C_can_I_use_RFC1918_IP_.28e.g._192.168.foo.bar.29_for_the_guest_vservers.3F |FAQ on private networking]]&lt;br /&gt;
* [[Frequently_Asked_Questions#When_I_try_to_ssh_to_the_guest.2C_I_log_into_the_host.2C_even_if_I_installed_sshd_on_the_guest._What.27s_wrong_here.3F |Permit guest sshd to bind to its IP address's port 22]]&lt;br /&gt;
* [[Networking_vserver_guests_RHEL|Networking_vserver_guests_RHEL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;br /&gt;
[[Category:Network]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Networking_vserver_guests</id>
		<title>Networking vserver guests</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Networking_vserver_guests"/>
				<updated>2010-02-15T13:55:35Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Guests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up network access to and from your vserver guests.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Lets imagine, you have only one external IP -- &amp;lt;code&amp;gt;$EXTIP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You want to have several vservers running without worrying about port overlapping.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Two vservers run a default webserver, running on port 80. If each &amp;quot;guest&amp;quot; vserver shares an IP with the host, then the two webservers will conflict.&lt;br /&gt;
&lt;br /&gt;
One solution is:&lt;br /&gt;
&lt;br /&gt;
* All vservers are contained in a &amp;quot;virtual lan&amp;quot;, say 192.168.1.x&lt;br /&gt;
* Each vserver has its own IP&lt;br /&gt;
* Control port forwarding on &amp;quot;parent&amp;quot; host. That is, run a router.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
===Host===&lt;br /&gt;
&lt;br /&gt;
===Optional: Load 'dummy' device(s)===&lt;br /&gt;
&lt;br /&gt;
====Why?====&lt;br /&gt;
This driver allows you to associate vServer guests with a ''virtual'' network device rather than the host's real network interface, which functions to hide packet counters from vServer guests.  There is no other use for this step, so feel free to skip it if you are not worried about sharing packet counters.  Packet counts ''may'' be useful to an attacker with control of a vServer guest who wishes to perform side-channel attacks during cryptanalysis, or network traffic analysis against your host or other vServer guests.  If you did not understand the last sentence and your installation is not particularly security sensitive, then the chances that you will encounter a skilled attacker are slim to none and you should feel free to skip this section.&lt;br /&gt;
&lt;br /&gt;
====Process====&lt;br /&gt;
First you need to load the dummy interface driver&lt;br /&gt;
 # modprobe dummy&lt;br /&gt;
&lt;br /&gt;
To have it automatically loaded on startup, add&lt;br /&gt;
&amp;quot;loopback&amp;quot; to /etc/modules&lt;br /&gt;
&lt;br /&gt;
Set up &amp;lt;code&amp;gt;dummy0&amp;lt;/code&amp;gt; interface on the parent host&lt;br /&gt;
 # /etc/network/interfaces on a Debian box, &lt;br /&gt;
 # configure on other distros with your preferred way&lt;br /&gt;
 auto dummy0&lt;br /&gt;
 iface dummy0 inet static&lt;br /&gt;
     address 192.168.1.250&lt;br /&gt;
     netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
===Guests===&lt;br /&gt;
Set up each guest vserver.  If you skipped the above step, replace dumm0 with the name of your host's primary network interface.&lt;br /&gt;
&lt;br /&gt;
 cd /etc/vservers/$VSERVER/interfaces/0&lt;br /&gt;
 echo dummy0 &amp;gt; dev&lt;br /&gt;
 echo 192.168.1.1 &amp;gt; ip&lt;br /&gt;
 echo 1 &amp;gt; name&lt;br /&gt;
 echo 24 &amp;gt; prefix&lt;br /&gt;
&lt;br /&gt;
Consider using a value of &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; equal to the last digit of the IP for easy separation.&lt;br /&gt;
&lt;br /&gt;
===Host as router===&lt;br /&gt;
Configure the host to act as a router.&lt;br /&gt;
&lt;br /&gt;
For internal packets going outside, pretend each packet came from our external IP (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A POSTROUTING -s 192.168.1.0/24 \ &lt;br /&gt;
   -d ! 192.168.1.0/24 -j SNAT --to-source $EXTIP&lt;br /&gt;
For each service that runs on a vserver, map it to an external port. Vserver local address &amp;lt;code&amp;gt;$VHOST&amp;lt;/code&amp;gt; and port &amp;lt;code&amp;gt;$INTPORT&amp;lt;/code&amp;gt; you select one external port &amp;lt;code&amp;gt;$EXTPORT&amp;lt;/code&amp;gt; and run the following (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A PREROUTING -s ! 192.168.1.0/24 \&lt;br /&gt;
   -m tcp -p tcp --dport $EXTPORT &lt;br /&gt;
   -j DNAT --to-destination $VHOST:$INTPORT&lt;br /&gt;
That's all!&lt;br /&gt;
&lt;br /&gt;
==Verifying==&lt;br /&gt;
Try &amp;lt;code&amp;gt;ping pool.ntp.org&amp;lt;/code&amp;gt; from your vserver -- it should ping fine.&lt;br /&gt;
&lt;br /&gt;
Try to connect to your &amp;lt;code&amp;gt;$EXTIP:$EXTPORT&amp;lt;/code&amp;gt; (from another external host) -- you will successfully connect to service running on a guest vserver.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Frequently_Asked_Questions#If_my_host_has_only_one_a_single_public_IP.2C_can_I_use_RFC1918_IP_.28e.g._192.168.foo.bar.29_for_the_guest_vservers.3F |FAQ on private networking]]&lt;br /&gt;
* [[Frequently_Asked_Questions#When_I_try_to_ssh_to_the_guest.2C_I_log_into_the_host.2C_even_if_I_installed_sshd_on_the_guest._What.27s_wrong_here.3F |Permit guest sshd to bind to its IP address's port 22]]&lt;br /&gt;
* [[Networking_vserver_guests_RHEL|Networking_vserver_guests_RHEL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;br /&gt;
[[Category:Network]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Frequently_Asked_Questions</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Frequently_Asked_Questions"/>
				<updated>2010-02-15T13:54:10Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: add pointer to http://linux-vserver.org/Networking_vserver_guests for packet counter hide&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;margin: 2em auto 2em auto; padding: 10px; background-color: #F9ECCD; border: 1px solid #004433; text-align: center;&amp;quot;&amp;gt;&lt;br /&gt;
[[Image:Icon-Caution.png|left]]&lt;br /&gt;
We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the [[Wiki Team]] page for instructions how to help or look at the [http://oldwiki.linux-vserver.org old wiki] to find the information not migrated yet.&lt;br /&gt;
&lt;br /&gt;
'''To ease migration we created a [[List of old Documentation pages]].'''&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
CURRENTLY THE CONTENT OF THE OLD WIKI FAQ (AND MORE) IS BEING MIGRATED TO THIS PAGE (TASK: DERJOHN)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is a 'Guest'?&lt;br /&gt;
||Details=To talk about stuff, we need some naming. The physical machine is called 'Host' and the 'main' context running the Host Distro is called 'Host Context'. The virtual machine/distro is called 'Guest' and basically is a Distribution (Userspace) running inside a 'Guest Context'.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What kind of Operating System (OS) can I run as guest?&lt;br /&gt;
||Details= With VServer you can only run Linux guests. The trick is that a guest does not run a kernel on its own (as XEN and UML do), it merely uses a virtualized host kernel-interface. VServer offers so called security contexts which make it possible to separate one guest from each other, i.e. they cannot get data from each other. Imagine it as a chroot environment with much more security and features.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is this a new project? When was it started?&lt;br /&gt;
||Details=The first public occurrence of Linux-VServer was Oct 2001. The initial mail can be found here: http://www.cs.helsinki.fi/linux/linux-kernel/2001-40/1065.html&lt;br /&gt;
So you can expect a mature software product which does its magic quite well (And hey, we have a version &amp;gt; 2.0!)&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Which distributions did you test?&lt;br /&gt;
||Details=Some. Check out the wiki for ready-made guest images. But you can easily build own guest images, e.g. with Debian's debootstrap. Checkout [[Building Guest Systems]] how to do that.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is VServer comparable to XEN/UML/QEMU?&lt;br /&gt;
||Details=Nope. XEN/UML/QEMU and VServer are just good friends. Because you ask, you probably know what XEN/UML/QEMU are. VServer in contrary to XEN/UML/QEMU does not &amp;quot;emulate&amp;quot; any hardware you run a kernel on. The purpose of Linux VServer is to isolate (groups of) applications.  The isolation is done by the kernel (see [[Overview]] for a more detailed comparison). You can run a VServer kernel in a XEN/UML/QEMU guest. This is confirmed to work at least with Linux 2.6/vs2.0.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=With which version should I begin?&lt;br /&gt;
||Details=If you are new to VServer I recommend to try the latest stable kernel patch, and the latest util-vserver &amp;quot;alpha&amp;quot; release.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is VServer secure?&lt;br /&gt;
||Details=We hope so. It should be as least as secure as Linux is. We consider it much much more secure though.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Performance?&lt;br /&gt;
||Details=For a single guest, we basically have native performance. Some tests showed insignificant overhead (about 1-2%) others ran faster than on an unpatched kernel. This is IMVHO significantly less than other solutions waste, especially if you have more than a single guest (because of the resource sharing).&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is the &amp;quot;great flower page&amp;quot;?&lt;br /&gt;
||Details=Well, [http://www.nongnu.org/util-vserver/doc/conf/configuration.html this page] contains all configuration options for util-vserver. The name of the page is derived from the stylesheet(s) it contains.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Resources usage ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Resource sharing?&lt;br /&gt;
||Details=Yes ....&lt;br /&gt;
* memory: Dynamically.&lt;br /&gt;
* CPU usage: Dynamically (token bucket)&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Resource limiting?&lt;br /&gt;
||Details=You can put limits per guest on different subsystems.&lt;br /&gt;
* using ulimits and rlimits (rlimit is a new feature of kernel 2.6/vs2.0.) per guest, to limit the memory consumption, the number of processes or file-handles, ... : see [[Resource Limits]]&lt;br /&gt;
* CPU usage : see [[CPU Scheduler]]&lt;br /&gt;
* disk space usage : see [[Disk Limits and Quota]]&lt;br /&gt;
Note that you can only offer guaranteed resource availability with some ticks at the time.&lt;br /&gt;
|Signature=derjohn&amp;amp;xm}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I limit a guests RAM? I want to prevent OOM situations on the host!&lt;br /&gt;
||Details=First you can read [http://linux-vserver.org/Memory+Allocation] and [[Memory Limits]].&lt;br /&gt;
If you want a recipe, do this:&lt;br /&gt;
# Check the size of memory pages. On x86 and x86_64 is usually 4 KB per page.&lt;br /&gt;
# Create /etc/vserver/&amp;lt;guest&amp;gt;/rlimits/&lt;br /&gt;
# Check your physical memory size on the host, e.g. with &amp;quot;free -m&amp;quot;. maxram = kilobytes/pagesize.&lt;br /&gt;
# Limit the guests physical RAM to value smaller then maxram:&amp;lt;pre&amp;gt;echo %%insertYourPagesHereSmallerThanMaxram%% &amp;gt; /etc/vserver/&amp;lt;guest&amp;gt;/rlimits/rss &amp;lt;/pre&amp;gt;&lt;br /&gt;
# Check your swapspace, e.g. with 'swapon -s'. maxswap = swapkilobytes/pagesize.&lt;br /&gt;
# Limit the guest's maximum number of as pages to a value smaller than (maxram+maxswap): &amp;lt;pre&amp;gt; echo %%desiredvalue%% &amp;gt; /etc/vserver/&amp;lt;guest&amp;gt;/rlimits/as &amp;lt;/pre&amp;gt;&lt;br /&gt;
# Correctly display the memory information inside the guest:&amp;lt;pre&amp;gt;echo &amp;quot;VIRT_MEM&amp;quot; &amp;gt;&amp;gt; /etc/vservers/&amp;lt;guest&amp;gt;/flags&amp;lt;/pre&amp;gt;&lt;br /&gt;
It should be clear this can still lead to OOM situations. Example: You have two guests and your as limit per guest is greater than 50% of (maxram+maxswap). If both guests request their maximum at the same point in time, there will be not enough mem .....&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Disk I/O limiting? Is that possible?&lt;br /&gt;
||Details=Well, since vs2.1.1 Linux-VServer supports a mechanism called 'I/O scheduling', which appeared in the 2.6 mainline some time ago. The mainline kernel offers several I/O schedulers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat /sys/block/hdc/queue/scheduler&lt;br /&gt;
noop [anticipatory] deadline cfq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default is anticipatory a.k.a. &amp;quot;AS&amp;quot;. When running several guests on a host you probably want the I/O performance shared in a fair way among the different guests. The kernel comes with a &amp;quot;completely fair queueing&amp;quot; scheduler, CFQ, which can do that. (More on schedulers can be found at http://lwn.net/Articles/114770/)&lt;br /&gt;
This is how to set the scheduler to &amp;quot;cfq&amp;quot; manually:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root# echo &amp;quot;cfq&amp;quot; &amp;gt; /sys/block/hdc/queue/scheduler&lt;br /&gt;
root# cat /sys/block/hdc/queue/scheduler&lt;br /&gt;
noop anticipatory deadline [cfq]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Keep in mind that you have to do it on all physical discs. So if you run an md-softraid, do it to all physical /dev/hdXYZ discs!&lt;br /&gt;
If you run Debian there is a predefined way to set the /sys values at boot-time:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apt-get install sysfsutils&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
# grep cfq /etc/sysfs.conf&lt;br /&gt;
block/sda/queue/scheduler = cfq&lt;br /&gt;
block/sdc/queue/scheduler = cfq&lt;br /&gt;
&lt;br /&gt;
# /etc/init.d/sysfsutils restart&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For non-vserver processes and CFQ you can set by which key the kernel decides about the fairness:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /sys/block/hdc/queue/iosched/key_type&lt;br /&gt;
pgid [tgid] uid gid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Hint: The 'key_type'-feature has been removed in the mainline kernel recently. Don't look for it any longer :(&lt;br /&gt;
&lt;br /&gt;
The default is tgid, which means to share fairly among process groups. Think every guest is treated like a own process group. It's not possible to set a scheduler strategy within a guest. All processes belonging to the same guest are treated like &amp;quot;noop&amp;quot; within the guest. So: If you run apache and some ftp-server within the _same_ guest, there is no fair scheduling between them, but there is fair scheduling between the whole guest and all other guests.&lt;br /&gt;
&lt;br /&gt;
And: It's possible to tune the scheduler parameters in several ways. Have a look at /sys/block/hdc/queue/....&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Nice disk I/O scheduling, is that possible?&lt;br /&gt;
||Details=Well, since linux 2.6.13 processess have another priority next to the cpu nice scheduling hint, it's called io nice.&lt;br /&gt;
It's split into three groups, called real-time, best effort and idle. The default is best-effort, but within best-effort, you can have a niceness from 0 to and including 7.&lt;br /&gt;
You can set this niceness by the tool ionice, which for debian is either in the package util-linux or schedutils.&lt;br /&gt;
To change the io-niceness you need the &amp;lt;tt&amp;gt;CAP_SYS_NICE&amp;lt;/tt&amp;gt;, '''and''' need to have the same uid as the processe you want to ionice.&lt;br /&gt;
&lt;br /&gt;
:'''Note:''' If you want to use any schedulung other than best-effort you will also need the &amp;lt;tt&amp;gt;CAP_SYS_ADMIN&amp;lt;/tt&amp;gt;-flag. Be warned that this gives quite some capabilities to the vserver, not just for I/O scheduling!&lt;br /&gt;
&lt;br /&gt;
If you want to increase the niceness of an I/O hogging process within a vserver you need to do:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
chcontext --xid sponlp1 sudo -u '#2089' ionice -c2 -n5 -p24409&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
with sudo and ionice installed on the root server to increase the *nice*ness of pid 24409, with uid 2089&lt;br /&gt;
|Signature=Groteblup}}&lt;br /&gt;
&lt;br /&gt;
== Unification ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is unification (vunify)?&lt;br /&gt;
||Details=Unification is Hard Links on Steroids. Guests can 'share' common files (usually binaries and libraries) in a secure way, by creating hard links with special properties (immutable but unlinkable (removable)). The tool to identify common files and to unify them is called vunify.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is vhashify?&lt;br /&gt;
||Details=The successor of vunify, a tool which does unification based on hash values (which allows to find common files in arbitrary paths.)&lt;br /&gt;
It creates hardlinks to files named after a hash of the content of the file. If you have a recent version of the vserver patch (2.2+), with CONFIG_VSERVER_COWBL enabled, you can even modify the hardlinked files inside the vservers and the links will be broken automatically.&lt;br /&gt;
There seems to be a catch when a hashified file has multiple hardlinks inside a guest, or when another internal hardlink is added after hashification. Link breaking will remove all the internal hardlinks too, so the guest will end up with different copies of the original file. The correct solution would be to not hashify files that have multiple links prior to hashification, and to break the link to the hashified version when a new internal hardlink is created. Apparently, this is not implemented yet (?).&lt;br /&gt;
|Signature=Guy-}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I manage a multi-guest setup with vhashify?&lt;br /&gt;
||Details=For 'vhashify', just do these once:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/apps/vunify/hash /vservers/.hash&lt;br /&gt;
ln -s /vservers/.hash /etc/vservers/.defaults/apps/vunify/hash/root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, do this one line per vserver:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;vservername&amp;gt;/apps/vunify   # vhashify reuses vunify configuration&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To hashify a running vserver, do (possibly from a cronjob):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver name-of-guest hashify&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The guest needs to be running because vhashify tries to figure out what files not to hashify by calling the package manager of the guest via &amp;lt;tt&amp;gt;vserver enter&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order for the OS cache to benefit from the hardlinking, you'll have to restart the vservers.&lt;br /&gt;
&lt;br /&gt;
To clean up hashified files that are no longer referenced by any vserver, do (possibly from a cronjob):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
find /vservers/.hash -type f -links 1 -print0 | xargs -0 rm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Until you do this, the files still take up place even though no vservers need them.&lt;br /&gt;
|Signature=Guy-}}&lt;br /&gt;
&lt;br /&gt;
== Filesystem usage ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is there a way to implement &amp;quot;user/group quota&amp;quot; per VServer?&lt;br /&gt;
||Details=Yes, but not on a shared partition for now. You need to put the guest on a separate partition, setup a vroot device (to make the quota access secure), copy that into the guest, and adjust the mtab line inside the guest. If 8 vroot device is not enough for you, you can add more with the kernel parameter max_vroot (exemple for built in kernel vroot /vmlinuz-2.6.31.6-vs2.3.0.36.26aq root=/dev/md1 ro max_vroot=20 ). If vroot is a module you'd actually want to put for exemple &amp;quot;options vroot max_vroot=20&amp;quot; in /etc/modprobe.conf and then just do modprobe vroot&lt;br /&gt;
|Signature=derjohn,gadnet}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What about &amp;quot;Quota&amp;quot; for a context? Howto limit disk usage?&lt;br /&gt;
||Details=Context quotas are now called Disk Limits (so that we can tell them apart from the user/group quotas :). They are supported out of the box (with vs2.0+) for all major filesystems (ext2/3, ReiserFS, JFS). You need to tag the FS with XID (see below). Please read [[Disk Limits and Quota]] for more information.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I tag a guest's directory with xid?&lt;br /&gt;
||Details=Tagging the guest's files gives you several advantages, e.g. the accounting will work properly.&lt;br /&gt;
Filesystem XID tagging only works on supported filesystem. Those are currently: ext2/3, reiserfs/reiser3, xfs and jfs.&lt;br /&gt;
To activate the XID tagging you have to mount the filesystem with &amp;quot;-o tag&amp;quot; (former tagxid is outdated since VS2.2). Attention: It's _not_ possible to &amp;quot;-o remount,tag&amp;quot;, you have to mount it freshly. The guests will tag their files automatiaclly. If you copy files in from the host, you have to tag them manually like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
chxid -c xid -R /var/lib/vservers/&amp;lt;guest&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note: Context 0 and 1 will see all files, guests will only be able to access untagged files and their own XID. They can see other XID files but no information about the file, e.g. no owner, no group, no permissions.&lt;br /&gt;
Note: It is not advised to tag the root filesystem, as [http://www.paul.sladen.org/vserver/archives/200602/0020.html explained by Herbert] : trying to do so will expose you to some troubles !&lt;br /&gt;
|Signature=derjohn_and_gonzo_and_are}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How can I copy anything from host to guest partition, normally unvisible on host?&lt;br /&gt;
||Details=You should just change namespace, e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vnamespace --enter &amp;lt;xid&amp;gt; -- /bin/bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and then use standard cp or rsync programs.&lt;br /&gt;
|Signature=SergiuszPawlowicz}}&lt;br /&gt;
&lt;br /&gt;
== Network ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Does it support IPv6?&lt;br /&gt;
||Details=Currently it requires an additional patch, but the functionality should be available in 2.3+ soon. [[IPv6]] has more information.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I can't do all I want with the network interfaces inside the guest?&lt;br /&gt;
||Details=For now the networking is 'Host Business' -- the host is a router, and each guest is a server. You can set the capability ICMP_RAW in the context of the guest, or even the capability CAP_NET_RAW (which would even allow to sniff interfaces of other guests!). Likely to change with ngnet.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I add several IPs to a vserver?&lt;br /&gt;
||Details=First of all a single guest vserver only supports up to 16 IPs (There is a 64-IP patch available, which is in &amp;quot;derjohn's kernel&amp;quot;).&lt;br /&gt;
Here is a little helper-script that adds a list of IPs defined in a text file, one per line.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
j=1&lt;br /&gt;
for i in `cat myiplist`; do&lt;br /&gt;
        j=$(($j+1))&lt;br /&gt;
        mkdir $j&lt;br /&gt;
        echo $i &amp;gt; $j/ip&lt;br /&gt;
        echo &amp;quot;24&amp;quot; &amp;gt; $j/prefix&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I assign a new IP address to a running guest?&lt;br /&gt;
||Details=This is done from the host server:&lt;br /&gt;
* add the ip on the host, for example&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ip addr add 194.169.123.23/24 dev eth0 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* add the ip to the guest's network context (a guests NID is the same as the XID {context ID})&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
naddress --add --nid &amp;lt;nid&amp;gt; --ip 194.169.123.23/24 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enter the guest (best via ssh) &lt;br /&gt;
* restart the services that need to make use of the new address if required &lt;br /&gt;
* update the config in ''/etc/vserver/&amp;lt;servername&amp;gt;/interfaces'' to reflect the changes for the next guest restart (if desired)&lt;br /&gt;
|Signature=BenjaminGreen}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=If my host has only one a single public IP, can I use RFC1918 IP (e.g. 192.168.foo.bar) for the guest vservers?&lt;br /&gt;
||Details=Yes, use iptables with SNAT to masquerade it. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
iptables -t nat -I POSTROUTING -s $VSERVER_NETZ  ! -d $VSERVER_NETZ -j SNAT --to $EXT_IP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
See: [[HowtoPrivateNetworking]] and &lt;br /&gt;
http://www.tgunkel.de/it/software/doc/linux_server.en#h3-VServer_Masquerading_SNAT (THX, [MUPPETS]Gonzo)&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=If I shut down my vserver guest, the whole Internet interface ethX on the host is shut down.  What happened?&lt;br /&gt;
||Details=When you shut down a guest (''i.e. vserver foo stop''), the IP is brought down on the host also. If this IP happens to be the primary IP of the host, the kernel will not only bring down the primary IP, but also all secondary IP addresses. But in very recent kernels, there is an option ''settable'' which prevents that nasty feature. It's called &amp;quot;alias promotion&amp;quot;. You may set it via sysctl by adding ''net.ipv4.conf.all.promote_secondaries=1'' in /etc/sysctl.conf or via sysctl command line.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Can I run an OpenVPN Server in a guest?&lt;br /&gt;
||Details=&lt;br /&gt;
Yes. To get a OpenVPN Server running in a guest, all networking setup has to be done on the host. This answer describes the common case and shows some pitfalls, for detailled information about OpenVPN, please consult the appropriate documentation on the OpenVPN homepage.&lt;br /&gt;
This is the minimal OpenVPN configuration for the Server which will be used to demonstrate how to get it running in a client:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Networking setup&lt;br /&gt;
server 192.168.16.0     255.255.255.0&lt;br /&gt;
dev tun16&lt;br /&gt;
ifconfig-noexec&lt;br /&gt;
comp-lzo&lt;br /&gt;
# Certificates&lt;br /&gt;
dh ...&lt;br /&gt;
ca ...&lt;br /&gt;
cert ...&lt;br /&gt;
key ...&lt;br /&gt;
# Management&lt;br /&gt;
persist-key&lt;br /&gt;
keepalive 10 60&lt;br /&gt;
verb 4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First of all you have to prepare the host with a persistent interface in the right mode and with the right settings. This is easily done by using openvpn and the ip and route tools.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# openvpn --mktun --dev tun16&lt;br /&gt;
# ip link set dev tun16 txqueuelen 100&lt;br /&gt;
# ifconfig tun16 192.168.16.1 pointopoint 192.168.16.2 mtu 1500&lt;br /&gt;
# route add -net 192.168.16.0 netmask 255.255.255.0 gw 192.168.16.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you need different settings, openvpn will tell you the ifconfig and route commands it uses to configure the interface when being started on the host with the original config file, but without ifconfig-noexec.&lt;br /&gt;
Additionally, the guest needs /dev/net/tun to make OpenVPN happy. This can be created with MAKEDEV:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /var/lib/vserver/&amp;lt;myopenvpnserver&amp;gt;/dev/&lt;br /&gt;
# ./MAKEDEV tun&lt;br /&gt;
  (creates the dev/net/tun device accessible by the guest - even a tap interface needs /dev/net/tun !)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, the guest needs to have the tun device assigned:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# head /etc/vservers/&amp;lt;myopenvpnserver&amp;gt;/interfaces/1/*&lt;br /&gt;
==&amp;gt; /etc/vservers/&amp;lt;myopenvpnserver&amp;gt;/interfaces/1/ip &amp;lt;==&lt;br /&gt;
192.168.16.1&lt;br /&gt;
&lt;br /&gt;
==&amp;gt; /etc/vservers/&amp;lt;myopenvpnserver&amp;gt;/interfaces/1/nodev &amp;lt;==&lt;br /&gt;
tun16&lt;br /&gt;
&lt;br /&gt;
==&amp;gt; /etc/vservers/&amp;lt;myopenvpnserver&amp;gt;/interfaces/1/prefix &amp;lt;==&lt;br /&gt;
24&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The client's conf may look like that:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Basic setup&lt;br /&gt;
client&lt;br /&gt;
proto tcp-client&lt;br /&gt;
dev tun&lt;br /&gt;
remote &amp;lt;ipaddress&amp;gt;&lt;br /&gt;
comp-lzo&lt;br /&gt;
verb 4&lt;br /&gt;
&lt;br /&gt;
# Certificate&lt;br /&gt;
ca ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[ Based on derJohn's original answer, all errors mine ] &lt;br /&gt;
|Signature=DavidS}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Trying to connect to a vserver from the host or another vserver on the same host fails&lt;br /&gt;
||Details=strace shows&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sin_addr=inet_addr(&amp;quot;xx.xx.xx.xx&amp;quot;)}, yy) = -1 EINVAL (Invalid argument)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A: The host/guest cannot communicate with another guest on same host.&lt;br /&gt;
* check all netmasks on all interfaces (do they overlap) ?&lt;br /&gt;
* check policy routing (disable it temporary) ?&lt;br /&gt;
* check that lo is up (Networking within a host/guest always uses lo interface)&lt;br /&gt;
|Signature=CommonProblems}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Can I use iptables ?&lt;br /&gt;
||Details=Yes but right now only on the host (rootserver). Please realize that all traffic is local and will not touch the forward chain.&lt;br /&gt;
|Signature=BeginnerFAQ}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is it possible to prevent guest from bringing down primary ip?&lt;br /&gt;
||Details=Yes. Remove /etc/vservers/&amp;lt;guest&amp;gt;/interfaces/X/dev, and touch /etc/vservers/&amp;lt;guest&amp;gt;/interfaces/X/nodev&lt;br /&gt;
|Signature=Daniel&amp;amp;Serge}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is it possible to provide a different MAC address per vServer?&lt;br /&gt;
||Details=Short answer - yes but it's a hassle.&lt;br /&gt;
&lt;br /&gt;
Real answer from '''_are_''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
When I once needed 'real' seperate MAC-addresses I used TAP-devices and VDE2 ([http://vde.sourceforge.net/ Virtual Distributed Ethernet]).&lt;br /&gt;
Basically vServer is an isolation of existing resources, not a virtualization of 'new' devices.&lt;br /&gt;
Without extra fuss you can't add a 'new' network interface to a vServer, no matter if it is eth* or tap*, you always add it to the host and give the vServer access to it.&lt;br /&gt;
I got the TAP+VDE2 up and running, but I think it is too much trouble for basically the simple adding of IPs to a vServer unless you really need the MAC address separate.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=bobnormal}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is it possible to hide packet counters on the host network interface from vServer guests?&lt;br /&gt;
||Details=Yes, see [[Networking_vserver_guests|Networking vServer Guests]]&lt;br /&gt;
|Signature=bobnormal}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Administration tools ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Which guest vservers are running?&lt;br /&gt;
||Details=Use vserver-stat to find out.  Example output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CTX   PROC    VSZ    RSS  userTIME   sysTIME    UPTIME NAME&lt;br /&gt;
0       77 965.1M 334.6M  14m14s18   2m28s69   1h33m46 root server&lt;br /&gt;
49152    7    14M   5.2M   0m00s40   0m00s30   1h30m15 chiffon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is there a web-based interface for vserver that will allow creation/deletion/configuration etc. of vserver guests?&lt;br /&gt;
||Details=&lt;br /&gt;
* http://OpenVPS.org which is a set of scripts with a web-interface for webhosters/ISPs&lt;br /&gt;
* http://Openvcp.org which is a distributed system (agent!) with a web-interface, with which you can build/remove guests&lt;br /&gt;
* http://vsmon.revolutionlinux.com/ is a distributed monitoring-only solution that allows you to search for a particular vserver in your park.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
== Hosting foreign distributions ==&lt;br /&gt;
 &lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I run a Debian host and want to build an Ubuntu guest. Howto?&lt;br /&gt;
||Details=Simple ;) Assume you want to build a breezy guest on a sid host with IP 192.168.0.2 and hostname vubuntu, then do:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver vubuntu build --force -m debootstrap --hostname vubuntu.myvservers.net --netdev eth0 --interface 192.168.0.2/24 \&lt;br /&gt;
--context 42 -- -d breezy -m http://de.archive.ubuntu.com/ubuntu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[UPDATE] Currently there are problems in building breezy under unclear circumstances, which seems to have to do with udev. If the above didnt work, try:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver vubuntu build --force -m debootstrap --hostname vubuntu.myvservers.net --netdev eth0 --interface 192.168.0.2/24 \&lt;br /&gt;
--context 42 -- -d breezy -m http://de.archive.ubuntu.com/ubuntu -- --exclude=udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In very recent versions of the utils, the problem should not occur anymore (it has to do with the 'secure-mount' if you look in the MLs)&lt;br /&gt;
&lt;br /&gt;
Well, sid's debootstrap knows how to bootstrap Ubuntu linux. Make sure to have a current debootstrap package: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt-get update&lt;br /&gt;
apt-get install debootstrap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 The knowledge how to build ubuntu 'breezy badger' (which you probably want to be your guest at the time of writing) has been added recently.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I want to build a Gentoo guest. Howto?&lt;br /&gt;
||Details=Even simpler ;) See http://www.gentoo.org/proj/en/vps/vserver-howto.xml#doc_chap3 .&lt;br /&gt;
|Signature=gcc}}&lt;br /&gt;
&lt;br /&gt;
== Application level problems ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I did everything right, but the application foo does not start. What's up there?&lt;br /&gt;
||Details=Before asking on the IRC channel, please check out the 'problematic programs' page:&lt;br /&gt;
[[Problematic Programs]]&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=When I try to ssh to the guest, I log into the host, even if I installed sshd on the guest. What's wrong here?&lt;br /&gt;
||Details=Look at /etc/ssh/sshd_config of the host:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Port 22&lt;br /&gt;
# Use these options to restrict which interfaces/protocols sshd will bind to&lt;br /&gt;
#ListenAddress ::&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And now change the setting to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Port 22&lt;br /&gt;
# Use these options to restrict which interfaces/protocols sshd will bind to&lt;br /&gt;
ListenAddress your.hosts.ip.here  # not the guests IP! &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then '/etc/init.d/ssh restart' on the host, after that on the guest (if you did apt-get install ssh on the guest already.)&lt;br /&gt;
Do I have to explain more? If the hosts sshd binds all available IP addresses on port 22 (The hosts 'sees' even all addresses of the guests!). So if the guest starts its sshd, it can't bind to port 22 any more. You need to change that setting only on the host. &lt;br /&gt;
(BTW: A similar approach has to be done for a lot of daemons, e.g. Apache. If the daemon does not support an explicit bind, you may use the chbind command to 'hide' IP addresses from the daemon before starting.)|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Bind9 does not like to start in my guest.&lt;br /&gt;
||Details=Check out the [[Problematic Programs]] page and/or get my [http://linux-vserver.derjohn.de/bind9-packages/bind9-capacheck_9.3.2-2_i386.deb vserver-guest-ready Debian package] for Debian Sid guests and check out the [http://linux-vserver.derjohn.de/bind9-packages/README.txt readme]. (Hint: This is fresh stuff. Please give me feedback)&lt;br /&gt;
 &lt;br /&gt;
[UPDATE] Since VServer Devel 2.1.1-rc18 you do not need to patch the userland tools anymore. The capabilities are masked.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=My mysqld running in a guest behaves strangely and is awfully slow/locks up&lt;br /&gt;
||Details=This can be related to /tmp being too small. mysqld stores temporary tables in /tmp and as such, if a lot of queries happen and /tmp runs full this can cause one query to lock up whilst creating the tmp table and all other queries waiting to acquire the lock. There are two possible solutions to that problem: a.) Modify /etc/vservers/vserver-name/fstab and assign more memory to the tmpfs of /tmp and b.) remove the /tmp entry from /etc/vservers/vserver-name/fstab completly. Especially on database servers with a rather high load the second one might be the preferred method.|Signature=sp}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Pure-FTP does not run inside a VServer?&lt;br /&gt;
||Details=That's because it has capabilities enabled, make sure you rebuild your distro's package passing also the `--without-capabilities` flag to configure.&lt;br /&gt;
|Signature=Pedro Algarvio, aka, s0undt3ch}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Why do neither sshd nor crond (vixie-cron) work correctly in my CentOS / Fedora guest? I get 'pam_loginuid(crond:session): set_loginuid failed opening loginuid' and similar lines in my logs.&lt;br /&gt;
||Details=Took me a while to figure this out, and it turned out to be mentioned in the old wiki. Here is the solution on how to solve a common problem with sshd / crond, somehow related to selinux and auditing:&lt;br /&gt;
&lt;br /&gt;
pam authentication (also used with openssh) enables &amp;quot;pam_loginuid.so&amp;quot; in the /etc/pam.d/* files. Comment those out as they are not necessary and will not load within a guest anyway. This probably is also necessary on updates later on, if the configs get changed. You therefore may add the following command line to a cronjob file or your software update script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/bin/sed --in-place -e &amp;quot;s/^session.*required.*pam_loginuid.so/# session\trequired\tpam_loginuid.so/g&amp;quot; /etc/pam.d/*&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=patrick}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do i install nagios-plugins on a Gentoo guest?&lt;br /&gt;
||Details=Unfortunately, the nagios-plugins ./configure scripts wants to ping 127.0.0.1 which is not available inside a guest. Therefore you have to build nagios-plugins outside the guest.&lt;br /&gt;
The easiest way to do this from the host (assuming the guest is running) is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vnamespace -e &amp;lt;xid&amp;gt; -- chroot /vservers/&amp;lt;name&amp;gt; emerge nagios-plugins -va&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=Hollow}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Somebody runs ntpd in guest and you can't use ntpdate in host?&lt;br /&gt;
||Details=Try to run ntpdate with options -u :&lt;br /&gt;
 ntpdate -u ntp.domain.xy&lt;br /&gt;
or you can use command:&lt;br /&gt;
 chbind --nid 42 --ip 1.2.3.4 -- ntpdate ntp.domain.xy&lt;br /&gt;
where IP will be the IP of host.&lt;br /&gt;
|Signature=Punkie/Bertl}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Start / Stop a VServer ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I make a vserver guest start by default?&lt;br /&gt;
||Details=At least on Debian, I can tell you how to do it with the new-style config. If your guest is called &amp;quot;derjohn&amp;quot; and you want it to be started somewhere at the of your bootstrap process, then do:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;default&amp;quot; &amp;gt; /etc/vservers/derjohn/apps/init/mark&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to start it earlier, please read the init script &amp;quot;/etc/init.d/util-vserver&amp;quot; to find out how to do it. In most cases you don't need to change this. On Debian the vservers are started at &amp;quot;20&amp;quot;, so after most other stuff is up (networking etc.).&lt;br /&gt;
&lt;br /&gt;
Besides that I created a small helper script for managing the autostart foo: ((vserver-autostart))|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=My host works, but when I start a guest it says that it has a problem with chbind.&lt;br /&gt;
||Details=You are probably using util-vserver &amp;lt;= 0.30.209, which does use dynamic network contexts internally (With 0.30.210 this fact changed). So if you compiled your kernel without dynamic contexts, you may start guests, but you can't use the network context.The solution is either to switch to .210 util (or Hollow's toolset) or compile the kernel with dynamic network contexts.&lt;br /&gt;
SE Keyword: invalid option `nid' testme.sh&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is old-style and new-style config?&lt;br /&gt;
||Details=Old-style config refers to a single text-file that contains all the configuration settings. With new-style config the configuration is split into several directories and files. You should probably go for new-style config if you are asking.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How can I reboot/halt guests?&lt;br /&gt;
||Details=It depends. &lt;br /&gt;
For legacy Linux-VServer (i.e. 1.2.x), you have to replace /sbin/halt in the guests with vreboot and start rebootmgr in the host. You also need to have a &amp;lt;guest&amp;gt;.conf file in /etc/vservers for each guest. Please have a look at /etc/init.d/rebootmgr.&lt;br /&gt;
For Linux-VServer 2.0+, sys_reboot has been virtualized to do the right thing. No changes are needed in guests. Please note that some things depend on the init style used by the guest : read [[util-vserver:InitStyles]]&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is the initial PATH?&lt;br /&gt;
||Details=By default, vserver uses the 'sysv' startup style, which mimics the init process by running the 3rd runlevel through '/etc/init.d/rc 3' (or '/etc/rc.d/rc 3'). Usually this 'rc' script uses a hard-coded PATH. In the case it doesn't, util-vserver also mimics init's default PATH through /etc/vservers/.defaults/apps/init/environment, or if not present /usr/local/lib/util-vserver/defaults/environment. Beware that all those default PATH usually do not include /usr/local.&lt;br /&gt;
|Signature=daniel_hozac&amp;amp;Beuc}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=When I try to start a guest i get this message &amp;quot;/proc/uptime can not be accessed. Usually, this is caused by procfs-security. Please read the FAQ for more details&amp;quot;?&lt;br /&gt;
||Details=After a reboot you need to run the vprocunhide script. If running this script causes many errors to print on the screen, try checking the kernel you have booted with (perhaps it does not have the linux-vserver extensions enabled).&lt;br /&gt;
|Signature=mattzerah}}&lt;br /&gt;
&lt;br /&gt;
== Kernel ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is SMP Supported?&lt;br /&gt;
||Details=Yes, on all SMP capable kernel architectures.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Do I really need the legacy-interfaces? What are these legacy-interfaces?&lt;br /&gt;
||Details=Since Linux-VServer is an ongoing project, new features might replace old ones, some might require a development version. Legacy-interfaces are available for backward compability (which might be removed someday) with Linux-VServer 1.2.x.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I have a vserver running on a Linux kernel with preemption. Is VServer &amp;quot;preempt&amp;quot; safe?&lt;br /&gt;
||Details=There are no known issues about running vserver on a preemption enabled kernel. I would like to add, that the vserver kernelhackers would probably exclude that option in 'make menuconfig' if there would be an incompatibility. Just my $.02 :)&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=32 vs 64 Bit? What should I take?&lt;br /&gt;
||Details=If you have the choice make the host a 64 bit one. You can run a guest as 32 bit or as 64 bit on a 64 bit host. To run it as 32 bit, you need to compile the x86_64 (a.k.a. AMD64) with the following options:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[*] Kernel support for ELF binaries&lt;br /&gt;
&amp;lt;M&amp;gt; Kernel support for MISC binaries&lt;br /&gt;
[*] IA32 Emulation &amp;lt;---- without that, the entire 32bit API is not present&lt;br /&gt;
&amp;lt;M&amp;gt;   IA32 a.out support  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can force the guest to behave like a 32 environment like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo linux_32bit &amp;gt; /etc/vservers/$NAME/personality&lt;br /&gt;
echo i686 &amp;gt; /etc/vservers/$NAME/uts/machine&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(thanks cehteh for the hint!)&lt;br /&gt;
&lt;br /&gt;
But you can force debootstrap to put 32 bit binaries into the guest by 'export ARCH=i386';&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export ARCH=i386 ; vserver build .... &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On debian when using the newvserver script &amp;quot;export ARCH=i386&amp;quot; has no effect, just use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
newvserver --arch i386 ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Distribution specific questions ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=VServer is included in the stable Debian GNU/Linux for years now. What VS version did they include?&lt;br /&gt;
||Details=At the time of writing, Debian Lenny is the stable release of Debian and includes a 2.6.26 based kernel-package called 2.6.26-2-vserver-ARCH. This currently contains VServer 2.3.0.35 (according to changelog.Debian.gz in the Debian package).&lt;br /&gt;
|Signature=scientes}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Were can I get newer versions of VServer as ready made packages for Debian?&lt;br /&gt;
||Details=Here you go: http://linux-vserver.derjohn.de/ . There is also some stuff on backports.org, but my kernels are always 'devel' branch.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Misc ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Why isn't there a device /dev/xyz within a guest?&lt;br /&gt;
||Details=Device nodes allow userspace to access hardware (or virtual resources). Creating a device node inside the guest's namespace will give access to that device, so for security reasons, the number of 'given' devices is small.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I want to (re)mount a partition in a running guest ... but the guest has no rights (capability) to (re)mount?&lt;br /&gt;
||Details=I'll explain. I take as example your /tmp partition within the guest is too small, what will be likely the case if you stay with the 16MB default (vserver build mounts /tmp as 16 MB tmpfs!).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vnamespace -e XID  mount -t tmpfs -o remount,size=256m,mode=1777 none /var/lib/vservers/&amp;lt;guest&amp;gt;/tmp/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(if there's a problem, try expanding the symlinks in the mount path)&lt;br /&gt;
Be warned that the guest will not recognize the change, as the /etc/mtab file is not updated when you mount like this. To permanently change the mount, edit /etc/vserver/&amp;lt;guest&amp;gt;/fstab on the host.&lt;br /&gt;
&lt;br /&gt;
If you get:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount: can't find /var/lib/vservers/&amp;lt;guest&amp;gt;/tmp in /etc/fstab or /etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
then try instead:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vnamespace -e builder chroot /var/lib/vservers/&amp;lt;guest&amp;gt;/ mount -o remount,size=64m,mode=1777 /tmp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this not work for adding a bindmount (&amp;lt;tt&amp;gt;-o bind&amp;lt;/tt&amp;gt;) of a directory outside of a vserver into the vserver. For this, there is no alternative but restarting the vserver.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Does anyone know how to increase the size of /tmp within a vserver w/o restarting?&lt;br /&gt;
||Details=Use the remount option for mount.&lt;br /&gt;
 # vnamespace -e XID mount -n -t tmpfs -o remount,size=32m tmpfs /&amp;lt;vdir&amp;gt;/&amp;lt;guest&amp;gt;/tmp&lt;br /&gt;
or something like that.  The arguments are needed since mount is not going to be using /etc/fstab for the information and the version of /proc/mounts is best understood by&lt;br /&gt;
 # vnamespace -e XID cat /proc/mounts.&lt;br /&gt;
See [[Frequently_Asked_Questions#I want to (re)mount a partition in a running guest ... but the guest has no rights (capability) to (re)mount?]]&lt;br /&gt;
|Signature=derjohn/dhozac}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=#1 ERROR:  capset(): Operation not permitted&lt;br /&gt;
||Details=capabilities are not enabled in kernel-setup&lt;br /&gt;
please check that CONFIG_SECURITY_CAPABILITIES is loaded or included in the kernel. ( check with &amp;quot;cat /path_to_kernel/.config | grep -i cap &amp;quot;) &lt;br /&gt;
(2.6.11.5-vs-1.9.5 + 0.30-205)&lt;br /&gt;
|Signature=IrcQuestions}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How can I make 'vserver start' mount the root filesystem?&lt;br /&gt;
||Details=Mount it via /etc/vservers/vserver-name/fstab, make sure to set the option 'dev' e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;/dev/drbd0     /       xfs     rw,dev          0 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=AdrianReyer}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I deleted a guest's directory without shutting it down. Now I have a &amp;quot;ghost&amp;quot; running. Is there any possibility to get it out of proc without rebooting?&lt;br /&gt;
||Details=&lt;br /&gt;
 vkill --xid &amp;lt;xid&amp;gt; -s 15; sleep 2; vkill --xid &amp;lt;xid&amp;gt; -s 9&lt;br /&gt;
&lt;br /&gt;
You will also need to remove guest's ip, for example with:&lt;br /&gt;
 ip addr del &amp;lt;ip&amp;gt; dev eth0&lt;br /&gt;
|Signature=daniel_hozac &amp;amp; gebura }}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=When using nice and su (for example, in the updatedb cron job), I get: su: Permission denied. What does it mean?&lt;br /&gt;
||Details=A guest cannot lower its nice value - and that's what 'su' does through pam_limits which sets a nice value of 0. You can see it through strace:&lt;br /&gt;
 $ strace nice su nobody&lt;br /&gt;
 [...]&lt;br /&gt;
 setpriority(PRIO_PROCESS, 0, 0)         = -1 EACCES (Permission denied)&lt;br /&gt;
You can use 'su nobody -c nice some_cmd' instead.&lt;br /&gt;
(Now there's the question of why a guest process cannot lower its nice value.)&lt;br /&gt;
|Signature=daniel_hozac&amp;amp;Beuc}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I handle NFS mounts within in a guest?&lt;br /&gt;
||Details=There are three ways. &lt;br /&gt;
&lt;br /&gt;
'''1)''' Mount the NFS share from the host OS and let vserver guest access it as part of it's file system.&lt;br /&gt;
&lt;br /&gt;
''mount --bind'' may also be beneficial in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''2)''' Use util-vserver and create a ''fstab.remote'' file in the /etc/vserver/&amp;lt;vserver_name&amp;gt; directory. Populate this with the NFS shares and they will be mounted in the context of the vserver guest.&lt;br /&gt;
&lt;br /&gt;
See http://www.nongnu.org/util-vserver/doc/conf/configuration.html&lt;br /&gt;
&lt;br /&gt;
'''3)''' Add capabilities to the vserver guest instance to grant sufficient rights to allow NFS mounts.&lt;br /&gt;
&lt;br /&gt;
Add the following to /etc/vserver/&amp;lt;vserver_name&amp;gt;/bcapabilities&lt;br /&gt;
 SYS_ADMIN&lt;br /&gt;
Add the following to /etc/vserver/&amp;lt;vserver_name&amp;gt;/ccapabilities&lt;br /&gt;
 SECURE_MOUNT&lt;br /&gt;
 BINARY_MOUNT&lt;br /&gt;
&lt;br /&gt;
See [[Capabilities_and_Flags]] for more information about vserver capabilities.&lt;br /&gt;
&lt;br /&gt;
If you want the NFS shares to be mounted when the guest starts, add them to /etc/vserver/&amp;lt;vserver_name&amp;gt;/fstab&lt;br /&gt;
&lt;br /&gt;
||Signature=martindk}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=vserver start/stop/enter fails with something like &amp;quot;vnamespace: execvp(&amp;quot;/usr/sbin/vserver&amp;quot;): No such file or directory&amp;quot; ?&lt;br /&gt;
||Details=Check whether ''/usr'' is mounted in the namespace you are working with.&lt;br /&gt;
&amp;lt;pre&amp;gt;vnamespace -e &amp;lt;guest&amp;gt; cat /proc/mounts&amp;lt;/pre&amp;gt;&lt;br /&gt;
If there is no ''/usr'', you can fix your problem with simply mounting it using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;vnamespace -e &amp;lt;guest&amp;gt; mount /dev/&amp;lt;device&amp;gt; /usr&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
||Signature=sim0n}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=The command vserver &amp;lt;$server&amp;gt; start gives '/etc/init.d/rc: line 74: /etc/default/rcS: No such file or directory', what do I do? &lt;br /&gt;
||Details=The vserver has not been correctly installed, this has several reasons&lt;br /&gt;
check your install log and it should tell you something about that your server didn't get installed properly&lt;br /&gt;
* use stable distribution of debian as server (debootstrap may be different over the versions)&lt;br /&gt;
* deny_mount, deny_caps and deny_pivot should be off if your running grsec.&lt;br /&gt;
&lt;br /&gt;
||Signature=Dude}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How could I rename a vserver directory?&lt;br /&gt;
||Details=Please note : this procedure renames the '''directory''', not the '''hostname''' !&lt;br /&gt;
#Stop the vserver in question&lt;br /&gt;
#rename the &amp;lt;tt&amp;gt;/vservers/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt; directory&lt;br /&gt;
#rename the &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt; directory&lt;br /&gt;
#update link: &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;/run&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;/var/run/vservers/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
#update link: &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;/vdir&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;/etc/vservers/.defaults/vdirbase/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
#update link: &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;/cache&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;/etc/vservers/.defaults/cachebase/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
#update link: &amp;lt;tt&amp;gt;/var/run/vservers.rev/&amp;lt;server XID&amp;gt;&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
#Start the vserver in question. It should start properly.&lt;br /&gt;
&lt;br /&gt;
|Signature=FlorianD (from ''hillct'' page in old wiki)}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade from 2.0 to 2.2 ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I now get errors like &amp;quot;ncontext: vc_net_create(): Invalid argument; dynamic contexts disabled.&amp;quot; on startup. Vservers are not started&lt;br /&gt;
||Details=Dynamic context are disabled by default and are deprecated. For example, tagxid and network checks won't be useable with dynamic ids. Now you should manually assign a explicit context to your vservers, like&lt;br /&gt;
 echo 101 &amp;gt; /etc/vservers/myvserv/context&lt;br /&gt;
ADDENDUM: please consider that valid static contexts are between 2 and 49151 ( daniel_hozac on IRC ) otherwise you will end up with unexplainable error &amp;quot;ncontext: vc_net_migrate(): No such process&amp;quot; when trying to start the vserver.&lt;br /&gt;
&lt;br /&gt;
|Signature=daniel_hozac&amp;amp;Beuc}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I assign a static context to an existing vserver?&lt;br /&gt;
||Details=Simple ;) See the answer above. &lt;br /&gt;
|Signature=gcc}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Since upgrading to a newer VS version my guest complains about &amp;quot;vsched: non-numeric value specified for '--priority_bias&amp;quot; at start time. What's wrong?&lt;br /&gt;
||Details=The scheduler paramters changed.You can use this (ugly) script to convert them or do it by hand:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat /usr/local/sbin/vserver-convert-schedule-to-scheddir&lt;br /&gt;
#/bin/sh&lt;br /&gt;
mkdir /etc/vservers/$1/sched&lt;br /&gt;
sed -e 1p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/fill-rate&lt;br /&gt;
sed -e 2p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/interval&lt;br /&gt;
sed -e 3p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/tokens&lt;br /&gt;
sed -e 4p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/tokens-min&lt;br /&gt;
sed -e 5p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/tokens-max&lt;br /&gt;
&lt;br /&gt;
mv /etc/vservers/$1/schedule /etc/vservers/$1/schedule.converted.see.scheddir&lt;br /&gt;
&lt;br /&gt;
# see: http://oldwiki.linux-vserver.org/Scheduler+Parameters&lt;br /&gt;
# see: http://www.nongnu.org/util-vserver/doc/conf/configuration.html#sched&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
||Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Since upgrading to a newer VS version my guest doesn't have the amount of shared memory (SHM / SHMMAX / SHMALL ) as it had in the former version. What changed?&lt;br /&gt;
||Details=Every VS version that runs on a kernel &amp;gt;= 2.6.19 offers sysctl values per guest. This has to do with the 'ipc namespace' feature that was added to the mainline kernel in version 2.6.19. Linux-VServer uses that feature to give each guest a separate 'ipc namespace' and thus 'own' sysctl values per guest. Because shmmax is such a sysctl value, you have to set it per guest.&lt;br /&gt;
Here is an example how to do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/0 -p&lt;br /&gt;
# echo kernel.shmall &amp;gt; /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/0/setting&lt;br /&gt;
# echo 134217728 &amp;gt; /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/0/value&lt;br /&gt;
# mkdir /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/1 -p&lt;br /&gt;
# echo kernel.shmmax &amp;gt; /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/1/setting&lt;br /&gt;
# echo 134217728 &amp;gt; /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/1/value&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It's also explained on the geat flower page:&lt;br /&gt;
# see: http://www.nongnu.org/util-vserver/doc/conf/configuration.html -&amp;gt; Look for &amp;quot;sysctl&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
After changing those values, restart your guest, enter it and check if the values are set:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sysctl -a | grep shm&lt;br /&gt;
...&lt;br /&gt;
kernel.shmall = 134217728&lt;br /&gt;
kernel.shmmax = 134217728&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To change a value for a running guest, on the host use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 vspace -e CONTEXTID --ipc sysctl -w kernel.shmall=134217728&lt;br /&gt;
 vspace -e CONTEXTID --ipc sysctl -w kernel.shmmax=134217728&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
||Signature=derjohn&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Networking_vserver_guests</id>
		<title>Networking vserver guests</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Networking_vserver_guests"/>
				<updated>2010-02-15T13:52:21Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Host */ add explanation of optional dummy device procedure&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up network access to and from your vserver guests.&lt;br /&gt;
__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Lets imagine, you have only one external IP -- &amp;lt;code&amp;gt;$EXTIP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You want to have several vservers running without worrying about port overlapping.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Two vservers run a default webserver, running on port 80. If each &amp;quot;guest&amp;quot; vserver shares an IP with the host, then the two webservers will conflict.&lt;br /&gt;
&lt;br /&gt;
One solution is:&lt;br /&gt;
&lt;br /&gt;
* All vservers are contained in a &amp;quot;virtual lan&amp;quot;, say 192.168.1.x&lt;br /&gt;
* Each vserver has its own IP&lt;br /&gt;
* Control port forwarding on &amp;quot;parent&amp;quot; host. That is, run a router.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
===Host===&lt;br /&gt;
&lt;br /&gt;
===Optional: Load 'dummy' device(s)===&lt;br /&gt;
&lt;br /&gt;
====Why?====&lt;br /&gt;
This driver allows you to associate vServer guests with a ''virtual'' network device rather than the host's real network interface, which functions to hide packet counters from vServer guests.  There is no other use for this step, so feel free to skip it if you are not worried about sharing packet counters.  Packet counts ''may'' be useful to an attacker with control of a vServer guest who wishes to perform side-channel attacks during cryptanalysis, or network traffic analysis against your host or other vServer guests.  If you did not understand the last sentence and your installation is not particularly security sensitive, then the chances that you will encounter a skilled attacker are slim to none and you should feel free to skip this section.&lt;br /&gt;
&lt;br /&gt;
====Process====&lt;br /&gt;
First you need to load the dummy interface driver&lt;br /&gt;
 # modprobe dummy&lt;br /&gt;
&lt;br /&gt;
To have it automatically loaded on startup, add&lt;br /&gt;
&amp;quot;loopback&amp;quot; to /etc/modules&lt;br /&gt;
&lt;br /&gt;
Set up &amp;lt;code&amp;gt;dummy0&amp;lt;/code&amp;gt; interface on the parent host&lt;br /&gt;
 # /etc/network/interfaces on a Debian box, &lt;br /&gt;
 # configure on other distros with your preferred way&lt;br /&gt;
 auto dummy0&lt;br /&gt;
 iface dummy0 inet static&lt;br /&gt;
     address 192.168.1.250&lt;br /&gt;
     netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
===Guests===&lt;br /&gt;
Set up each guest vserver:&lt;br /&gt;
 cd /etc/vservers/$VSERVER/interfaces/0&lt;br /&gt;
 echo dummy0 &amp;gt; dev&lt;br /&gt;
 echo 192.168.1.1 &amp;gt; ip&lt;br /&gt;
 echo 1 &amp;gt; name&lt;br /&gt;
 echo 24 &amp;gt; prefix&lt;br /&gt;
Consider using a value of &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; equal to the last digit of the IP for easy separation.&lt;br /&gt;
&lt;br /&gt;
===Host as router===&lt;br /&gt;
Configure the host to act as a router.&lt;br /&gt;
&lt;br /&gt;
For internal packets going outside, pretend each packet came from our external IP (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A POSTROUTING -s 192.168.1.0/24 \ &lt;br /&gt;
   -d ! 192.168.1.0/24 -j SNAT --to-source $EXTIP&lt;br /&gt;
For each service that runs on a vserver, map it to an external port. Vserver local address &amp;lt;code&amp;gt;$VHOST&amp;lt;/code&amp;gt; and port &amp;lt;code&amp;gt;$INTPORT&amp;lt;/code&amp;gt; you select one external port &amp;lt;code&amp;gt;$EXTPORT&amp;lt;/code&amp;gt; and run the following (put it in one line without backslash):&lt;br /&gt;
 # iptables -t nat -A PREROUTING -s ! 192.168.1.0/24 \&lt;br /&gt;
   -m tcp -p tcp --dport $EXTPORT &lt;br /&gt;
   -j DNAT --to-destination $VHOST:$INTPORT&lt;br /&gt;
That's all!&lt;br /&gt;
&lt;br /&gt;
==Verifying==&lt;br /&gt;
Try &amp;lt;code&amp;gt;ping pool.ntp.org&amp;lt;/code&amp;gt; from your vserver -- it should ping fine.&lt;br /&gt;
&lt;br /&gt;
Try to connect to your &amp;lt;code&amp;gt;$EXTIP:$EXTPORT&amp;lt;/code&amp;gt; (from another external host) -- you will successfully connect to service running on a guest vserver.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Frequently_Asked_Questions#If_my_host_has_only_one_a_single_public_IP.2C_can_I_use_RFC1918_IP_.28e.g._192.168.foo.bar.29_for_the_guest_vservers.3F |FAQ on private networking]]&lt;br /&gt;
* [[Frequently_Asked_Questions#When_I_try_to_ssh_to_the_guest.2C_I_log_into_the_host.2C_even_if_I_installed_sshd_on_the_guest._What.27s_wrong_here.3F |Permit guest sshd to bind to its IP address's port 22]]&lt;br /&gt;
* [[Networking_vserver_guests_RHEL|Networking_vserver_guests_RHEL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;br /&gt;
[[Category:Network]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Capabilities_and_Flags</id>
		<title>Capabilities and Flags</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Capabilities_and_Flags"/>
				<updated>2010-02-15T13:39:35Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: /* Network context flags (nflags) */ slightly clearer explanation of hide_netif and hide_lback&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In computer science, a capability is a token used by a process to prove that it is allowed to perform an operation on an object. The Linux Capability System is based on &amp;quot;POSIX Capabilities&amp;quot;, a somewhat different concept, designed to split up the all powerful root privilege into a set of distinct privileges.&lt;br /&gt;
&lt;br /&gt;
== The Capability/Flag System ==&lt;br /&gt;
&lt;br /&gt;
=== POSIX Capabilities ===&lt;br /&gt;
&lt;br /&gt;
A process has three sets of bitmaps called the inheritable(I), permitted(P), and effective(E) capabilities. Each capability is implemented as a bit in each of these bitmaps that is either set or unset.&lt;br /&gt;
&lt;br /&gt;
When a process tries to do a privileged operation, the operating system will check the appropriate bit in the effective set of the process (instead of checking whether the effective uid of the process is 0 as is normally done). &lt;br /&gt;
&lt;br /&gt;
For example, when a process tries to set the clock, the Linux kernel will check that the process has the CAP_SYS_TIME bit (which is currently bit 25) set in its effective set. &lt;br /&gt;
&lt;br /&gt;
The permitted set of the process indicates the capabilities the process can use. The process can have capabilities set in the permitted set that are not in the effective set. &lt;br /&gt;
&lt;br /&gt;
This indicates that the process has temporarily disabled this capability. A process is allowed to set a bit in its effective set only if it is available in the permitted set. The distinction between effective and permitted exists so that processes can &amp;quot;bracket&amp;quot; operations that need privilege.&lt;br /&gt;
&lt;br /&gt;
The inheritable capabilities are the capabilities of the current process that should be inherited by a program executed by the current process. The permitted set of a process is masked against the inheritable set during exec(). Nothing special happens during fork() or clone(). Child processes and threads are given an exact copy of the capabilities of the parent process.&lt;br /&gt;
&lt;br /&gt;
The implementation in Linux stopped at this point, whereas POSIX Capabilities require the addition of capability sets to files too, to replace the SUID flag (at least for executables)&lt;br /&gt;
&lt;br /&gt;
=== Upper Bound for Capabilities ===&lt;br /&gt;
&lt;br /&gt;
Because the current Linux Capability system does not implement the filesystem related portions of POSIX Capabilities which would make setuid and setgid executables secure, and because it is much safer to have a secure upper bound for all processes within a context, an additional per-context capability mask has been added to limit all processes belonging to that context to this mask. &lt;br /&gt;
The meaning of the individual caps (bits) of the capability bound mask is exactly the same as with the permitted capability set.&lt;br /&gt;
&lt;br /&gt;
=== Context Capabilities ===&lt;br /&gt;
&lt;br /&gt;
As the Linux capabilities have almost reached the maximum number that is possible without heavy modifications to the kernel, it was a natural step to add a context-specific capability system.&lt;br /&gt;
&lt;br /&gt;
The Linux-VServer context capability set acts as a mechanism to fine tune existing Linux capabilities. It is not visible to the processes within a context, as they would not know how to modify or verify it.&lt;br /&gt;
&lt;br /&gt;
In general there are two ways to use those capabilities:&lt;br /&gt;
* Require one or a number of context capabilities to be set in addition to a given Linux capability, each one controlling a distinct part of the functionality. For example the CAP_NET_ADMIN could be split into RAW and PACKET sockets, so you could take away each of them separately by not providing the required context capability.&lt;br /&gt;
* Consider the context capability sufficient for a specified functionality, even if the Linux Capability says something different. For example mount() requires CAP_SYS_ADMIN which adds a dozen other things we do not want, so we define VXC_SECURE_MOUNT to allow mounts for certain contexts. &lt;br /&gt;
&lt;br /&gt;
The difference between the context flags and the context capabilities is more an abstract logical separation than a functional one, because they are handled in a very similar way.&lt;br /&gt;
&lt;br /&gt;
== List of capabilities/flags ==&lt;br /&gt;
&lt;br /&gt;
Below is a list of capabilities and flags used for contexts and processes within. The tables contain the following information:&lt;br /&gt;
&lt;br /&gt;
; Bit : The bit number to enable the capability/flag&lt;br /&gt;
; Mask : The bit number in hexadecimal notation&lt;br /&gt;
; Name : Human readable identifier used in userspace utilities&lt;br /&gt;
; Tag : Special capability/flag code to denote special behaviour, legacy usage and others (see below)&lt;br /&gt;
; Description : Description of capability/flag effects&lt;br /&gt;
&lt;br /&gt;
=== Special capability/flags codes ===&lt;br /&gt;
&lt;br /&gt;
The tag column may contain one or more of the following tags:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_inline&amp;quot;&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| I&lt;br /&gt;
| Internal use only&lt;br /&gt;
|-&lt;br /&gt;
| L&lt;br /&gt;
| Only supported with legacy enabled&lt;br /&gt;
|-&lt;br /&gt;
| O&lt;br /&gt;
| One time capability/flag (once it's cleared, it can't be re-enabled again)&lt;br /&gt;
|-&lt;br /&gt;
| U&lt;br /&gt;
| Unsupported&lt;br /&gt;
|-&lt;br /&gt;
| X&lt;br /&gt;
| Slightly different meaning in legacy&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Context capabilities (ccaps) ===&lt;br /&gt;
&lt;br /&gt;
The set of available context capabilities is specific to Linux-VServer and applied to all processes contained within a context. Below is a list of capabilities currently available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| SET_UTSNAME&lt;br /&gt;
|&lt;br /&gt;
| Allow setdomainname(2) and sethostname(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| SET_RLIMIT&lt;br /&gt;
|&lt;br /&gt;
| Allow setrlimit(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| FS_SECURITY&lt;br /&gt;
|&lt;br /&gt;
| Allow setxattr for security attributes &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| TIOCSTI&lt;br /&gt;
|&lt;br /&gt;
| Allow the tiocsti ioctl (fake input character)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| RAW_ICMP&lt;br /&gt;
| L&lt;br /&gt;
| Allow usage of raw ICMP sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 12&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00001000&lt;br /&gt;
| SYSLOG&lt;br /&gt;
|&lt;br /&gt;
| Allow syslog(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 13&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00002000&lt;br /&gt;
| OOM_ADJUST&lt;br /&gt;
|&lt;br /&gt;
| Allow 'safe' oom adjustments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 14&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00004000&lt;br /&gt;
| AUDIT_CONTROL&lt;br /&gt;
|&lt;br /&gt;
| Allow loginuid write (for auditing)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 16&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| SECURE_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow secure mount(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 17&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| SECURE_REMOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow secure remount&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 18&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| BINARY_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Allow binary/network mounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| QUOTA_CTL&lt;br /&gt;
|&lt;br /&gt;
| Allow quota ioctls&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00200000&lt;br /&gt;
| ADMIN_MAPPER&lt;br /&gt;
|&lt;br /&gt;
| Allow access to device mapper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00400000&lt;br /&gt;
| ADMIN_CLOOP&lt;br /&gt;
|&lt;br /&gt;
| Allow access to loop devices&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| KTHREAD&lt;br /&gt;
|&lt;br /&gt;
| Allow creating kernel threads&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 25&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| NAMESPACE&lt;br /&gt;
|&lt;br /&gt;
| Allow namespace related operations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Context flags (cflags) ===&lt;br /&gt;
&lt;br /&gt;
The set of available context flags is specific to Linux-VServer and applied to all processes contained within a context. Below is a list of flags available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| INFO_LOCK&lt;br /&gt;
| L&lt;br /&gt;
| Prohibit further context migration&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| INFO_SCHED&lt;br /&gt;
| L&lt;br /&gt;
| Account all processes as one&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| INFO_NPROC&lt;br /&gt;
| L&lt;br /&gt;
| Apply process limits to context&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| INFO_PRIVATE&lt;br /&gt;
| L&lt;br /&gt;
| Context cannot be entered&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| INFO_INIT&lt;br /&gt;
| X&lt;br /&gt;
| Show a fake init process&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 5&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000020&lt;br /&gt;
| INFO_HIDE&lt;br /&gt;
| X&lt;br /&gt;
| Hide context information in task status&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 6&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000040&lt;br /&gt;
| INFO_ULIMIT&lt;br /&gt;
| L&lt;br /&gt;
| Apply ulimits to context&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 7&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000080&lt;br /&gt;
| INFO_NSPACE&lt;br /&gt;
| L&lt;br /&gt;
| Use private namespace&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SCHED_HARD&lt;br /&gt;
|&lt;br /&gt;
| Enable hard scheduler&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| SCHED_PRIO&lt;br /&gt;
|&lt;br /&gt;
| Enable priority scheduler&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| SCHED_PAUSE&lt;br /&gt;
|&lt;br /&gt;
| Pause context (unschedule)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| VIRT_MEM&lt;br /&gt;
|&lt;br /&gt;
| Virtualize memory information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| VIRT_UPTIME&lt;br /&gt;
|&lt;br /&gt;
| Virtualize uptime information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| VIRT_CPU&lt;br /&gt;
|&lt;br /&gt;
| Virtualize cpu usage information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 23&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00080000&lt;br /&gt;
| VIRT_LOAD&lt;br /&gt;
|&lt;br /&gt;
| Virtualize load average information&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| VIRT_TIME&lt;br /&gt;
|&lt;br /&gt;
| Allow per guest time offsets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 28&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| HIDE_MOUNT&lt;br /&gt;
|&lt;br /&gt;
| Hide entries in /proc/$pid/mounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| HIDE_NETIF&lt;br /&gt;
| L&lt;br /&gt;
| Hide foreign network interfaces&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| HIDE_VINFO&lt;br /&gt;
|&lt;br /&gt;
| Hide context information in task status&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 32&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_SETUP&lt;br /&gt;
| IO&lt;br /&gt;
| Enable setup state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 33&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0002&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_INIT&lt;br /&gt;
| IO&lt;br /&gt;
| Enable init state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 34&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0004&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_ADMIN&lt;br /&gt;
| O&lt;br /&gt;
| Enable admin state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 36&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;32&lt;br /&gt;
| SC_HELPER&lt;br /&gt;
| I&lt;br /&gt;
| Enable state change helper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 37&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0020&amp;lt;&amp;lt;32&lt;br /&gt;
| REBOOT_KILL&lt;br /&gt;
|&lt;br /&gt;
| Kill all processes on reboot(2)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 38&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0040&amp;lt;&amp;lt;32&lt;br /&gt;
| PERSISTENT&lt;br /&gt;
|&lt;br /&gt;
| Make context persistent&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 48&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;48&lt;br /&gt;
| FORK_RSS&lt;br /&gt;
|&lt;br /&gt;
| Block fork when RSS limit is exceeded&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 49&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0002&amp;lt;&amp;lt;48&lt;br /&gt;
| PROLIFIC&lt;br /&gt;
|&lt;br /&gt;
| Allow context to create new contexts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 52&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;48&lt;br /&gt;
| IGNEG_NICE&lt;br /&gt;
|&lt;br /&gt;
| Ignore priority raise&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Network context flags (nflags) ===&lt;br /&gt;
&lt;br /&gt;
The set of available network context flags is specific to Linux-VServer and applied to all processes contained within a network context. Below is a list of flags available in 2.1.1 and above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Tag&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| INFO_LOCK&lt;br /&gt;
| L&lt;br /&gt;
| Prohibit further context migration&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| INFO_PRIVATE&lt;br /&gt;
| &lt;br /&gt;
| Context cannot be entered&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SINGLE_IP&lt;br /&gt;
|&lt;br /&gt;
| Enable special handling of network contexts with a single IP only&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| LBACK_REMAP&lt;br /&gt;
|&lt;br /&gt;
| use loopback-virtualisation (will only work in 2.3.0.xx or greater)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| LBACK_ALLOW&lt;br /&gt;
|&lt;br /&gt;
| if set, allows guests without LBACK_REMAP to connect to 127.0.0.0/8&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| HIDE_NETIF&lt;br /&gt;
|&lt;br /&gt;
| Hide foreign network interfaces (ie: network interfaces not carrying and IP belonging to the guest)&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| HIDE_LBACK&lt;br /&gt;
|&lt;br /&gt;
| hides the real loopback-address from the guest (rewrites to 127.0.0.1 when queried) (will only work in 2.3.0.xx or greater)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 32&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0001&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_SETUP&lt;br /&gt;
| IO&lt;br /&gt;
| Enable setup state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 34&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0004&amp;lt;&amp;lt;32&lt;br /&gt;
| STATE_ADMIN&lt;br /&gt;
| O&lt;br /&gt;
| Enable admin state&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 36&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0010&amp;lt;&amp;lt;32&lt;br /&gt;
| SC_HELPER&lt;br /&gt;
| I&lt;br /&gt;
| Enable state change helper&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 38&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x0040&amp;lt;&amp;lt;32&lt;br /&gt;
| PERSISTENT&lt;br /&gt;
|&lt;br /&gt;
| Make network context persistent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== System capabilities (bcaps) ===&lt;br /&gt;
&lt;br /&gt;
The set of available system capabilities is inherited from the Linux kernel and applied to all processes contained within a context. Below is a list of capabilities currently available in the vanilla kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color: red; font-weight: bold;&amp;quot;&amp;gt;&lt;br /&gt;
BIG FAT WARNING: Adding any system capability to your virtual server WILL reduce security. Do not change the default values unless you absolutely know what you are doing!&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable_list&amp;quot;&lt;br /&gt;
! Bit&lt;br /&gt;
! Mask&lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 0&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000001&lt;br /&gt;
| CHOWN&lt;br /&gt;
| In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this overrides the restriction of changing file ownership and group ownership.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 1&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000002&lt;br /&gt;
| DAC_OVERRIDE&lt;br /&gt;
| Override all DAC access, including ACL execute access if [_POSIX_ACL] is defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 2&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000004&lt;br /&gt;
| DAC_READ_SEARCH&lt;br /&gt;
| Overrides all DAC restrictions regarding read and search on files and directories, including ACL restrictions if [_POSIX_ACL] is defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 3&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000008&lt;br /&gt;
| FOWNER&lt;br /&gt;
| Overrides all restrictions about allowed operations on files, where file owner ID must be equal to the user ID, except where CAP_FSETID is applicable. It doesn't override MAC and DAC restrictions.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 4&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000010&lt;br /&gt;
| FSETID&lt;br /&gt;
| Overrides the following restrictions that the effective user ID shall match the file owner ID when setting the S_ISUID and S_ISGID bits on that file; that the effective group ID (or one of the supplementary group IDs) shall match the file owner ID when setting the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are cleared on successful return from chown(2) (not implemented).&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 5&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000020&lt;br /&gt;
| KILL&lt;br /&gt;
| Overrides the restriction that the real or effective user ID of a process sending a signal must match the real or effective user ID of the process receiving the signal.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 6&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000040&lt;br /&gt;
| SETGID&lt;br /&gt;
|&lt;br /&gt;
* Allows setgid(2) manipulation&lt;br /&gt;
* Allows setgroups(2)&lt;br /&gt;
* Allows forged gids on socket credentials passing.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 7&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000080&lt;br /&gt;
| SETUID&lt;br /&gt;
|&lt;br /&gt;
* Allows set*uid(2) manipulation (including fsuid).&lt;br /&gt;
* Allows forged pids on socket credentials passing.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 8&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000100&lt;br /&gt;
| SETPCAP&lt;br /&gt;
| Transfer any capability in your permitted set to any pid, remove any capability in your permitted set from any pid&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 9&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000200&lt;br /&gt;
| LINUX_IMMUTABLE&lt;br /&gt;
| Allow modification of S_IMMUTABLE and S_APPEND file attributes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 10&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000400&lt;br /&gt;
| NET_BIND_SERVICE&lt;br /&gt;
|&lt;br /&gt;
* Allows binding to TCP/UDP sockets below 1024&lt;br /&gt;
* Allows binding to ATM VCIs below 32&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 11&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00000800&lt;br /&gt;
| NET_BROADCAST&lt;br /&gt;
| Allow broadcasting, listen to multicast&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 12&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00001000&lt;br /&gt;
| NET_ADMIN&lt;br /&gt;
|&lt;br /&gt;
* Allow interface configuration&lt;br /&gt;
* Allow administration of IP firewall, masquerading and accounting&lt;br /&gt;
* Allow setting debug option on sockets&lt;br /&gt;
* Allow modification of routing tables&lt;br /&gt;
* Allow setting arbitrary process / process group ownership on sockets&lt;br /&gt;
* Allow binding to any address for transparent proxying&lt;br /&gt;
* Allow setting TOS (type of service)&lt;br /&gt;
* Allow setting promiscuous mode&lt;br /&gt;
* Allow clearing driver statistics&lt;br /&gt;
* Allow multicasting&lt;br /&gt;
* Allow read/write of device-specific registers&lt;br /&gt;
* Allow activation of ATM control sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 13&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00002000&lt;br /&gt;
| NET_RAW&lt;br /&gt;
|&lt;br /&gt;
* Allow use of RAW sockets&lt;br /&gt;
* Allow use of PACKET sockets&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 14&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00004000&lt;br /&gt;
| IPC_LOCK&lt;br /&gt;
|&lt;br /&gt;
* Allow locking of shared memory segments&lt;br /&gt;
* Allow mlock and mlockall (which doesn't really have anything to do with IPC)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 15&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00008000&lt;br /&gt;
| IPC_OWNER&lt;br /&gt;
| Override IPC ownership checks&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 16&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00010000&lt;br /&gt;
| SYS_MODULE&lt;br /&gt;
|&lt;br /&gt;
* Insert and remove kernel modules - modify kernel without limit&lt;br /&gt;
* Modify cap_bset&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 17&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00020000&lt;br /&gt;
| SYS_RAWIO&lt;br /&gt;
|&lt;br /&gt;
* Allow ioperm/iopl access&lt;br /&gt;
* Allow sending USB messages to any device via /proc/bus/usb&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 18&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00040000&lt;br /&gt;
| SYS_CHROOT&lt;br /&gt;
| Allow use of chroot()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 19&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00080000&lt;br /&gt;
| SYS_PTRACE&lt;br /&gt;
| Allow ptrace() of any process&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 20&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00100000&lt;br /&gt;
| SYS_PACCT&lt;br /&gt;
| Allow configuration of process accounting&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 21&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00200000&lt;br /&gt;
| SYS_ADMIN&lt;br /&gt;
|&lt;br /&gt;
* Allow configuration of the secure attention key&lt;br /&gt;
* Allow administration of the random device&lt;br /&gt;
* Allow examination and configuration of disk quotas&lt;br /&gt;
* Allow configuring the kernel's syslog (printk behaviour)&lt;br /&gt;
* Allow setting the domainname&lt;br /&gt;
* Allow setting the hostname&lt;br /&gt;
* Allow calling bdflush()&lt;br /&gt;
* Allow mount() and umount(), setting up new smb connection&lt;br /&gt;
* Allow some autofs root ioctls&lt;br /&gt;
* Allow nfsservctl&lt;br /&gt;
* Allow VM86_REQUEST_IRQ&lt;br /&gt;
* Allow to read/write pci config on alpha&lt;br /&gt;
* Allow irix_prctl on mips (setstacksize)&lt;br /&gt;
* Allow flushing all cache on m68k (sys_cacheflush)&lt;br /&gt;
* Allow removing semaphores (Used instead of CAP_CHOWN to &amp;quot;chown&amp;quot; IPC message queues, semaphores and shared memory)&lt;br /&gt;
* Allow locking/unlocking of shared memory segment&lt;br /&gt;
* Allow turning swap on/off&lt;br /&gt;
* Allow forged pids on socket credentials passing&lt;br /&gt;
* Allow setting readahead and flushing buffers on block devices&lt;br /&gt;
* Allow setting geometry in floppy driver&lt;br /&gt;
* Allow turning DMA on/off in xd driver&lt;br /&gt;
* Allow administration of md devices (mostly the above, but some extra ioctls)&lt;br /&gt;
* Allow tuning the ide driver&lt;br /&gt;
* Allow access to the nvram device&lt;br /&gt;
* Allow administration of apm_bios, serial and bttv (TV) device&lt;br /&gt;
* Allow manufacturer commands in isdn CAPI support driver&lt;br /&gt;
* Allow reading non-standardized portions of pci configuration space&lt;br /&gt;
* Allow DDI debug ioctl on sbpcd driver&lt;br /&gt;
* Allow setting up serial ports&lt;br /&gt;
* Allow sending raw qic-117 commands&lt;br /&gt;
* Allow enabling/disabling tagged queuing on SCSI controllers and sending arbitrary SCSI commands&lt;br /&gt;
* Allow setting encryption key on loopback filesystem&lt;br /&gt;
* Allow setting zone reclaim policy&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 22&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00400000&lt;br /&gt;
| SYS_BOOT&lt;br /&gt;
| Allow use of reboot()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 23&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x00800000&lt;br /&gt;
| SYS_NICE&lt;br /&gt;
|&lt;br /&gt;
* Allow raising priority and setting priority on other (different UID) processes&lt;br /&gt;
* Allow use of FIFO and round-robin (realtime) scheduling on own processes and setting the scheduling algorithm used by another process.&lt;br /&gt;
* Allow setting cpu affinity on other processes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 24&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x01000000&lt;br /&gt;
| SYS_RESOURCE&lt;br /&gt;
|&lt;br /&gt;
* Override resource limits. Set resource limits.&lt;br /&gt;
* Override quota limits.&lt;br /&gt;
* Override reserved space on ext2 filesystem&lt;br /&gt;
* Modify data journaling mode on ext3 filesystem (uses journaling resources)&lt;br /&gt;
* ''NOTE:'' ext2 honors fsuid when checking for resource overrides, so you can override using fsuid too&lt;br /&gt;
* Override size restrictions on IPC message queues&lt;br /&gt;
* Allow more than 64hz interrupts from the real-time clock&lt;br /&gt;
* Override max number of consoles on console allocation&lt;br /&gt;
* Override max number of keymaps&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 25&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x02000000&lt;br /&gt;
| SYS_TIME&lt;br /&gt;
|&lt;br /&gt;
* Allow manipulation of system clock&lt;br /&gt;
* Allow irix_stime on mips&lt;br /&gt;
* Allow setting the real-time clock&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 26&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x04000000&lt;br /&gt;
| SYS_TTY_CONFIG&lt;br /&gt;
|&lt;br /&gt;
* Allow configuration of tty devices&lt;br /&gt;
* Allow vhangup() of tty&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 27&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x08000000&lt;br /&gt;
| MKNOD&lt;br /&gt;
| Allow the privileged aspects of mknod()&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 28&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x10000000&lt;br /&gt;
| LEASE&lt;br /&gt;
| Allow taking of leases on files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 29&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x20000000&lt;br /&gt;
| AUDIT_WRITE&lt;br /&gt;
| ??&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: right&amp;quot; | 30&lt;br /&gt;
| style=&amp;quot;font-family: monospace&amp;quot; | 0x40000000&lt;br /&gt;
| AUDIT_CONTROL&lt;br /&gt;
| ??&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Setting flags and capabilities ==&lt;br /&gt;
To see how to set the flags and capabilities, see [[util-vserver:Capabilities and Flags]] if you're using util-vserver.&lt;br /&gt;
&lt;br /&gt;
If you would like to edit those flags without restarting the vservers, you can use vattribute and nattribute. See [[util-vserver:Cheatsheet]]&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	<entry>
		<id>http://www.linux-vserver.at/Frequently_Asked_Questions</id>
		<title>Frequently Asked Questions</title>
		<link rel="alternate" type="text/html" href="http://www.linux-vserver.at/Frequently_Asked_Questions"/>
				<updated>2010-02-15T10:55:54Z</updated>
		
		<summary type="html">&lt;p&gt;Bobnormal: add new MAC per vServer info from _are_ on IRC&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;margin: 2em auto 2em auto; padding: 10px; background-color: #F9ECCD; border: 1px solid #004433; text-align: center;&amp;quot;&amp;gt;&lt;br /&gt;
[[Image:Icon-Caution.png|left]]&lt;br /&gt;
We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the [[Wiki Team]] page for instructions how to help or look at the [http://oldwiki.linux-vserver.org old wiki] to find the information not migrated yet.&lt;br /&gt;
&lt;br /&gt;
'''To ease migration we created a [[List of old Documentation pages]].'''&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
CURRENTLY THE CONTENT OF THE OLD WIKI FAQ (AND MORE) IS BEING MIGRATED TO THIS PAGE (TASK: DERJOHN)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is a 'Guest'?&lt;br /&gt;
||Details=To talk about stuff, we need some naming. The physical machine is called 'Host' and the 'main' context running the Host Distro is called 'Host Context'. The virtual machine/distro is called 'Guest' and basically is a Distribution (Userspace) running inside a 'Guest Context'.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What kind of Operating System (OS) can I run as guest?&lt;br /&gt;
||Details= With VServer you can only run Linux guests. The trick is that a guest does not run a kernel on its own (as XEN and UML do), it merely uses a virtualized host kernel-interface. VServer offers so called security contexts which make it possible to separate one guest from each other, i.e. they cannot get data from each other. Imagine it as a chroot environment with much more security and features.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is this a new project? When was it started?&lt;br /&gt;
||Details=The first public occurrence of Linux-VServer was Oct 2001. The initial mail can be found here: http://www.cs.helsinki.fi/linux/linux-kernel/2001-40/1065.html&lt;br /&gt;
So you can expect a mature software product which does its magic quite well (And hey, we have a version &amp;gt; 2.0!)&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Which distributions did you test?&lt;br /&gt;
||Details=Some. Check out the wiki for ready-made guest images. But you can easily build own guest images, e.g. with Debian's debootstrap. Checkout [[Building Guest Systems]] how to do that.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is VServer comparable to XEN/UML/QEMU?&lt;br /&gt;
||Details=Nope. XEN/UML/QEMU and VServer are just good friends. Because you ask, you probably know what XEN/UML/QEMU are. VServer in contrary to XEN/UML/QEMU does not &amp;quot;emulate&amp;quot; any hardware you run a kernel on. The purpose of Linux VServer is to isolate (groups of) applications.  The isolation is done by the kernel (see [[Overview]] for a more detailed comparison). You can run a VServer kernel in a XEN/UML/QEMU guest. This is confirmed to work at least with Linux 2.6/vs2.0.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=With which version should I begin?&lt;br /&gt;
||Details=If you are new to VServer I recommend to try the latest stable kernel patch, and the latest util-vserver &amp;quot;alpha&amp;quot; release.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is VServer secure?&lt;br /&gt;
||Details=We hope so. It should be as least as secure as Linux is. We consider it much much more secure though.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Performance?&lt;br /&gt;
||Details=For a single guest, we basically have native performance. Some tests showed insignificant overhead (about 1-2%) others ran faster than on an unpatched kernel. This is IMVHO significantly less than other solutions waste, especially if you have more than a single guest (because of the resource sharing).&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is the &amp;quot;great flower page&amp;quot;?&lt;br /&gt;
||Details=Well, [http://www.nongnu.org/util-vserver/doc/conf/configuration.html this page] contains all configuration options for util-vserver. The name of the page is derived from the stylesheet(s) it contains.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Resources usage ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Resource sharing?&lt;br /&gt;
||Details=Yes ....&lt;br /&gt;
* memory: Dynamically.&lt;br /&gt;
* CPU usage: Dynamically (token bucket)&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Resource limiting?&lt;br /&gt;
||Details=You can put limits per guest on different subsystems.&lt;br /&gt;
* using ulimits and rlimits (rlimit is a new feature of kernel 2.6/vs2.0.) per guest, to limit the memory consumption, the number of processes or file-handles, ... : see [[Resource Limits]]&lt;br /&gt;
* CPU usage : see [[CPU Scheduler]]&lt;br /&gt;
* disk space usage : see [[Disk Limits and Quota]]&lt;br /&gt;
Note that you can only offer guaranteed resource availability with some ticks at the time.&lt;br /&gt;
|Signature=derjohn&amp;amp;xm}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I limit a guests RAM? I want to prevent OOM situations on the host!&lt;br /&gt;
||Details=First you can read [http://linux-vserver.org/Memory+Allocation] and [[Memory Limits]].&lt;br /&gt;
If you want a recipe, do this:&lt;br /&gt;
# Check the size of memory pages. On x86 and x86_64 is usually 4 KB per page.&lt;br /&gt;
# Create /etc/vserver/&amp;lt;guest&amp;gt;/rlimits/&lt;br /&gt;
# Check your physical memory size on the host, e.g. with &amp;quot;free -m&amp;quot;. maxram = kilobytes/pagesize.&lt;br /&gt;
# Limit the guests physical RAM to value smaller then maxram:&amp;lt;pre&amp;gt;echo %%insertYourPagesHereSmallerThanMaxram%% &amp;gt; /etc/vserver/&amp;lt;guest&amp;gt;/rlimits/rss &amp;lt;/pre&amp;gt;&lt;br /&gt;
# Check your swapspace, e.g. with 'swapon -s'. maxswap = swapkilobytes/pagesize.&lt;br /&gt;
# Limit the guest's maximum number of as pages to a value smaller than (maxram+maxswap): &amp;lt;pre&amp;gt; echo %%desiredvalue%% &amp;gt; /etc/vserver/&amp;lt;guest&amp;gt;/rlimits/as &amp;lt;/pre&amp;gt;&lt;br /&gt;
# Correctly display the memory information inside the guest:&amp;lt;pre&amp;gt;echo &amp;quot;VIRT_MEM&amp;quot; &amp;gt;&amp;gt; /etc/vservers/&amp;lt;guest&amp;gt;/flags&amp;lt;/pre&amp;gt;&lt;br /&gt;
It should be clear this can still lead to OOM situations. Example: You have two guests and your as limit per guest is greater than 50% of (maxram+maxswap). If both guests request their maximum at the same point in time, there will be not enough mem .....&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Disk I/O limiting? Is that possible?&lt;br /&gt;
||Details=Well, since vs2.1.1 Linux-VServer supports a mechanism called 'I/O scheduling', which appeared in the 2.6 mainline some time ago. The mainline kernel offers several I/O schedulers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat /sys/block/hdc/queue/scheduler&lt;br /&gt;
noop [anticipatory] deadline cfq&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default is anticipatory a.k.a. &amp;quot;AS&amp;quot;. When running several guests on a host you probably want the I/O performance shared in a fair way among the different guests. The kernel comes with a &amp;quot;completely fair queueing&amp;quot; scheduler, CFQ, which can do that. (More on schedulers can be found at http://lwn.net/Articles/114770/)&lt;br /&gt;
This is how to set the scheduler to &amp;quot;cfq&amp;quot; manually:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root# echo &amp;quot;cfq&amp;quot; &amp;gt; /sys/block/hdc/queue/scheduler&lt;br /&gt;
root# cat /sys/block/hdc/queue/scheduler&lt;br /&gt;
noop anticipatory deadline [cfq]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Keep in mind that you have to do it on all physical discs. So if you run an md-softraid, do it to all physical /dev/hdXYZ discs!&lt;br /&gt;
If you run Debian there is a predefined way to set the /sys values at boot-time:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apt-get install sysfsutils&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
# grep cfq /etc/sysfs.conf&lt;br /&gt;
block/sda/queue/scheduler = cfq&lt;br /&gt;
block/sdc/queue/scheduler = cfq&lt;br /&gt;
&lt;br /&gt;
# /etc/init.d/sysfsutils restart&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For non-vserver processes and CFQ you can set by which key the kernel decides about the fairness:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /sys/block/hdc/queue/iosched/key_type&lt;br /&gt;
pgid [tgid] uid gid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Hint: The 'key_type'-feature has been removed in the mainline kernel recently. Don't look for it any longer :(&lt;br /&gt;
&lt;br /&gt;
The default is tgid, which means to share fairly among process groups. Think every guest is treated like a own process group. It's not possible to set a scheduler strategy within a guest. All processes belonging to the same guest are treated like &amp;quot;noop&amp;quot; within the guest. So: If you run apache and some ftp-server within the _same_ guest, there is no fair scheduling between them, but there is fair scheduling between the whole guest and all other guests.&lt;br /&gt;
&lt;br /&gt;
And: It's possible to tune the scheduler parameters in several ways. Have a look at /sys/block/hdc/queue/....&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Nice disk I/O scheduling, is that possible?&lt;br /&gt;
||Details=Well, since linux 2.6.13 processess have another priority next to the cpu nice scheduling hint, it's called io nice.&lt;br /&gt;
It's split into three groups, called real-time, best effort and idle. The default is best-effort, but within best-effort, you can have a niceness from 0 to and including 7.&lt;br /&gt;
You can set this niceness by the tool ionice, which for debian is either in the package util-linux or schedutils.&lt;br /&gt;
To change the io-niceness you need the &amp;lt;tt&amp;gt;CAP_SYS_NICE&amp;lt;/tt&amp;gt;, '''and''' need to have the same uid as the processe you want to ionice.&lt;br /&gt;
&lt;br /&gt;
:'''Note:''' If you want to use any schedulung other than best-effort you will also need the &amp;lt;tt&amp;gt;CAP_SYS_ADMIN&amp;lt;/tt&amp;gt;-flag. Be warned that this gives quite some capabilities to the vserver, not just for I/O scheduling!&lt;br /&gt;
&lt;br /&gt;
If you want to increase the niceness of an I/O hogging process within a vserver you need to do:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
chcontext --xid sponlp1 sudo -u '#2089' ionice -c2 -n5 -p24409&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
with sudo and ionice installed on the root server to increase the *nice*ness of pid 24409, with uid 2089&lt;br /&gt;
|Signature=Groteblup}}&lt;br /&gt;
&lt;br /&gt;
== Unification ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is unification (vunify)?&lt;br /&gt;
||Details=Unification is Hard Links on Steroids. Guests can 'share' common files (usually binaries and libraries) in a secure way, by creating hard links with special properties (immutable but unlinkable (removable)). The tool to identify common files and to unify them is called vunify.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is vhashify?&lt;br /&gt;
||Details=The successor of vunify, a tool which does unification based on hash values (which allows to find common files in arbitrary paths.)&lt;br /&gt;
It creates hardlinks to files named after a hash of the content of the file. If you have a recent version of the vserver patch (2.2+), with CONFIG_VSERVER_COWBL enabled, you can even modify the hardlinked files inside the vservers and the links will be broken automatically.&lt;br /&gt;
There seems to be a catch when a hashified file has multiple hardlinks inside a guest, or when another internal hardlink is added after hashification. Link breaking will remove all the internal hardlinks too, so the guest will end up with different copies of the original file. The correct solution would be to not hashify files that have multiple links prior to hashification, and to break the link to the hashified version when a new internal hardlink is created. Apparently, this is not implemented yet (?).&lt;br /&gt;
|Signature=Guy-}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I manage a multi-guest setup with vhashify?&lt;br /&gt;
||Details=For 'vhashify', just do these once:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/.defaults/apps/vunify/hash /vservers/.hash&lt;br /&gt;
ln -s /vservers/.hash /etc/vservers/.defaults/apps/vunify/hash/root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, do this one line per vserver:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir /etc/vservers/&amp;lt;vservername&amp;gt;/apps/vunify   # vhashify reuses vunify configuration&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To hashify a running vserver, do (possibly from a cronjob):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver name-of-guest hashify&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The guest needs to be running because vhashify tries to figure out what files not to hashify by calling the package manager of the guest via &amp;lt;tt&amp;gt;vserver enter&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order for the OS cache to benefit from the hardlinking, you'll have to restart the vservers.&lt;br /&gt;
&lt;br /&gt;
To clean up hashified files that are no longer referenced by any vserver, do (possibly from a cronjob):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
find /vservers/.hash -type f -links 1 -print0 | xargs -0 rm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Until you do this, the files still take up place even though no vservers need them.&lt;br /&gt;
|Signature=Guy-}}&lt;br /&gt;
&lt;br /&gt;
== Filesystem usage ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is there a way to implement &amp;quot;user/group quota&amp;quot; per VServer?&lt;br /&gt;
||Details=Yes, but not on a shared partition for now. You need to put the guest on a separate partition, setup a vroot device (to make the quota access secure), copy that into the guest, and adjust the mtab line inside the guest. If 8 vroot device is not enough for you, you can add more with the kernel parameter max_vroot (exemple for built in kernel vroot /vmlinuz-2.6.31.6-vs2.3.0.36.26aq root=/dev/md1 ro max_vroot=20 ). If vroot is a module you'd actually want to put for exemple &amp;quot;options vroot max_vroot=20&amp;quot; in /etc/modprobe.conf and then just do modprobe vroot&lt;br /&gt;
|Signature=derjohn,gadnet}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What about &amp;quot;Quota&amp;quot; for a context? Howto limit disk usage?&lt;br /&gt;
||Details=Context quotas are now called Disk Limits (so that we can tell them apart from the user/group quotas :). They are supported out of the box (with vs2.0+) for all major filesystems (ext2/3, ReiserFS, JFS). You need to tag the FS with XID (see below). Please read [[Disk Limits and Quota]] for more information.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I tag a guest's directory with xid?&lt;br /&gt;
||Details=Tagging the guest's files gives you several advantages, e.g. the accounting will work properly.&lt;br /&gt;
Filesystem XID tagging only works on supported filesystem. Those are currently: ext2/3, reiserfs/reiser3, xfs and jfs.&lt;br /&gt;
To activate the XID tagging you have to mount the filesystem with &amp;quot;-o tag&amp;quot; (former tagxid is outdated since VS2.2). Attention: It's _not_ possible to &amp;quot;-o remount,tag&amp;quot;, you have to mount it freshly. The guests will tag their files automatiaclly. If you copy files in from the host, you have to tag them manually like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
chxid -c xid -R /var/lib/vservers/&amp;lt;guest&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note: Context 0 and 1 will see all files, guests will only be able to access untagged files and their own XID. They can see other XID files but no information about the file, e.g. no owner, no group, no permissions.&lt;br /&gt;
Note: It is not advised to tag the root filesystem, as [http://www.paul.sladen.org/vserver/archives/200602/0020.html explained by Herbert] : trying to do so will expose you to some troubles !&lt;br /&gt;
|Signature=derjohn_and_gonzo_and_are}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How can I copy anything from host to guest partition, normally unvisible on host?&lt;br /&gt;
||Details=You should just change namespace, e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vnamespace --enter &amp;lt;xid&amp;gt; -- /bin/bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and then use standard cp or rsync programs.&lt;br /&gt;
|Signature=SergiuszPawlowicz}}&lt;br /&gt;
&lt;br /&gt;
== Network ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Does it support IPv6?&lt;br /&gt;
||Details=Currently it requires an additional patch, but the functionality should be available in 2.3+ soon. [[IPv6]] has more information.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I can't do all I want with the network interfaces inside the guest?&lt;br /&gt;
||Details=For now the networking is 'Host Business' -- the host is a router, and each guest is a server. You can set the capability ICMP_RAW in the context of the guest, or even the capability CAP_NET_RAW (which would even allow to sniff interfaces of other guests!). Likely to change with ngnet.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I add several IPs to a vserver?&lt;br /&gt;
||Details=First of all a single guest vserver only supports up to 16 IPs (There is a 64-IP patch available, which is in &amp;quot;derjohn's kernel&amp;quot;).&lt;br /&gt;
Here is a little helper-script that adds a list of IPs defined in a text file, one per line.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
j=1&lt;br /&gt;
for i in `cat myiplist`; do&lt;br /&gt;
        j=$(($j+1))&lt;br /&gt;
        mkdir $j&lt;br /&gt;
        echo $i &amp;gt; $j/ip&lt;br /&gt;
        echo &amp;quot;24&amp;quot; &amp;gt; $j/prefix&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I assign a new IP address to a running guest?&lt;br /&gt;
||Details=This is done from the host server:&lt;br /&gt;
* add the ip on the host, for example&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ip addr add 194.169.123.23/24 dev eth0 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* add the ip to the guest's network context (a guests NID is the same as the XID {context ID})&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
naddress --add --nid &amp;lt;nid&amp;gt; --ip 194.169.123.23/24 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enter the guest (best via ssh) &lt;br /&gt;
* restart the services that need to make use of the new address if required &lt;br /&gt;
* update the config in ''/etc/vserver/&amp;lt;servername&amp;gt;/interfaces'' to reflect the changes for the next guest restart (if desired)&lt;br /&gt;
|Signature=BenjaminGreen}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=If my host has only one a single public IP, can I use RFC1918 IP (e.g. 192.168.foo.bar) for the guest vservers?&lt;br /&gt;
||Details=Yes, use iptables with SNAT to masquerade it. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
iptables -t nat -I POSTROUTING -s $VSERVER_NETZ  ! -d $VSERVER_NETZ -j SNAT --to $EXT_IP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
See: [[HowtoPrivateNetworking]] and &lt;br /&gt;
http://www.tgunkel.de/it/software/doc/linux_server.en#h3-VServer_Masquerading_SNAT (THX, [MUPPETS]Gonzo)&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=If I shut down my vserver guest, the whole Internet interface ethX on the host is shut down.  What happened?&lt;br /&gt;
||Details=When you shut down a guest (''i.e. vserver foo stop''), the IP is brought down on the host also. If this IP happens to be the primary IP of the host, the kernel will not only bring down the primary IP, but also all secondary IP addresses. But in very recent kernels, there is an option ''settable'' which prevents that nasty feature. It's called &amp;quot;alias promotion&amp;quot;. You may set it via sysctl by adding ''net.ipv4.conf.all.promote_secondaries=1'' in /etc/sysctl.conf or via sysctl command line.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Can I run an OpenVPN Server in a guest?&lt;br /&gt;
||Details=&lt;br /&gt;
Yes. To get a OpenVPN Server running in a guest, all networking setup has to be done on the host. This answer describes the common case and shows some pitfalls, for detailled information about OpenVPN, please consult the appropriate documentation on the OpenVPN homepage.&lt;br /&gt;
This is the minimal OpenVPN configuration for the Server which will be used to demonstrate how to get it running in a client:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Networking setup&lt;br /&gt;
server 192.168.16.0     255.255.255.0&lt;br /&gt;
dev tun16&lt;br /&gt;
ifconfig-noexec&lt;br /&gt;
comp-lzo&lt;br /&gt;
# Certificates&lt;br /&gt;
dh ...&lt;br /&gt;
ca ...&lt;br /&gt;
cert ...&lt;br /&gt;
key ...&lt;br /&gt;
# Management&lt;br /&gt;
persist-key&lt;br /&gt;
keepalive 10 60&lt;br /&gt;
verb 4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First of all you have to prepare the host with a persistent interface in the right mode and with the right settings. This is easily done by using openvpn and the ip and route tools.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# openvpn --mktun --dev tun16&lt;br /&gt;
# ip link set dev tun16 txqueuelen 100&lt;br /&gt;
# ifconfig tun16 192.168.16.1 pointopoint 192.168.16.2 mtu 1500&lt;br /&gt;
# route add -net 192.168.16.0 netmask 255.255.255.0 gw 192.168.16.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you need different settings, openvpn will tell you the ifconfig and route commands it uses to configure the interface when being started on the host with the original config file, but without ifconfig-noexec.&lt;br /&gt;
Additionally, the guest needs /dev/net/tun to make OpenVPN happy. This can be created with MAKEDEV:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /var/lib/vserver/&amp;lt;myopenvpnserver&amp;gt;/dev/&lt;br /&gt;
# ./MAKEDEV tun&lt;br /&gt;
  (creates the dev/net/tun device accessible by the guest - even a tap interface needs /dev/net/tun !)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, the guest needs to have the tun device assigned:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# head /etc/vservers/&amp;lt;myopenvpnserver&amp;gt;/interfaces/1/*&lt;br /&gt;
==&amp;gt; /etc/vservers/&amp;lt;myopenvpnserver&amp;gt;/interfaces/1/ip &amp;lt;==&lt;br /&gt;
192.168.16.1&lt;br /&gt;
&lt;br /&gt;
==&amp;gt; /etc/vservers/&amp;lt;myopenvpnserver&amp;gt;/interfaces/1/nodev &amp;lt;==&lt;br /&gt;
tun16&lt;br /&gt;
&lt;br /&gt;
==&amp;gt; /etc/vservers/&amp;lt;myopenvpnserver&amp;gt;/interfaces/1/prefix &amp;lt;==&lt;br /&gt;
24&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The client's conf may look like that:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Basic setup&lt;br /&gt;
client&lt;br /&gt;
proto tcp-client&lt;br /&gt;
dev tun&lt;br /&gt;
remote &amp;lt;ipaddress&amp;gt;&lt;br /&gt;
comp-lzo&lt;br /&gt;
verb 4&lt;br /&gt;
&lt;br /&gt;
# Certificate&lt;br /&gt;
ca ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[ Based on derJohn's original answer, all errors mine ] &lt;br /&gt;
|Signature=DavidS}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Trying to connect to a vserver from the host or another vserver on the same host fails&lt;br /&gt;
||Details=strace shows&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
sin_addr=inet_addr(&amp;quot;xx.xx.xx.xx&amp;quot;)}, yy) = -1 EINVAL (Invalid argument)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A: The host/guest cannot communicate with another guest on same host.&lt;br /&gt;
* check all netmasks on all interfaces (do they overlap) ?&lt;br /&gt;
* check policy routing (disable it temporary) ?&lt;br /&gt;
* check that lo is up (Networking within a host/guest always uses lo interface)&lt;br /&gt;
|Signature=CommonProblems}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Can I use iptables ?&lt;br /&gt;
||Details=Yes but right now only on the host (rootserver). Please realize that all traffic is local and will not touch the forward chain.&lt;br /&gt;
|Signature=BeginnerFAQ}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is it possible to prevent guest from bringing down primary ip?&lt;br /&gt;
||Details=Yes. Remove /etc/vservers/&amp;lt;guest&amp;gt;/interfaces/X/dev, and touch /etc/vservers/&amp;lt;guest&amp;gt;/interfaces/X/nodev&lt;br /&gt;
|Signature=Daniel&amp;amp;Serge}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is it possible to provide a different MAC address per vServer?&lt;br /&gt;
||Details=Short answer - yes but it's a hassle.&lt;br /&gt;
&lt;br /&gt;
Real answer from '''_are_''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
When I once needed 'real' seperate MAC-addresses I used TAP-devices and VDE2 ([http://vde.sourceforge.net/ Virtual Distributed Ethernet]).&lt;br /&gt;
Basically vServer is an isolation of existing resources, not a virtualization of 'new' devices.&lt;br /&gt;
Without extra fuss you can't add a 'new' network interface to a vServer, no matter if it is eth* or tap*, you always add it to the host and give the vServer access to it.&lt;br /&gt;
I got the TAP+VDE2 up and running, but I think it is too much trouble for basically the simple adding of IPs to a vServer unless you really need the MAC address separate.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=bobnormal}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Administration tools ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Which guest vservers are running?&lt;br /&gt;
||Details=Use vserver-stat to find out.  Example output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CTX   PROC    VSZ    RSS  userTIME   sysTIME    UPTIME NAME&lt;br /&gt;
0       77 965.1M 334.6M  14m14s18   2m28s69   1h33m46 root server&lt;br /&gt;
49152    7    14M   5.2M   0m00s40   0m00s30   1h30m15 chiffon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is there a web-based interface for vserver that will allow creation/deletion/configuration etc. of vserver guests?&lt;br /&gt;
||Details=&lt;br /&gt;
* http://OpenVPS.org which is a set of scripts with a web-interface for webhosters/ISPs&lt;br /&gt;
* http://Openvcp.org which is a distributed system (agent!) with a web-interface, with which you can build/remove guests&lt;br /&gt;
* http://vsmon.revolutionlinux.com/ is a distributed monitoring-only solution that allows you to search for a particular vserver in your park.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
== Hosting foreign distributions ==&lt;br /&gt;
 &lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I run a Debian host and want to build an Ubuntu guest. Howto?&lt;br /&gt;
||Details=Simple ;) Assume you want to build a breezy guest on a sid host with IP 192.168.0.2 and hostname vubuntu, then do:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver vubuntu build --force -m debootstrap --hostname vubuntu.myvservers.net --netdev eth0 --interface 192.168.0.2/24 \&lt;br /&gt;
--context 42 -- -d breezy -m http://de.archive.ubuntu.com/ubuntu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[UPDATE] Currently there are problems in building breezy under unclear circumstances, which seems to have to do with udev. If the above didnt work, try:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vserver vubuntu build --force -m debootstrap --hostname vubuntu.myvservers.net --netdev eth0 --interface 192.168.0.2/24 \&lt;br /&gt;
--context 42 -- -d breezy -m http://de.archive.ubuntu.com/ubuntu -- --exclude=udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In very recent versions of the utils, the problem should not occur anymore (it has to do with the 'secure-mount' if you look in the MLs)&lt;br /&gt;
&lt;br /&gt;
Well, sid's debootstrap knows how to bootstrap Ubuntu linux. Make sure to have a current debootstrap package: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt-get update&lt;br /&gt;
apt-get install debootstrap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 The knowledge how to build ubuntu 'breezy badger' (which you probably want to be your guest at the time of writing) has been added recently.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I want to build a Gentoo guest. Howto?&lt;br /&gt;
||Details=Even simpler ;) See http://www.gentoo.org/proj/en/vps/vserver-howto.xml#doc_chap3 .&lt;br /&gt;
|Signature=gcc}}&lt;br /&gt;
&lt;br /&gt;
== Application level problems ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I did everything right, but the application foo does not start. What's up there?&lt;br /&gt;
||Details=Before asking on the IRC channel, please check out the 'problematic programs' page:&lt;br /&gt;
[[Problematic Programs]]&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=When I try to ssh to the guest, I log into the host, even if I installed sshd on the guest. What's wrong here?&lt;br /&gt;
||Details=Look at /etc/ssh/sshd_config of the host:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Port 22&lt;br /&gt;
# Use these options to restrict which interfaces/protocols sshd will bind to&lt;br /&gt;
#ListenAddress ::&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And now change the setting to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Port 22&lt;br /&gt;
# Use these options to restrict which interfaces/protocols sshd will bind to&lt;br /&gt;
ListenAddress your.hosts.ip.here  # not the guests IP! &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then '/etc/init.d/ssh restart' on the host, after that on the guest (if you did apt-get install ssh on the guest already.)&lt;br /&gt;
Do I have to explain more? If the hosts sshd binds all available IP addresses on port 22 (The hosts 'sees' even all addresses of the guests!). So if the guest starts its sshd, it can't bind to port 22 any more. You need to change that setting only on the host. &lt;br /&gt;
(BTW: A similar approach has to be done for a lot of daemons, e.g. Apache. If the daemon does not support an explicit bind, you may use the chbind command to 'hide' IP addresses from the daemon before starting.)|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Bind9 does not like to start in my guest.&lt;br /&gt;
||Details=Check out the [[Problematic Programs]] page and/or get my [http://linux-vserver.derjohn.de/bind9-packages/bind9-capacheck_9.3.2-2_i386.deb vserver-guest-ready Debian package] for Debian Sid guests and check out the [http://linux-vserver.derjohn.de/bind9-packages/README.txt readme]. (Hint: This is fresh stuff. Please give me feedback)&lt;br /&gt;
 &lt;br /&gt;
[UPDATE] Since VServer Devel 2.1.1-rc18 you do not need to patch the userland tools anymore. The capabilities are masked.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=My mysqld running in a guest behaves strangely and is awfully slow/locks up&lt;br /&gt;
||Details=This can be related to /tmp being too small. mysqld stores temporary tables in /tmp and as such, if a lot of queries happen and /tmp runs full this can cause one query to lock up whilst creating the tmp table and all other queries waiting to acquire the lock. There are two possible solutions to that problem: a.) Modify /etc/vservers/vserver-name/fstab and assign more memory to the tmpfs of /tmp and b.) remove the /tmp entry from /etc/vservers/vserver-name/fstab completly. Especially on database servers with a rather high load the second one might be the preferred method.|Signature=sp}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Pure-FTP does not run inside a VServer?&lt;br /&gt;
||Details=That's because it has capabilities enabled, make sure you rebuild your distro's package passing also the `--without-capabilities` flag to configure.&lt;br /&gt;
|Signature=Pedro Algarvio, aka, s0undt3ch}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Why do neither sshd nor crond (vixie-cron) work correctly in my CentOS / Fedora guest? I get 'pam_loginuid(crond:session): set_loginuid failed opening loginuid' and similar lines in my logs.&lt;br /&gt;
||Details=Took me a while to figure this out, and it turned out to be mentioned in the old wiki. Here is the solution on how to solve a common problem with sshd / crond, somehow related to selinux and auditing:&lt;br /&gt;
&lt;br /&gt;
pam authentication (also used with openssh) enables &amp;quot;pam_loginuid.so&amp;quot; in the /etc/pam.d/* files. Comment those out as they are not necessary and will not load within a guest anyway. This probably is also necessary on updates later on, if the configs get changed. You therefore may add the following command line to a cronjob file or your software update script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/bin/sed --in-place -e &amp;quot;s/^session.*required.*pam_loginuid.so/# session\trequired\tpam_loginuid.so/g&amp;quot; /etc/pam.d/*&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=patrick}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do i install nagios-plugins on a Gentoo guest?&lt;br /&gt;
||Details=Unfortunately, the nagios-plugins ./configure scripts wants to ping 127.0.0.1 which is not available inside a guest. Therefore you have to build nagios-plugins outside the guest.&lt;br /&gt;
The easiest way to do this from the host (assuming the guest is running) is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vnamespace -e &amp;lt;xid&amp;gt; -- chroot /vservers/&amp;lt;name&amp;gt; emerge nagios-plugins -va&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=Hollow}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Somebody runs ntpd in guest and you can't use ntpdate in host?&lt;br /&gt;
||Details=Try to run ntpdate with options -u :&lt;br /&gt;
 ntpdate -u ntp.domain.xy&lt;br /&gt;
or you can use command:&lt;br /&gt;
 chbind --nid 42 --ip 1.2.3.4 -- ntpdate ntp.domain.xy&lt;br /&gt;
where IP will be the IP of host.&lt;br /&gt;
|Signature=Punkie/Bertl}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Start / Stop a VServer ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I make a vserver guest start by default?&lt;br /&gt;
||Details=At least on Debian, I can tell you how to do it with the new-style config. If your guest is called &amp;quot;derjohn&amp;quot; and you want it to be started somewhere at the of your bootstrap process, then do:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;default&amp;quot; &amp;gt; /etc/vservers/derjohn/apps/init/mark&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to start it earlier, please read the init script &amp;quot;/etc/init.d/util-vserver&amp;quot; to find out how to do it. In most cases you don't need to change this. On Debian the vservers are started at &amp;quot;20&amp;quot;, so after most other stuff is up (networking etc.).&lt;br /&gt;
&lt;br /&gt;
Besides that I created a small helper script for managing the autostart foo: ((vserver-autostart))|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=My host works, but when I start a guest it says that it has a problem with chbind.&lt;br /&gt;
||Details=You are probably using util-vserver &amp;lt;= 0.30.209, which does use dynamic network contexts internally (With 0.30.210 this fact changed). So if you compiled your kernel without dynamic contexts, you may start guests, but you can't use the network context.The solution is either to switch to .210 util (or Hollow's toolset) or compile the kernel with dynamic network contexts.&lt;br /&gt;
SE Keyword: invalid option `nid' testme.sh&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is old-style and new-style config?&lt;br /&gt;
||Details=Old-style config refers to a single text-file that contains all the configuration settings. With new-style config the configuration is split into several directories and files. You should probably go for new-style config if you are asking.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How can I reboot/halt guests?&lt;br /&gt;
||Details=It depends. &lt;br /&gt;
For legacy Linux-VServer (i.e. 1.2.x), you have to replace /sbin/halt in the guests with vreboot and start rebootmgr in the host. You also need to have a &amp;lt;guest&amp;gt;.conf file in /etc/vservers for each guest. Please have a look at /etc/init.d/rebootmgr.&lt;br /&gt;
For Linux-VServer 2.0+, sys_reboot has been virtualized to do the right thing. No changes are needed in guests. Please note that some things depend on the init style used by the guest : read [[util-vserver:InitStyles]]&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=What is the initial PATH?&lt;br /&gt;
||Details=By default, vserver uses the 'sysv' startup style, which mimics the init process by running the 3rd runlevel through '/etc/init.d/rc 3' (or '/etc/rc.d/rc 3'). Usually this 'rc' script uses a hard-coded PATH. In the case it doesn't, util-vserver also mimics init's default PATH through /etc/vservers/.defaults/apps/init/environment, or if not present /usr/local/lib/util-vserver/defaults/environment. Beware that all those default PATH usually do not include /usr/local.&lt;br /&gt;
|Signature=daniel_hozac&amp;amp;Beuc}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=When I try to start a guest i get this message &amp;quot;/proc/uptime can not be accessed. Usually, this is caused by procfs-security. Please read the FAQ for more details&amp;quot;?&lt;br /&gt;
||Details=After a reboot you need to run the vprocunhide script. If running this script causes many errors to print on the screen, try checking the kernel you have booted with (perhaps it does not have the linux-vserver extensions enabled).&lt;br /&gt;
|Signature=mattzerah}}&lt;br /&gt;
&lt;br /&gt;
== Kernel ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Is SMP Supported?&lt;br /&gt;
||Details=Yes, on all SMP capable kernel architectures.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Do I really need the legacy-interfaces? What are these legacy-interfaces?&lt;br /&gt;
||Details=Since Linux-VServer is an ongoing project, new features might replace old ones, some might require a development version. Legacy-interfaces are available for backward compability (which might be removed someday) with Linux-VServer 1.2.x.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I have a vserver running on a Linux kernel with preemption. Is VServer &amp;quot;preempt&amp;quot; safe?&lt;br /&gt;
||Details=There are no known issues about running vserver on a preemption enabled kernel. I would like to add, that the vserver kernelhackers would probably exclude that option in 'make menuconfig' if there would be an incompatibility. Just my $.02 :)&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=32 vs 64 Bit? What should I take?&lt;br /&gt;
||Details=If you have the choice make the host a 64 bit one. You can run a guest as 32 bit or as 64 bit on a 64 bit host. To run it as 32 bit, you need to compile the x86_64 (a.k.a. AMD64) with the following options:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[*] Kernel support for ELF binaries&lt;br /&gt;
&amp;lt;M&amp;gt; Kernel support for MISC binaries&lt;br /&gt;
[*] IA32 Emulation &amp;lt;---- without that, the entire 32bit API is not present&lt;br /&gt;
&amp;lt;M&amp;gt;   IA32 a.out support  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can force the guest to behave like a 32 environment like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo linux_32bit &amp;gt; /etc/vservers/$NAME/personality&lt;br /&gt;
echo i686 &amp;gt; /etc/vservers/$NAME/uts/machine&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(thanks cehteh for the hint!)&lt;br /&gt;
&lt;br /&gt;
But you can force debootstrap to put 32 bit binaries into the guest by 'export ARCH=i386';&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export ARCH=i386 ; vserver build .... &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On debian when using the newvserver script &amp;quot;export ARCH=i386&amp;quot; has no effect, just use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
newvserver --arch i386 ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Distribution specific questions ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=VServer is included in the stable Debian GNU/Linux for years now. What VS version did they include?&lt;br /&gt;
||Details=At the time of writing, Debian Lenny is the stable release of Debian and includes a 2.6.26 based kernel-package called 2.6.26-2-vserver-ARCH. This currently contains VServer 2.3.0.35 (according to changelog.Debian.gz in the Debian package).&lt;br /&gt;
|Signature=scientes}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Were can I get newer versions of VServer as ready made packages for Debian?&lt;br /&gt;
||Details=Here you go: http://linux-vserver.derjohn.de/ . There is also some stuff on backports.org, but my kernels are always 'devel' branch.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Misc ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Why isn't there a device /dev/xyz within a guest?&lt;br /&gt;
||Details=Device nodes allow userspace to access hardware (or virtual resources). Creating a device node inside the guest's namespace will give access to that device, so for security reasons, the number of 'given' devices is small.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I want to (re)mount a partition in a running guest ... but the guest has no rights (capability) to (re)mount?&lt;br /&gt;
||Details=I'll explain. I take as example your /tmp partition within the guest is too small, what will be likely the case if you stay with the 16MB default (vserver build mounts /tmp as 16 MB tmpfs!).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vnamespace -e XID  mount -t tmpfs -o remount,size=256m,mode=1777 none /var/lib/vservers/&amp;lt;guest&amp;gt;/tmp/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(if there's a problem, try expanding the symlinks in the mount path)&lt;br /&gt;
Be warned that the guest will not recognize the change, as the /etc/mtab file is not updated when you mount like this. To permanently change the mount, edit /etc/vserver/&amp;lt;guest&amp;gt;/fstab on the host.&lt;br /&gt;
&lt;br /&gt;
If you get:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount: can't find /var/lib/vservers/&amp;lt;guest&amp;gt;/tmp in /etc/fstab or /etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
then try instead:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vnamespace -e builder chroot /var/lib/vservers/&amp;lt;guest&amp;gt;/ mount -o remount,size=64m,mode=1777 /tmp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this not work for adding a bindmount (&amp;lt;tt&amp;gt;-o bind&amp;lt;/tt&amp;gt;) of a directory outside of a vserver into the vserver. For this, there is no alternative but restarting the vserver.&lt;br /&gt;
|Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Does anyone know how to increase the size of /tmp within a vserver w/o restarting?&lt;br /&gt;
||Details=Use the remount option for mount.&lt;br /&gt;
 # vnamespace -e XID mount -n -t tmpfs -o remount,size=32m tmpfs /&amp;lt;vdir&amp;gt;/&amp;lt;guest&amp;gt;/tmp&lt;br /&gt;
or something like that.  The arguments are needed since mount is not going to be using /etc/fstab for the information and the version of /proc/mounts is best understood by&lt;br /&gt;
 # vnamespace -e XID cat /proc/mounts.&lt;br /&gt;
See [[Frequently_Asked_Questions#I want to (re)mount a partition in a running guest ... but the guest has no rights (capability) to (re)mount?]]&lt;br /&gt;
|Signature=derjohn/dhozac}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=#1 ERROR:  capset(): Operation not permitted&lt;br /&gt;
||Details=capabilities are not enabled in kernel-setup&lt;br /&gt;
please check that CONFIG_SECURITY_CAPABILITIES is loaded or included in the kernel. ( check with &amp;quot;cat /path_to_kernel/.config | grep -i cap &amp;quot;) &lt;br /&gt;
(2.6.11.5-vs-1.9.5 + 0.30-205)&lt;br /&gt;
|Signature=IrcQuestions}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How can I make 'vserver start' mount the root filesystem?&lt;br /&gt;
||Details=Mount it via /etc/vservers/vserver-name/fstab, make sure to set the option 'dev' e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;/dev/drbd0     /       xfs     rw,dev          0 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Signature=AdrianReyer}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I deleted a guest's directory without shutting it down. Now I have a &amp;quot;ghost&amp;quot; running. Is there any possibility to get it out of proc without rebooting?&lt;br /&gt;
||Details=&lt;br /&gt;
 vkill --xid &amp;lt;xid&amp;gt; -s 15; sleep 2; vkill --xid &amp;lt;xid&amp;gt; -s 9&lt;br /&gt;
&lt;br /&gt;
You will also need to remove guest's ip, for example with:&lt;br /&gt;
 ip addr del &amp;lt;ip&amp;gt; dev eth0&lt;br /&gt;
|Signature=daniel_hozac &amp;amp; gebura }}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=When using nice and su (for example, in the updatedb cron job), I get: su: Permission denied. What does it mean?&lt;br /&gt;
||Details=A guest cannot lower its nice value - and that's what 'su' does through pam_limits which sets a nice value of 0. You can see it through strace:&lt;br /&gt;
 $ strace nice su nobody&lt;br /&gt;
 [...]&lt;br /&gt;
 setpriority(PRIO_PROCESS, 0, 0)         = -1 EACCES (Permission denied)&lt;br /&gt;
You can use 'su nobody -c nice some_cmd' instead.&lt;br /&gt;
(Now there's the question of why a guest process cannot lower its nice value.)&lt;br /&gt;
|Signature=daniel_hozac&amp;amp;Beuc}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I handle NFS mounts within in a guest?&lt;br /&gt;
||Details=There are three ways. &lt;br /&gt;
&lt;br /&gt;
'''1)''' Mount the NFS share from the host OS and let vserver guest access it as part of it's file system.&lt;br /&gt;
&lt;br /&gt;
''mount --bind'' may also be beneficial in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''2)''' Use util-vserver and create a ''fstab.remote'' file in the /etc/vserver/&amp;lt;vserver_name&amp;gt; directory. Populate this with the NFS shares and they will be mounted in the context of the vserver guest.&lt;br /&gt;
&lt;br /&gt;
See http://www.nongnu.org/util-vserver/doc/conf/configuration.html&lt;br /&gt;
&lt;br /&gt;
'''3)''' Add capabilities to the vserver guest instance to grant sufficient rights to allow NFS mounts.&lt;br /&gt;
&lt;br /&gt;
Add the following to /etc/vserver/&amp;lt;vserver_name&amp;gt;/bcapabilities&lt;br /&gt;
 SYS_ADMIN&lt;br /&gt;
Add the following to /etc/vserver/&amp;lt;vserver_name&amp;gt;/ccapabilities&lt;br /&gt;
 SECURE_MOUNT&lt;br /&gt;
 BINARY_MOUNT&lt;br /&gt;
&lt;br /&gt;
See [[Capabilities_and_Flags]] for more information about vserver capabilities.&lt;br /&gt;
&lt;br /&gt;
If you want the NFS shares to be mounted when the guest starts, add them to /etc/vserver/&amp;lt;vserver_name&amp;gt;/fstab&lt;br /&gt;
&lt;br /&gt;
||Signature=martindk}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=vserver start/stop/enter fails with something like &amp;quot;vnamespace: execvp(&amp;quot;/usr/sbin/vserver&amp;quot;): No such file or directory&amp;quot; ?&lt;br /&gt;
||Details=Check whether ''/usr'' is mounted in the namespace you are working with.&lt;br /&gt;
&amp;lt;pre&amp;gt;vnamespace -e &amp;lt;guest&amp;gt; cat /proc/mounts&amp;lt;/pre&amp;gt;&lt;br /&gt;
If there is no ''/usr'', you can fix your problem with simply mounting it using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;vnamespace -e &amp;lt;guest&amp;gt; mount /dev/&amp;lt;device&amp;gt; /usr&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
||Signature=sim0n}}&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=The command vserver &amp;lt;$server&amp;gt; start gives '/etc/init.d/rc: line 74: /etc/default/rcS: No such file or directory', what do I do? &lt;br /&gt;
||Details=The vserver has not been correctly installed, this has several reasons&lt;br /&gt;
check your install log and it should tell you something about that your server didn't get installed properly&lt;br /&gt;
* use stable distribution of debian as server (debootstrap may be different over the versions)&lt;br /&gt;
* deny_mount, deny_caps and deny_pivot should be off if your running grsec.&lt;br /&gt;
&lt;br /&gt;
||Signature=Dude}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How could I rename a vserver directory?&lt;br /&gt;
||Details=Please note : this procedure renames the '''directory''', not the '''hostname''' !&lt;br /&gt;
#Stop the vserver in question&lt;br /&gt;
#rename the &amp;lt;tt&amp;gt;/vservers/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt; directory&lt;br /&gt;
#rename the &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt; directory&lt;br /&gt;
#update link: &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;/run&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;/var/run/vservers/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
#update link: &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;/vdir&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;/etc/vservers/.defaults/vdirbase/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
#update link: &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;/cache&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;/etc/vservers/.defaults/cachebase/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
#update link: &amp;lt;tt&amp;gt;/var/run/vservers.rev/&amp;lt;server XID&amp;gt;&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;/etc/vservers/&amp;lt;server name&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
#Start the vserver in question. It should start properly.&lt;br /&gt;
&lt;br /&gt;
|Signature=FlorianD (from ''hillct'' page in old wiki)}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade from 2.0 to 2.2 ==&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=I now get errors like &amp;quot;ncontext: vc_net_create(): Invalid argument; dynamic contexts disabled.&amp;quot; on startup. Vservers are not started&lt;br /&gt;
||Details=Dynamic context are disabled by default and are deprecated. For example, tagxid and network checks won't be useable with dynamic ids. Now you should manually assign a explicit context to your vservers, like&lt;br /&gt;
 echo 101 &amp;gt; /etc/vservers/myvserv/context&lt;br /&gt;
ADDENDUM: please consider that valid static contexts are between 2 and 49151 ( daniel_hozac on IRC ) otherwise you will end up with unexplainable error &amp;quot;ncontext: vc_net_migrate(): No such process&amp;quot; when trying to start the vserver.&lt;br /&gt;
&lt;br /&gt;
|Signature=daniel_hozac&amp;amp;Beuc}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=How do I assign a static context to an existing vserver?&lt;br /&gt;
||Details=Simple ;) See the answer above. &lt;br /&gt;
|Signature=gcc}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Since upgrading to a newer VS version my guest complains about &amp;quot;vsched: non-numeric value specified for '--priority_bias&amp;quot; at start time. What's wrong?&lt;br /&gt;
||Details=The scheduler paramters changed.You can use this (ugly) script to convert them or do it by hand:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat /usr/local/sbin/vserver-convert-schedule-to-scheddir&lt;br /&gt;
#/bin/sh&lt;br /&gt;
mkdir /etc/vservers/$1/sched&lt;br /&gt;
sed -e 1p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/fill-rate&lt;br /&gt;
sed -e 2p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/interval&lt;br /&gt;
sed -e 3p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/tokens&lt;br /&gt;
sed -e 4p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/tokens-min&lt;br /&gt;
sed -e 5p -n /etc/vservers/$1/schedule &amp;gt; /etc/vservers/$1/sched/tokens-max&lt;br /&gt;
&lt;br /&gt;
mv /etc/vservers/$1/schedule /etc/vservers/$1/schedule.converted.see.scheddir&lt;br /&gt;
&lt;br /&gt;
# see: http://oldwiki.linux-vserver.org/Scheduler+Parameters&lt;br /&gt;
# see: http://www.nongnu.org/util-vserver/doc/conf/configuration.html#sched&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
||Signature=derjohn}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Question&lt;br /&gt;
|Question=Since upgrading to a newer VS version my guest doesn't have the amount of shared memory (SHM / SHMMAX / SHMALL ) as it had in the former version. What changed?&lt;br /&gt;
||Details=Every VS version that runs on a kernel &amp;gt;= 2.6.19 offers sysctl values per guest. This has to do with the 'ipc namespace' feature that was added to the mainline kernel in version 2.6.19. Linux-VServer uses that feature to give each guest a separate 'ipc namespace' and thus 'own' sysctl values per guest. Because shmmax is such a sysctl value, you have to set it per guest.&lt;br /&gt;
Here is an example how to do so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/0 -p&lt;br /&gt;
# echo kernel.shmall &amp;gt; /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/0/setting&lt;br /&gt;
# echo 134217728 &amp;gt; /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/0/value&lt;br /&gt;
# mkdir /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/1 -p&lt;br /&gt;
# echo kernel.shmmax &amp;gt; /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/1/setting&lt;br /&gt;
# echo 134217728 &amp;gt; /etc/vservers/&amp;lt;vserver&amp;gt;/sysctl/1/value&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It's also explained on the geat flower page:&lt;br /&gt;
# see: http://www.nongnu.org/util-vserver/doc/conf/configuration.html -&amp;gt; Look for &amp;quot;sysctl&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
After changing those values, restart your guest, enter it and check if the values are set:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sysctl -a | grep shm&lt;br /&gt;
...&lt;br /&gt;
kernel.shmall = 134217728&lt;br /&gt;
kernel.shmmax = 134217728&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To change a value for a running guest, on the host use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 vspace -e CONTEXTID --ipc sysctl -w kernel.shmall=134217728&lt;br /&gt;
 vspace -e CONTEXTID --ipc sysctl -w kernel.shmmax=134217728&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
||Signature=derjohn&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Bobnormal</name></author>	</entry>

	</feed>