Difference between revisions of "Frequently Asked Questions"

From Linux-VServer

Jump to: navigation, search
(split nondefault mark value stuff into its own question)
 
(136 intermediate revisions by 76 users not shown)
Line 11: Line 11:
 
__TOC__
 
__TOC__
  
{{Question|Question=What is a 'Guest'?||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'.|Signature=derjohn}}
+
== General ==
  
 +
{{Question
 +
|Question=What is the status of Linux-VServer?
 +
||Details=Linux-VServer has more than a decade of maturity and is actively developed. Two projects are similar to Linux-VServer, [[http://lxc.sf.net LXC]], and [[http://openvz.org OpenVZ]]. Of the two, OpenVZ is the more mature and offers some similar functionality to Linux-VServer. LXC is solely based on the kernel mechanisms such as cgroups that are present in modern kernels. These kernel mechanisms will continue to be refined and isolation will mature. As that occurs, Linux-VServer will take advantage of those new features separately from LXC and continue to provide the same robust user interface that it does currently. Currently, LXC offers significantly less functionality and isolation than Linux-vserver. LXC will eventually be a robust wrapper around kernel mechanisms but is still under heavy development and not considered ready for production use.
 +
|Signature=beck}}
  
{{Question|Question=What kind of Operating System (OS) can I run as guest?||Details=
 
A: 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 seperate 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.|Signature=derjohn}}
 
  
{{Question|Question=Which distributions did you test?||Details=
 
A: 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 ((step-by-step Guide 2.6)) how to do that.|Signature=derjohn}}
 
  
{{Question|Question=Is VServer comparable to XEN/UML/QEMU?||Details=
+
{{Question
A: 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 not "emulate" any hardware you run a kernel on. 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.|Signature=derjohn}}
+
|Question=What is a 'Guest'?
 +
||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'.
 +
|Signature=derjohn}}
  
{{Question|Question=Is VServer secure?||Details=
 
A: We hope so. It should be as least as secure as Linux is. We consider it much much more secure though.|Signature=derjohn}}
 
  
{{Question|Question=Performance?||Details=
+
{{Question
A: 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).|Signature=derjohn}}
+
|Question=What kind of Operating System (OS) can I run as guest?
 +
||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.
 +
|Signature=derjohn}}
  
{{Question|Question=Is SMP Supported?||Details=
+
{{Question
A: Yes, on all SMP capable kernel architectures.|Signature=derjohn}}
+
|Question=Is this a new project? When was it started?
 +
||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
 +
So you can expect a mature software product which does its magic quite well (And hey, we have a version > 2.0!)
 +
|Signature=derjohn}}
  
{{Question|Question=Resource sharing?||Details=
+
{{Question
A: Yes ....
+
|Question=Which distributions did you test?
 +
||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.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=Is VServer comparable to XEN/UML/QEMU?
 +
||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 "emulate" 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.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=With which version should I begin?
 +
||Details=If you are new to VServer I recommend to try the latest stable kernel patch, and the latest util-vserver "alpha" release.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=Is VServer secure?
 +
||Details=We hope so. It should be as least as secure as Linux is. We consider it much much more secure though.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=Performance?
 +
||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).
 +
|Signature=derjohn}}
 +
 
 +
 
 +
{{Question
 +
|Question=What is the "great flower page"?
 +
||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.
 +
|Signature=derjohn}}
 +
 
 +
 
 +
 
 +
== Resources usage ==
 +
 
 +
{{Question
 +
|Question=Resource sharing?
 +
||Details=Yes ....
 
* memory: Dynamically.
 
* memory: Dynamically.
* CPU usage: Dynamically (token bucket)|Signature=derjohn}}
+
* CPU usage: Dynamically (token bucket)
 +
|Signature=derjohn}}
  
{{Question|Question=Resource limiting?||Details=
+
{{Question
A: Yes, you can set maximum limits per guest, but you can only offer guaranteed resource availability with some ticks at the time. There is the possibility to ulimit and to rlimit. Rlimit is a new feature of kernel 2.6/vs2.0.|Signature=derjohn}}
+
|Question=Resource limiting?
 +
||Details=You can put limits per guest on different subsystems.
 +
* 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]]
 +
* CPU usage : see [[CPU Scheduler]]
 +
* disk space usage : see [[Disk Limits and Quota]]
 +
Note that you can only offer guaranteed resource availability with some ticks at the time.
 +
|Signature=derjohn&xm}}
 +
 
 +
{{Question
 +
|Question=How do I limit a guests RAM? I want to prevent OOM situations on the host!
 +
||Details=First you can read [http://linux-vserver.org/Memory+Allocation] and [[Memory Limits]].
 +
If you want a recipe, do this:
 +
# Check the size of memory pages. On x86 and x86_64 is usually 4 KB per page. (on linux "getconf -a|grep PAGE" will give you the information)
 +
# Create /etc/vserver/<guest>/rlimits/
 +
# Check your physical memory size on the host, e.g. with "free -m". maxram = kilobytes/pagesize.
 +
# Limit the guests physical RAM to value smaller then maxram:<pre>echo %%insertYourPagesHereSmallerThanMaxram%% > /etc/vserver/<guest>/rlimits/rss </pre>
 +
# Check your swapspace, e.g. with 'swapon -s'. maxswap = swapkilobytes/pagesize.
 +
# Limit the guest's maximum number of as pages to a value smaller than (maxram+maxswap): <pre> echo %%desiredvalue%% > /etc/vserver/<guest>/rlimits/as </pre>
 +
# Correctly display the memory information inside the guest:<pre>echo "VIRT_MEM" >> /etc/vservers/<guest>/flags</pre>
 +
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 .....
 +
|Signature=derjohn}}
  
{{Question|Question=Disk I/O limiting? Is that possible?||Details=
 
A: 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:
 
  
 +
{{Question
 +
|Question=Disk I/O limiting? Is that possible?
 +
||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:
 
<pre>
 
<pre>
 
# cat /sys/block/hdc/queue/scheduler
 
# cat /sys/block/hdc/queue/scheduler
Line 48: Line 111:
 
</pre>
 
</pre>
  
The default is anticipatory a.k.a. "AS". 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 "completely fair queueing" scheduler, CFQ, which can do that. (More on schedulers can be found at http://lwn.net/Articles/114770/)
+
The default since 2.6.18 in Sept 2006 is CFQ, described below, and prior to that was anticipatory a.k.a. "AS" ([[http://en.wikipedia.org/wiki/CFQ#Kernel_2.6.18_.2820_September_2006.29 Wikipedia]]). 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 "completely fair queueing" scheduler, CFQ, which can do that. (More on schedulers can be found at http://lwn.net/Articles/114770/)
 
+
 
This is how to set the scheduler to "cfq" manually:
 
This is how to set the scheduler to "cfq" manually:
 
<pre>
 
<pre>
Line 56: Line 118:
 
noop anticipatory deadline [cfq]
 
noop anticipatory deadline [cfq]
 
</pre>
 
</pre>
 
 
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!
 
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!
 
 
If you run Debian there is a predefined way to set the /sys values at boot-time:
 
If you run Debian there is a predefined way to set the /sys values at boot-time:
 
 
<pre>
 
<pre>
 
# apt-get install sysfsutils
 
# apt-get install sysfsutils
 
[...]
 
[...]
  
# cat /etc/sysfs.conf | grep cfq
+
# grep cfq /etc/sysfs.conf
 
block/sda/queue/scheduler = cfq
 
block/sda/queue/scheduler = cfq
 
block/sdc/queue/scheduler = cfq
 
block/sdc/queue/scheduler = cfq
Line 73: Line 132:
  
 
For non-vserver processes and CFQ you can set by which key the kernel decides about the fairness:
 
For non-vserver processes and CFQ you can set by which key the kernel decides about the fairness:
 
 
<pre>
 
<pre>
 
cat /sys/block/hdc/queue/iosched/key_type
 
cat /sys/block/hdc/queue/iosched/key_type
Line 83: Line 141:
  
 
And: It's possible to tune the scheduler parameters in several ways. Have a look at /sys/block/hdc/queue/....
 
And: It's possible to tune the scheduler parameters in several ways. Have a look at /sys/block/hdc/queue/....
 +
|Signature=derjohn}}
  
You need a very recent Version of VS devel, e.g. the 2.1.1-rc18 can do it. Some older version have that feature too, then it got lost and was reinvented. So: Go and get a rc18 - only in 'devel', not stable!|Signature=derjohn}}
+
{{Question
 +
|Question=Nice disk I/O scheduling, is that possible?
 +
||Details=Well, since linux 2.6.13 processess have another priority next to the cpu nice scheduling hint, it's called io nice.
 +
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.
 +
You can set this niceness by the tool ionice, which for debian is either in the package util-linux or schedutils.
 +
To change the io-niceness you need the <tt>CAP_SYS_NICE</tt>, '''and''' need to have the same uid as the processe you want to ionice.
  
{{Question|Question=Why isn't there a device /dev/bla? within a guest||Details=
+
:'''Note:''' If you want to use any schedulung other than best-effort you will also need the <tt>CAP_SYS_ADMIN</tt>-flag. Be warned that this gives quite some capabilities to the vserver, not just for I/O scheduling!
A: 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.|Signature=derjohn}}
+
  
{{Question|Question=What is Unification (vunify)?||Details=
+
If you want to increase the niceness of an I/O hogging process within a vserver you need to do:
A: 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.|Signature=derjohn}}
+
<PRE>
 +
chcontext --xid sponlp1 sudo -u '#2089' ionice -c2 -n5 -p24409
 +
</PRE>
 +
with sudo and ionice installed on the root server to increase the *nice*ness of pid 24409, with uid 2089
 +
|Signature=Groteblup}}
  
{{Question|Question=What is vhashify?||Details=
+
{{Question
A: The successor of vunify, a tool which does unification based on hash values (which allows to find common files in arbitrary paths.)|Signature=derjohn}}
+
|Question=I want iotop to display all guest processes on host to give me a nice overview of I/O usage.
 +
||Details=You must allow iotop to read information from all guests. Add
  
{{Question|Question=How do I manage a multi-guest setup with vhashify?||Details=
+
<PRE>
A:  For 'vhashify', just do these once:
+
# setattr --watch /proc/vmstat
 +
</PRE>
 +
to, for example, rc.local, and later run iotop:
 +
<PRE>
 +
# vcontext --migrate --xid 1 -- iotop
 +
</PRE>
 +
|Signature=corey via ser}}
  
 +
== Unification ==
 +
 +
{{Question
 +
|Question=What is unification (vunify)?
 +
||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]].
 +
|Signature=derjohn}}
 +
 +
{{Question
 +
|Question=What is [[vhashify]]?
 +
||Details=The successor of [[vunify]], a tool which does unification based on hash values (which allows to find common files in arbitrary paths.)
 +
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.
 +
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 (?).
 +
<br/>|Signature=Guy-
 +
<br/>
 +
Note: hashify cannot cross XFS project QUOTA because hardlinks cannot cross projects.
 +
}}
 +
 +
{{Question
 +
|Question=How do I manage a multi-guest setup with vhashify?
 +
||Details=For '[[vhashify]]', just do these once:
 
<pre>
 
<pre>
 
mkdir /etc/vservers/.defaults/apps/vunify/hash /vservers/.hash
 
mkdir /etc/vservers/.defaults/apps/vunify/hash /vservers/.hash
ln -0s /vservers/.hash /etc/vservers/.defaults/apps/vunify/hash/root
+
ln -s /vservers/.hash /etc/vservers/.defaults/apps/vunify/hash/root
 
</pre>
 
</pre>
 
 
Then, do this one line per vserver:
 
Then, do this one line per vserver:
 
 
<pre>
 
<pre>
 
mkdir /etc/vservers/<vservername>/apps/vunify  # vhashify reuses vunify configuration
 
mkdir /etc/vservers/<vservername>/apps/vunify  # vhashify reuses vunify configuration
 +
</pre>
 +
To hashify a running vserver, do (possibly from a cronjob):
 +
<pre>
 +
vserver name-of-guest hashify
 
</pre>
 
</pre>
  
 +
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 <tt>vserver enter</tt>.
  
The command 'ln' creates a link between two files.  "ln -s" creates a symbolic link -- two files are linked by name.  "ln -0s" uses a Vserver extention to create a unified link.|Signature=derjohn}}
+
In order for the OS cache to benefit from the hardlinking, you'll have to restart the vservers.
  
{{Question|Question=With which VS version should I begin?||Details=
+
To clean up hashified files that are no longer referenced by any vserver, do (possibly from a cronjob):
A: If you are new to VServer I recommend to try 2.0.+. Take "alpha utils" Version 0.30.210. In Debian Sid there appeared well running version of it recently. (It's  a .210 at the time of writing).|Signature=derjohn}}
+
<pre>
 +
find /vservers/.hash -type f -links 1 -print0 | xargs -0 rm
 +
</pre>
  
{{Question|Question=is there a way to implement "user/group quota" per VServer?||Details=
+
Until you do this, the files still take up place even though no vservers need them.
A: 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.|Signature=derjohn}}
+
|Signature=Guy-}}
  
{{Question|Question=what about "Quota" for a context?||Details=
+
== Filesystem usage ==
A: 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, XFS, JFS)|Signature=derjohn}}
+
  
{{Question|Question=Does it support IPv6?||Details=
+
{{Question
A: Currently not. Some developer has to move his ... to reimplement this functionality from the V4 code (I read that on the ML ;)). Will probably be superseded by the ngnet (next generation networking) soon. There is a Wiki page regarding this: http://linux-vserver.org/IPv6|Signature=derjohn}}
+
|Question=Is there a way to implement "user/group quota" per VServer?
 +
||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 "options vroot max_vroot=20" in /etc/modprobe.conf and then just do modprobe vroot
 +
|Signature=derjohn,gadnet}}
  
{{Question|Question=I can't do all I want with the network interfaces inside the guest?||Details=
+
{{Question
A: 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. |Signature=derjohn}}
+
|Question=What about "Quota" for a context? Howto limit disk usage?
 +
||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.
 +
|Signature=derjohn}}
  
{{Question|Question=Is there a web-based interface for vserver that will allow creation/deletion/configuration etc. of vserver guests?||Details=
+
{{Question
A. [Update] Errrh, there is http://OpenVPS.org which is a set of scripts with a web-interface for webhosters/ISPs.  
+
|Question=How do I tag a guest's directory with xid?
A. [Update] Errrh, there is http://Openvcp.org which is a distributed system (agent!) with a web-interface, with which you can build/remove guests! cool stuff! beta, try out!|Signature=derjohn}}
+
||Details=Tagging the guest's files gives you several advantages, e.g. the accounting will work properly.
 +
Filesystem XID tagging only works on supported filesystem. Those are currently: ext2/3, reiserfs/reiser3, xfs and jfs.
 +
To activate the XID tagging you have to mount the filesystem with "-o tag" (former tagxid is outdated since VS2.2). Attention: It's _not_ possible to "-o remount,tag", 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:
 +
<pre>
 +
chxid -c xid -R /var/lib/vservers/<guest>
 +
</pre>
 +
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.
 +
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 !
 +
|Signature=derjohn_and_gonzo_and_are}}
  
{{Question|Question=What is old-style and new-style config?||Details=
+
{{Question
A. 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.|Signature=derjohn}}
+
|Question=How can I copy anything from host to guest partition, normally unvisible on host?
 +
||Details=You should just change namespace, e.g.:
 +
<pre>
 +
vnamespace --enter <xid> -- /bin/bash
 +
</pre>
 +
and then use standard cp or rsync programs.
 +
|Signature=SergiuszPawlowicz}}
 +
 
 +
{{Question
 +
|Question=Why is the barrier attribute disappearing on reiserfs filesystem after umount or host reboot?
 +
||Details=The filesystem has to be mounted with explicitly defining the 'attrs' option, i.e.
 +
<pre>
 +
mount /dev/reiserfsdev /vservers -oattrs
 +
setattr --barrier /vservers
 +
</pre>
 +
to get the barrier survive after umount/reboot.
 +
|Signature=Nikolay Kichukov}}
 +
 
 +
== Network ==
 +
 
 +
{{Question
 +
|Question=Does it support IPv6?
 +
||Details=Currently it requires an additional patch, but the functionality should be available in 2.3+ soon. [[IPv6]] has more information.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=I can't do all I want with the network interfaces inside the guest?
 +
||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.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=How do I add several IPs to a vserver?
 +
||Details=First of all a single guest vserver only supports up to 16 IPs (There is a 64-IP patch available, which is in "derjohn's kernel").
 +
<pre>
 +
Update from IRC (2011-08-22):
 +
<mmouse> quick question: what is the maximum count of IPs (v4) I can have in a single guest?
 +
<daniel_hozac> unlimited.
 +
</pre>
  
{{Question|Question=What is the "great flower page"?||Details=
 
A. Well, this page contains all configation options for vserver in version > 1.9 (I think .. I joined Linux-VServer in version 2, so I don't know for sure). The name of the page is derivived from the stylesheet(s) it contains: It displays background pictures of a very great flower, so regard it as highly optimized. It was designed by a non-designer, who asks us to create a better one. I played with the thought of creating a complete new theme for that page - but actually we all got used to the name "great flower page", so we stick to it. If you are unable to read it clearly, feel invited to join the IRC channel #vserver, we may tell you how to ;)|Signature=derjohn}}
 
 
{{Question|Question=How do I add several IPs to a vserver? ||Details=
 
A: First of all a single guest vserver only supports up to 16 IPs (There is a 64-IP patch available, which is in "derjohn's kernel", you need extra util-vserver anyway).
 
 
Here is a little helper-script that adds a list of IPs defined in a text file, one per line.
 
Here is a little helper-script that adds a list of IPs defined in a text file, one per line.
 
<pre>
 
<pre>
Line 147: Line 289:
 
         mkdir $j
 
         mkdir $j
 
         echo $i > $j/ip
 
         echo $i > $j/ip
        echo $i > $j/ip-old
 
 
         echo "24" > $j/prefix
 
         echo "24" > $j/prefix
 
done
 
done
</pre>|Signature=derjohn}}
+
</pre>
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=How do I assign a new IP address to a running guest?
 +
||Details=This is done from the host server:
 +
* add the ip on the host, for example
 +
<pre>
 +
ip addr add 194.169.123.23/24 dev eth0
 +
</pre>
 +
* add the ip to the guest's network context (a guests NID is the same as the XID {context ID})
 +
<pre>
 +
naddress --add --nid <nid> --ip 194.169.123.23/24
 +
</pre>
 +
* enter the guest (best via ssh)
 +
* restart the services that need to make use of the new address if required
 +
* update the config in ''/etc/vserver/<servername>/interfaces'' to reflect the changes for the next guest restart (if desired)
 +
|Signature=BenjaminGreen}}
  
{{Question|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?||Details=
+
{{Question
A: Yes, use iptables with SNAT to masquerade it.  
+
|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?
 +
||Details=Yes, use iptables with SNAT to masquerade it.  
 
<pre>
 
<pre>
 
iptables -t nat -I POSTROUTING -s $VSERVER_NETZ  ! -d $VSERVER_NETZ -j SNAT --to $EXT_IP
 
iptables -t nat -I POSTROUTING -s $VSERVER_NETZ  ! -d $VSERVER_NETZ -j SNAT --to $EXT_IP
 
</pre>
 
</pre>
See: HowtoPrivateNetworking and  
+
See: [[HowtoPrivateNetworking]] and  
http://www.tgunkel.de/it/software/doc/linux_server#h3-Vserver_Masquerading_SNAT (THX, [MUPPETS]Gonzo)|Signature=derjohn}}
+
http://www.tgunkel.de/it/software/doc/linux_server.en#h3-VServer_Masquerading_SNAT (THX, [MUPPETS]Gonzo)
 +
|Signature=derjohn}}
  
{{Question|Question=If I shut down my vserver guest, the whole Internet interface ethX on the host is shut down.  What happened? ||Details=
+
{{Question
A: 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 "alias promotion". You may set it via sysctl by adding ''net.ipv4.conf.all.promote_secondaries=1'' in /etc/sysctl.conf or via sysctl command line.|Signature=derjohn}}
+
|Question=If I shut down my vserver guest, the whole Internet interface ethX on the host is shut down.  What happened?
 +
||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. Similarly, if your guests bring up IPs of more than one subnet, all other IPs from a specific subnet will be shut down if you stop the guest which created the first ("parent") IP.
 +
 
 +
You can check this on the host using the command "ip addr show". Example output:
 +
<pre>
 +
1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
 +
    link/ether 00:01:02:03:04:05 brd ff:ff:ff:ff:ff:ff
 +
    inet 192.168.249.172/27 brd 192.168.249.191 scope global eth0
 +
    inet 192.168.234.194/27 brd 192.168.234.223 scope global eth0
 +
    inet 192.168.249.169/27 brd 192.168.249.191 scope global secondary eth0
 +
    inet 192.168.234.195/27 brd 192.168.234.223 scope global secondary eth0
 +
</pre>
 +
In this example, if you stop the guest which brings down the IP 192.168.249.172, the IP 192.168.249.169 will be brought down as well, because it is a secondary IP of the "parent" 192.168.249.172.
  
 +
But in very recent kernels, there is an option ''settable'' which prevents that nasty feature. It's called "alias promotion". You may set it via sysctl by adding ''net.ipv4.conf.all.promote_secondaries=1'' in /etc/sysctl.conf or via sysctl command line.
 +
|Signature=derjohn, Hurga}}
  
{{Question|Question=On Debian Sarge (stable) only util-vserver is 0.30-204 available, which has been reported to be buggy (I didnt check the version for longer time) How do I compile a local version of alpha util-vserver .210 on Debian?||Details=
+
{{Question
A:
+
|Question=Can I run an OpenVPN Server in a guest?
 +
||Details=
 +
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.
 +
This is the minimal OpenVPN configuration for the Server which will be used to demonstrate how to get it running in a client:
 
<pre>
 
<pre>
apt-get build-dep util-vserver
+
# Networking setup
 +
server 192.168.16.0    255.255.255.0
 +
dev tun16
 +
ifconfig-noexec
 +
comp-lzo
 +
# Certificates
 +
dh ...
 +
ca ...
 +
cert ...
 +
key ...
 +
# Management
 +
persist-key
 +
keepalive 10 60
 +
verb 4
 +
</pre>
 +
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.
 +
<pre>
 +
# openvpn --mktun --dev tun16
 +
# ip link set dev tun16 txqueuelen 100
 +
# ifconfig tun16 192.168.16.1 pointopoint 192.168.16.2 mtu 1500
 +
# route add -net 192.168.16.0 netmask 255.255.255.0 gw 192.168.16.2
 +
</pre>
 +
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.
 +
Additionally, the guest needs /dev/net/tun to make OpenVPN happy. This can be created with MAKEDEV:
 +
<pre>
 +
# cd /var/lib/vserver/<myopenvpnserver>/dev/
 +
# ./MAKEDEV tun
 +
  (creates the dev/net/tun device accessible by the guest - even a tap interface needs /dev/net/tun !)
 +
</pre>
 +
Finally, the guest needs to have the tun device assigned:
 +
<pre>
 +
# head /etc/vservers/<myopenvpnserver>/interfaces/1/*
 +
==> /etc/vservers/<myopenvpnserver>/interfaces/1/ip <==
 +
192.168.16.1
  
./configure --prefix=/usr/local/ --enable-release \
+
==> /etc/vservers/<myopenvpnserver>/interfaces/1/nodev <==
--mandir=/usr/local/share/man \
+
tun16
--infodir=/usr/local/share/info \
+
--sysconfdir=/etc --enable-dietlibc \
+
--localstatedir=/var \
+
--with-vrootdir=/var/lib/vservers
+
  
make
+
==> /etc/vservers/<myopenvpnserver>/interfaces/1/prefix <==
 +
24
 +
#
 +
</pre>
 +
The client's conf may look like that:
 +
<pre>
 +
# Basic setup
 +
client
 +
proto tcp-client
 +
dev tun
 +
remote <ipaddress>
 +
comp-lzo
 +
verb 4
  
make install-distribution
+
# Certificate
(Which does a make install + setting a symlink ln -s /usr/local/lib/util-vserver/vshelper /sbin/vshelper )
+
ca ...
 +
</pre>
  
 +
[ Based on derJohn's original answer, all errors mine ]
 +
|Signature=DavidS}}
 +
 +
{{Question
 +
|Question=Trying to connect to a vserver from the host or another vserver on the same host fails
 +
||Details=strace shows
 +
<pre>
 +
sin_addr=inet_addr("xx.xx.xx.xx")}, yy) = -1 EINVAL (Invalid argument)
 
</pre>
 
</pre>
 +
A: The host/guest cannot communicate with another guest on same host.
 +
* check all netmasks on all interfaces (do they overlap) ?
 +
* check policy routing (disable it temporary) ?
 +
* check that lo is up (Networking within a host/guest always uses lo interface)
 +
|Signature=CommonProblems}}
  
To test which version you are running:
+
{{Question
<pre>
+
|Question=Can I use iptables ?
# which vserver
+
||Details=Yes but right now only on the host (rootserver). Please realize that all traffic is local and will not touch the forward chain.
/usr/local/sbin/vserver
+
<br>If you really, really, really need iptables on the guest and you are aware about loosing a big part of VServer isolation and security you could add the NET_ADMIN capability. Consider writing wrappers to manage iptables on the host instead.
 +
|Signature=_are_}}
  
 +
{{Question
 +
|Question=Is it possible to prevent guest from bringing down primary ip?
 +
||Details=Yes. Remove /etc/vservers/<guest>/interfaces/X/dev, and touch /etc/vservers/<guest>/interfaces/X/nodev
 +
|Signature=Daniel&Serge}}
 +
 +
{{Question
 +
|Question=Is it possible to provide a different MAC address per vServer?
 +
||Details=Short answer - yes but it's a hassle.
 +
 +
Real answer from '''_are_''':
 +
<pre>
 +
When I once needed 'real' seperate MAC-addresses I used TAP-devices and VDE2 ([http://vde.sourceforge.net/ Virtual Distributed Ethernet]).
 +
Basically vServer is an isolation of existing resources, not a virtualization of 'new' devices.
 +
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.
 +
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.
 
</pre>
 
</pre>
  
This should point to ..local...
 
  
If you dont want to build it yourself: On www.backports.org there are backported (for sarge) linux-images (2.6.16) with vserver-patch enabled and a updated util-vserver package as well.
+
You can also utilize MACVLAN ability from kernel.
|Signature=derjohn}}
+
I.e. create ''macvlan0'' interface with:
 +
<pre>ip link add link eth0 address 00:19:d1:29:d2:58 macvlan0 type macvlan</pre>
 +
[[http://jim.studt.net/depository/index.php/notes-on-linux-s-macvlan-module Reference]]
 +
|Signature=bobnormal&swenTjuln
 +
}}
  
{{Question|Question=I use derjohn's kernel or a differnet kernel with a more-than-16-IPs-per-guest-patch and can't use more than 16 IPs. Why?||Details=
+
{{Question
A: You need to patch util-vserver, too. So you obviously need to recompile util-vserver (see above). In the util-vserver directory there are header files in the ./kernel/ directory. Patch like this:
+
|Question=Is it possible to hide packet counters on the host network interface from vServer guests?
 +
||Details=Yes, see [[Networking_vserver_guests|Networking vServer Guests]]
 +
|Signature=bobnormal}}
 +
 
 +
{{Question
 +
|Question=Services won't bind to 127.0.0.1 when I configure them to bind to all available IPs / (binding service to * doesn't bind to loopback)?
 +
||Details=You've configured single public IP and have kernel option "Linux VServer -> Automatic Single IP Special Casing" enabled.
 +
It means somehow "optimized" :D
 +
If you don't want this you have 3 possible solutions (quoting Bertl):
 +
  * disable the auto single IP in the kernel
 +
  * assign more than one IP to the guest
 +
  * disable single ip special casing for that guest
 +
 
 +
The later is done by : echo "~single_ip" >> /etc/vservers/<VSERVER>/nflags
 +
At runtime to avoid restarting the vserver: nattribute --set --nid <guest> --flag ~single_ip
 +
|Signature=swenTjuln}}
 +
 
 +
{{Question
 +
|Question=When using network namespaces and vserver together, netstat does not work in the vserver. What's wrong?  
 +
||Details=All proc entries are hidden by default in the guests. During startup of the host system a tool called vprocunhide makes some /proc files visible.
 +
 
 +
If you create a new network namespace you have to do the same in the network namespace because the new /proc/net files are not available for the vprocunhide outside the new network namespace. So something like that should be sufficient to get netstat working in vservers with network namespaces:
  
 
<pre>
 
<pre>
kernel/network.h:#define NB_IPV4ROOT    64
+
ip netns exec $NAMESPACE /usr/lib/util-vserver/vprocunhide
 
</pre>
 
</pre>
 +
|Signature=AlexanderS}}
  
BTW: The initial patches can be found here: http://vserver.13thfloor.at/Experimental/VARIOUS/util-vserver-0.30.196-net64.diff.bz2 and  http://vserver.13thfloor.at/Experimental/VARIOUS/delta-2.6.9-vs1.9.3-net64.diff
+
== Administration tools ==
|Signature=unknown}}
+
  
{{Question|Question=I run a Debian host and want to build an Ubuntu guest. Howto?||Details=
+
{{Question
A: Simple ;) Assume you want to build a breezy guest on a sid host with IP 192.168.0.2 and hostname vubuntu, then do:
+
|Question=Which guest vservers are running?
 +
||Details=Use vserver-stat to find out.  Example output:
 +
<pre>
 +
CTX  PROC    VSZ    RSS  userTIME  sysTIME    UPTIME NAME
 +
0      77 965.1M 334.6M  14m14s18  2m28s69  1h33m46 root server
 +
49152    7    14M  5.2M  0m00s40  0m00s30  1h30m15 chiffon
 +
</pre>
 +
|Signature=derjohn}}
 +
 
 +
 
 +
{{Question
 +
|Question=Is there a web-based interface for vserver that will allow creation/deletion/configuration etc. of vserver guests?
 +
||Details=
 +
* http://OpenVPS.org which is a set of scripts with a web-interface for webhosters/ISPs
 +
* http://Openvcp.org which is a distributed system (agent!) with a web-interface, with which you can build/remove guests
 +
* http://vsmon.revolutionlinux.com/ is a distributed monitoring-only solution that allows you to search for a particular vserver in your park.
 +
|Signature=derjohn}}
 +
 
 +
== Hosting foreign distributions ==
 +
 +
{{Question
 +
|Question=I run a Debian host and want to build an Ubuntu guest. Howto?
 +
||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:
 
<pre>
 
<pre>
 
vserver vubuntu build --force -m debootstrap --hostname vubuntu.myvservers.net --netdev eth0 --interface 192.168.0.2/24 \
 
vserver vubuntu build --force -m debootstrap --hostname vubuntu.myvservers.net --netdev eth0 --interface 192.168.0.2/24 \
Line 224: Line 518:
 
apt-get install debootstrap
 
apt-get install debootstrap
 
</pre>
 
</pre>
  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.|Signature=derjohn}}
+
  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.
 +
|Signature=derjohn}}
  
{{Question|Question=How do I make a vserver guest start by default?||Details=
 
A: At least on Debian, I can tell you how to do it with the new-style config. If your guest is called "derjohn" and you want it to be started somewhere at the of your bootstrap process, then do:
 
<pre>
 
echo "default" > /etc/vservers/derjohn/apps/init/mark
 
</pre>
 
If you want to start it earlier, please read the init script "/etc/init.d/vserver-default" to find out how to do it. In most cases you don't need to change this. On Debian the vservers are started at "90", so after most other stuff is up (networking etc.).
 
  
Besides that I created a small helper script for managing the autostart foo: ((vserver-autostart))|Signature=derjohn}}
+
{{Question
 +
|Question=I want to build a Gentoo guest. Howto?
 +
||Details=Even simpler ;) See http://www.gentoo.org/proj/en/vps/vserver-howto.xml#doc_chap3 .
 +
|Signature=gcc}}
  
{{Question|Question=My host works, but when I start a guest it says that it has a problem with chbind.||Details=
+
== Application level problems ==
A: You are probably using util-vserver <= 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.
+
SE Keyword: invalid option `nid' testme.sh|Signature=derjohn}}
+
  
 +
{{Question
 +
|Question=I did everything right, but the application foo does not start. What's up there?
 +
||Details=Before asking on the IRC channel, please check out the 'problematic programs' page:
 +
[[Problematic Programs]]
 +
|Signature=derjohn}}
  
{{Question|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?||Details=
+
{{Question
A: Look at /etc/ssh/sshd_config of the host:
+
|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?
 
+
||Details=Look at /etc/ssh/sshd_config of the host:
 
<pre>
 
<pre>
 
Port 22
 
Port 22
Line 248: Line 543:
 
#ListenAddress ::
 
#ListenAddress ::
 
</pre>
 
</pre>
 
 
And now change the setting to  
 
And now change the setting to  
 
<pre>
 
<pre>
Line 255: Line 549:
 
ListenAddress your.hosts.ip.here  # not the guests IP!  
 
ListenAddress your.hosts.ip.here  # not the guests IP!  
 
</pre>
 
</pre>
 
 
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.)
 
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.)
 
+
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.  
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 cant bind to port 22 any more. You need to change that setting only on the host.  
+
 
(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}}
 
(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}}
  
{{Question|Question=I did everything right, but the application foo does not start. What's up there?||Details=
+
{{Question
A: Before asking on the IRC channel, please check out the 'problematic programs' page:
+
|Question=Bind9 does not like to start in my guest.
[[Problematic Programs]]|Signature=derjohn}}
+
||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)
 
+
{{Question|Question=Bind9 does not like to start in my guest.||Details=
+
A: Check out the 'problematic programs' page:
+
((ProblematicPrograms)) and/or get my [((ProblematicPrograms)) 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 from that URL: http://linux-vserver.derjohn.de/bind9-packages/bind9-capacheck_9.3.2-2_i386.deb and check out the [http://linux-vserver.derjohn.de/bind9-packages/README.txt readme]. (Hint: This is fresh stuff. The give me Feedback)
+
 
   
 
   
[UPDATE] Since VServer Devel 2.1.1-rc18 you do not need to patch the userland tools anymore. The capabilities are masked.|Signature=derjohn}}
+
[UPDATE] Since VServer Devel 2.1.1-rc18 you do not need to patch the userland tools anymore. The capabilities are masked.
 +
|Signature=derjohn}}
  
{{Question|Question=Which guest vservers are running?||Details=
+
{{Question
A: {{vserver-stat}}Example output:
+
|Question=My mysqld running in a guest behaves strangely and is awfully slow/locks up
 +
||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.
 +
If you prefer not to modify or disable tmpfs, you can reconfigure MySQL to use a different tmpdir such as "/var/tmp"For example, edit /etc/my.cnf (RHEL/CentOS) or create /etc/mysql/conf.d/mysqld_custom.conf (Debian) and add the following line:  
 
<pre>
 
<pre>
CTX  PROC    VSZ    RSS  userTIME  sysTIME    UPTIME NAME
+
tmpdir = /var/tmp
0      77 965.1M 334.6M  14m14s18  2m28s69  1h33m46 root server
+
</pre>
49152    7    14M  5.2M  0m00s40  0m00s30  1h30m15 chiffon
+
Afterwards, restart MySQL (/etc/init.d/mysqld restart) and then review MySQL variables (mysqladmin -uroot -p variables) to confirm "tmpdir" is no longer pointing to "/tmp". |Signature=sp, jrklein}}
</pre>|Signature=derjohn}}
+
  
 +
{{Question
 +
|Question=Pure-FTP does not run inside a VServer?
 +
||Details=That's because it has capabilities enabled, make sure you rebuild your distro's package passing also the `--without-capabilities` flag to configure.
 +
|Signature=Pedro Algarvio, aka, s0undt3ch}}
  
 +
{{Question
 +
|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.
 +
||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:
  
{{Question|Question=How can I reboot/halt guests?||Details=
+
pam authentication (also used with openssh) enables "pam_loginuid.so" 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:
A: It depends.
+
<pre>
For vserver with legacy-interfaces support, you have to replace {{/sbin/halt}} in guests with vreboot and start rebootmgr in host. You also need to have a dummy <guest>.conf file in /etc/vservers for each guest. Please have a look at /etc/init.d/rebootmgr.
+
/bin/sed --in-place -e "s/^session.*required.*pam_loginuid.so/# session\trequired\tpam_loginuid.so/g" /etc/pam.d/*
Vserver with native interface utilizes /dev/initctl. No changes are needed in guests. Just make sure that REBOOT capability is adjusted in guests.|Signature=derjohn}}
+
</pre>
  
{{Question|Question=Do I really need the legacy-interfaces? What are these legacy-interfaces?||Details=
+
'''UPDATE:''' If you are compiling your own kernel this can be fixed system-wide by setting CONFIG_AUDIT_LOGINUID_IMMUTABLE=n in kernels .config file.
A: Since vserver is an ongoing project, new features might replace old ones, some might still on development. Legacy-interfaces are available for backward compability (which might be removed someday). See Q: How can I reboot/halt guests?|Signature=derjohn}}
+
  
{{Question|Question= I have a vserver running on a Linux kernel with preemption. Is VServer "preempt" safe?||Details=
+
|Signature=patrick, SwenTjuln}}
A: 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 :)|Signature=derjohn}}
+
  
{{Question|Question=Is this a new project? When was it started?||Details=
+
{{Question
A: The first public occurance 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
+
|Question=How do i install nagios-plugins on a Gentoo guest?
So you can expect a mature software product wich does it's magic quite well (And hey, we have a version > 2.0 ! )|Signature=derjohn}}
+
||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.
 +
The easiest way to do this from the host (assuming the guest is running) is:
 +
<pre>
 +
vnamespace -e <xid> -- chroot /vservers/<name> emerge nagios-plugins -va
 +
</pre>
 +
|Signature=Hollow}}
  
 +
{{Question
 +
|Question=Somebody runs ntpd in guest and you can't use ntpdate in host?
 +
||Details=Try to run ntpdate with options -u :
 +
ntpdate -u ntp.domain.xy
 +
or you can use command:
 +
chbind --nid 42 --ip 1.2.3.4 -- ntpdate ntp.domain.xy
 +
where IP will be the IP of host.
 +
|Signature=Punkie/Bertl}}
  
{{Question|Question=Can I run an OpenVPN Server in a guest?||Details=
 
A: Yes. I don't want to provide an in-depth OpenVPN tutorial, but want to show how I made OpenVPN work in a guest as server. I was not able to run it with a tun devive, due to a buglet in util-vserver and kernel when it comes to settings a an ip address a point to point link: If you add "ip addr add <ip> peer <mypeer> dev tun0" there is no way to map the tun0 interface into a guest, even not with a 'nodev' option. (bug confirmed to be reproducible by daniel_hoczac)
 
  
First of all you have to prepare the host with a persistent tuntap interface in tap-mode. The tools we need come from the uml-utilities.
 
Then you need to create a device /dev/net/tun, which the OpenVPN userspace daemon reads. Well assume 10.10.10.100 is the server IP, and 10.10.10.101 is the client ip - to be cool be choose a /31 netmask (255.255.255.254), so we have a net without broadcast and don't waste IPs :)
 
  
On the host do:  
+
== Start / Stop a VServer ==
 +
 
 +
{{Question
 +
|Question=How do I make a vserver guest start by default?
 +
||Details=At least on Debian, I can tell you how to do it with the new-style config. If your guest is called "derjohn" and you want it to be started somewhere at the of your bootstrap process, then do:
 
<pre>
 
<pre>
# apt-get install uml-utilities
+
echo "default" > /etc/vservers/derjohn/apps/init/mark
# cd /var/lib/vserver/<myopenvpnserver>/dev/
+
# ./MAKEDEV tun
+
  (creates the dev/net/tun device accessible by te guest - even a tap interface need /dev/net/tun !)
+
# tunctl -t tap0
+
  (creates the network device 'tap0' persistently)
+
 
</pre>
 
</pre>
 +
If you want to start it earlier, please read the init script "/etc/init.d/util-vserver" to find out how to do it. In most cases you don't need to change this. On Debian the vservers are started at "20", so after most other stuff is up (networking etc.).
 +
 +
Besides that I created a small helper script for managing the autostart foo: ((vserver-autostart))|Signature=derjohn}}
  
Then add the ip to the guest:
+
{{Question
 +
|Question=How do I start all vservers with a <tt>mark</tt> value of something other than "default"?
 +
||Details=To start all vservers with a mark value of <tt>foo</tt>, you can use something like:
 
<pre>
 
<pre>
# cat /etc/vservers/<myopenvpnserver>/interfaces/1/ip
+
MARK=foo NUMPARALLEL=42 LOCKFILE=vserver-foo /path/to/util-vserver/vserver-wrapper start
10.10.10.100
+
# cat /etc/vservers/<myopenvpnserver>/interfaces/1/prefix
+
31
+
# cat /etc/vservers/<myopenvpnserver>/interfaces/1/dev
+
tap0
+
(This kind of config brings the ip when the vserver is started - only the tap0 interface has to exist already, see above!)
+
 
</pre>
 
</pre>
  
Here is a sample config for the guest (which is acting as a server):
+
If you want to automate this, you can create a copy of the <tt>/etc/init.d/vservers-default</tt> script called <tt>/etc/init.d/vservers-foo</tt>, set <tt>MARK</tt>, <tt>NUMPARALLEL</tt> and <tt>LOCKFILE</tt> appropriately in it, and have it start at whatever point in the boot process.|Signature=Guy-}}
  
Install OpenVPN package on server and client, in the Debian case:
+
{{Question
 +
|Question=My host works, but when I start a guest it says that it has a problem with chbind.
 +
||Details=You are probably using util-vserver <= 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.
 +
SE Keyword: invalid option `nid' testme.sh
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=What is old-style and new-style config?
 +
||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.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=How can I reboot/halt guests?
 +
||Details=It depends.
 +
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 <guest>.conf file in /etc/vservers for each guest. Please have a look at /etc/init.d/rebootmgr.
 +
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]]
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=What is the initial PATH?
 +
||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.
 +
|Signature=daniel_hozac&Beuc}}
 +
 
 +
{{Question
 +
|Question=When I try to start a guest i get this message "/proc/uptime can not be accessed. Usually, this is caused by procfs-security. Please read the FAQ for more details"?
 +
||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).
 +
|Signature=mattzerah}}
 +
 
 +
{{Question
 +
|Question=When I try to start a guest i get this message "vsched: vc_set_sched(): Function not implemented". 
 +
||Details=After an upgrade of the kernel/tools if you used the old scheduler function you must convert them to cgroup cpu limits. If you do not want limits search and remove/rename /etc/vservers/*/sched/ and the guest will start again. This might also happen when you use a newer kernel patch but did not yet update the vserver utils to a recent version (Thorsten).
 +
|Signature=aqueos}}
 +
 
 +
== Kernel ==
 +
 
 +
{{Question
 +
|Question=Is SMP Supported?
 +
||Details=Yes, on all SMP capable kernel architectures.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=Do I really need the legacy-interfaces? What are these legacy-interfaces?
 +
||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.
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=I have a vserver running on a Linux kernel with preemption. Is VServer "preempt" safe?
 +
||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 :)
 +
|Signature=derjohn}}
 +
 
 +
{{Question
 +
|Question=32 vs 64 Bit? What should I take?
 +
||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:
 
<pre>
 
<pre>
# apt-get install openvpn
+
[*] Kernel support for ELF binaries
 +
<M> Kernel support for MISC binaries
 +
[*] IA32 Emulation <---- without that, the entire 32bit API is not present
 +
<M>  IA32 a.out support 
 
</pre>
 
</pre>
 +
You can force the guest to behave like a 32 environment like this:
 +
<pre>
 +
echo linux_32bit > /etc/vservers/$NAME/personality
 +
echo i686 > /etc/vservers/$NAME/uts/machine
 +
</pre>
 +
(thanks cehteh for the hint!)
  
The server's conf looks like that:
+
But you can force debootstrap to put 32 bit binaries into the guest by 'export ARCH=i386';
 
<pre>
 
<pre>
# port and interface specs
+
export ARCH=i386 ; vserver build ....
 +
</pre>
  
# behave like a ssl-webserver
+
On debian when using the newvserver script "export ARCH=i386" has no effect, just use:
port 443
+
<pre>
proto tcp-server
+
newvserver --arch i386 ...
 +
</pre>
  
# tap device? (keep in mind you need /dev/net/tun !)
+
On debian debootstrap can also be gived the arch option:
dev tap0
+
<pre>
 +
vserver myguest \
 +
build -m debootstrap -n myguest \
 +
--hostname myguest.mydomain.com \
 +
-- -d squeeze -- \
 +
--arch=amd64  (or i386 if you want 32bit)
 +
</pre>
  
# now the ips we will use for the tunnel
+
|Signature=derjohn}}
ifconfig 10.10.10.100 255.255.255.254
+
ifconfig-noexec
+
  
# the server part
+
{{Question
 +
|Question=What does the guest privacy option do in the kernel settings ?
 +
||Details=<pre>
 +
>i was wondering about the real thing that guest privacy does.
 +
#ifdef  CONFIG_VSERVER_PRIVACY
 +
#define VS_ADMIN_P      (0)
 +
#define VS_WATCH_P      (0)
 +
#else
  
# Keep VPN connections, even if the client IP changes
+
> > Does it just prevent the spectator context ?
float
+
 +
it prevents the spectator context and the admin
 +
functionality in all cases which are privacy
 +
sensitive, which includes:
  
# use compression (may also even obfuscate content filters)
+
- ptrace
comp-lzo
+
- devmapper
 +
- devpts
 +
- inode tag permissions
 +
- mountinfo
 +
- kill/signal
 +
- netlink dumps
 +
- tun control
 +
- iopriority
  
# use a static key - create it with 'openvpn --genkey --secret static.key'
+
> > What security do it bring to the system ?
secret static.key
+
  
# dont reload the key after a SIGUSR1
+
together with the VXF_STATE_ADMIN it can be
persist-key
+
used to secure a guest (to some degree) from
 +
unwanted access from the host admin, of course,
 +
as the admin can change the kernel, this is a
 +
voluntary feature which mostly prevents certain
 +
kinds of accidential peeking or guest modification
 +
 +
</pre>
 +
|Signature=ghislain}}
  
# check alive all 10 secs
 
keepalive 10 60
 
  
# verbosity level (from 1 to 9, 9 is max log level)
+
== Distribution specific questions ==
verb 4
+
status openvpn-status.log
+
</pre>
+
  
The client's conf may look like that (This example even makes the tunnel the clients default address):
+
{{Question
<pre>
+
|Question=VServer is included in the stable Debian GNU/Linux for years now. What VS version did they include?
# cat /etc/openvpn/client.conf
+
||Details=There is no support in Debian for Linux-Vserver since the Wheezy release. Debian Squeeze included a 2.6.32 based kernel-package called 2.6.32-5-vserver-ARCH. This contained VServer 2.3.0.36.29.6 with some additional fixes.
# port and interface specs
+
|Signature=scientes}}
  
# the following is not necessary, if you bring up openvpn via Debian's init script:
+
{{Question
daemon ovpn-my-clients-name
+
|Question=Were can I get newer versions of VServer as ready made packages for Debian?
 +
||Details= There are a number of locations
 +
* http://repo.psand.net/info/ has Debian Lenny, Squeeze and Wheezy repositories. Many kernel versions are present. Currently (Febraury 2013) 3.2 kernels are being maintained for Wheezy, with additional packages for 3.4 and 3.10 also available. Architectures available are i386 and amd64. This repository also contains curremt util-vserver builds. Build will shortly begin for Jessie.
 +
* http://www.lihas.de/anleitungen-und-service/linux-vserver-kernel-fuer-debian/linux-vserver-kernel-english details their automatically built repository currently for 3.4 kernels. Building, patching and testing for the kernels is automated.
  
# behave like a ssl-webserver
+
Older unmaintained repositories are/were here:
port 443
+
proto tcp-client
+
remote %%%<insert-the-guest-primary-public-ip-here>%%%%
+
# what device tun ot tap?
+
dev tap
+
  
# now the ips we will use for the tunnel
+
* http://linux-vserver.derjohn.de/ - "my kernels are always 'devel' branch" (derjohn). This repo contain kernels up to 2.6.29 for amd64, 2.6.26 for i386.
ifconfig 10.10.10.101 255.255.255.254
+
* http://backports.debian.org/ contains 2.6.32 backports for Lenny at time of writing (11th May 2010)
 +
* http://zbla.net/debian/ Unofficial debian vserver packages '''WARNING : i386 packets are compiled for 64bits !''' apt source line: ''deb http://zbla.net/debian/ ./'' (N/A as of 2011/12/27)
 +
|Signature=Gremble
 +
}}
  
# Keep VPN connections, even if the client IP changes
+
{{Question
float
+
|Question=Were can I get newer versions of VServer as ready made packages for Ubuntu?
mssfix
+
||Details= There is only one location for
 +
*http://repo-ubuntu.psand.net/dists/ is the only repository maintained for Ubuntu. It covers the same builds as http://repo.psand.net/info/ - and information there should be used, replacing 'precise' as distro in your /etc/apt/source.list.
 +
|Signature=Gremble
 +
}}
 +
== Misc ==
  
# use compression (may also even obfuscate content filters)
+
{{Question
comp-lzo
+
|Question=Why isn't there a device /dev/xyz within a guest?
 +
||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.
 +
|Signature=derjohn}}
  
# use a static key
+
{{Question
secret static.key
+
|Question=I want to (re)mount a virtual filesystem (like tmpfs) in a running guest ... but the guest has no rights (capability) to (re)mount?
 +
||Details=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!).
 +
<pre>
 +
# vnamespace -e XID  mount -t tmpfs -o remount,size=256m,mode=1777 none /var/lib/vservers/<guest>/tmp/
 +
</pre>
 +
(if there's a problem, try expanding the symlinks in the mount path)
 +
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/<guest>/fstab on the host.
  
# dont reload the key after a SIGUSR1
+
If you get:
persist-key
+
<pre>
 +
mount: can't find /var/lib/vservers/<guest>/tmp in /etc/fstab or /etc/mtab
 +
</pre>
 +
then try instead:
 +
<pre>
 +
vnamespace -e builder chroot /var/lib/vservers/<guest>/ mount -o remount,size=64m,mode=1777 /tmp
 +
</pre>
 +
|Signature=derjohn/BenjaminGreen}}
  
# check alive all 10 secs
+
{{Question
keepalive 10 60
+
|Question=How do I bind mount a host directory inside a running guest?
 +
||Details=There are two ways to do this: one is to enter the bind mount in the guest fstab and restart the guest.
  
# verbosity level (from 1 to 9, 9 is max log level)
+
To understand the other way, let me explain how mount namespaces work.
verb 4
+
  
# set the default route
+
Every guest has two mount namespaces associated with it: one "''management namespace''" and one "''operational namespace''".
route-gateway 10.10.10.100
+
redirect-gateway def1
+
# to add special routes you can do it wihtin the openvpn client conf:
+
# route <dest> <mask> <gateway>
+
  
# if you need to connect via proxy (like squid)
+
On starting the guest, first the management namespace is created as a copy of the host namespace (which means that everything that was mounted on the host is mounted in the new namespace as well). This has unwelcome side effects: for example, if you had a cdrom mounted while starting the guest, you wouldn't be able to eject it until you stop the guest even if you umount it on the host, because it's still mounted in the guest. Therefore, the namespace is ''cleaned up'': filesystems that are mounted outside the root of the guest get unmounted in the guest namespace.
# http-proxy s p [up] [auth] : Connect to remote host through an HTTP proxy at
+
#                  address s and port p. If proxy authentication is required,
+
#                  up is a file containing username/password on 2 lines, or
+
#                  'stdin' to prompt from console.  Add auth='ntlm' if
+
#                  the proxy requires NTLM authentication.
+
  
# http-proxy s p [up] [auth]
+
Subsequently, the operational namespace of the guest is created as a copy of the management namespace, and the guest's processes are started in it.
  
 +
To bind mount a host directory in the guest, you must first make that host directory visible in the management namespace of the guest. This is automatically the case if the directory resides inside a mountpoint that exists in the guest namespace as well; however, if the guest config referenced no part of this mountpoint (or it didn't yet exist when you started the guest), then the cleanup mentioned above removed it from the guest's management namespace and you need to re-add it.
  
# http-proxy-option type [parm] : Set extended HTTP proxy options.
+
Let's assume, as an example, that we want a guest to see a subdirectory, called <tt>foo</tt>, of the cdrom we just mounted on the host (e.g. under <tt>/media/cdrom</tt>).
#                                  Repeat to set multiple options.
+
#                  VERSION version (default=1.0)
+
#                  AGENT user-agent
+
  
# http-proxy-option type [parm]
+
Let's enter the management namespace of the guest (that's what <tt>-i 0</tt> is for):
 +
 
 +
<pre>
 +
# vnamespace -i 0 -e <guest-xid> -- /bin/bash
 
</pre>
 
</pre>
  
In the next lesson I will talk about OpenVPN's server mode, which can deal with with multiple clients connecting to one ip and one port (i.e. you only need one guest for tons or 'roadwarriros'), tls connections and pki.
+
Now you have access to all host devices; mount the device that contains your directory wherever you want, but you may prefer to mount it in the same location you used on the host. (Note, though, that it's not even necessary for the device to be mounted in the host namespace at all.)
  
Contributions welcome. :)|Signature=derjohn}}
+
It's likely best to use <tt>mount -n</tt> lest your host <tt>/etc/mtab</tt> get polluted with mounts from other namespaces.
  
{{Question|Question=32 vs 64 Bit? What should I take?||Details=
+
<pre>
A: 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:
+
# mount -n /dev/sr0 /media/cdrom
 +
# exit
 +
</pre>
 +
 
 +
We're now back in the host namespace. <tt>vmount</tt> can now be used to bind mount <tt>/media/cdrom/foo</tt> inside a running guest (in this example, under <tt>/foo</tt> inside the vserver root):
  
 
<pre>
 
<pre>
[*] Kernel support for ELF binaries
+
# vmount guestname -- --bind /media/cdrom/foo /mnt/foo
<M> Kernel support for MISC binaries
+
[*] IA32 Emulation <---- without that, the entire 32bit API is not present
+
<M>  IA32 a.out support 
+
 
</pre>
 
</pre>
 +
|Signature=[[User:KornAndras|Guy-]] 01:31, 10 January 2012 (UTC)}}
  
You can force the guest to behave like a 32 environment like this:
+
{{Question
 +
|Question=How do I mount a device present on the host under a directory in a running guest?
 +
||Details=Use something like:
 
<pre>
 
<pre>
echo linux_32bit > /etc/vservers/$NAME/personality
+
vnamespace -e <guestname> mount -n /dev/<device> /vservers/<guest>/place/you/want/to/mount/it
echo i686 > /etc/vservers/$NAME/uts/machine
+
 
</pre>
 
</pre>
(thanks cehteh for the hint!)
 
  
But you can force debootstrap to but 32 bit binaries into the guest by 'export ARCH=i386';
+
This device can be unmounted with:
 +
 
 
<pre>
 
<pre>
export ARCH=i386 ; vserver build ....  
+
vnamespace -e <guestname> umount -n /vservers/<guest>/place/you/want/to/mount/it
</pre>|Signature=derjohn}}
+
</pre>
 +
 
 +
|Signature=derjohn/BenjaminGreen}}
 +
 
 +
{{Question
 +
|Question=Does anyone know how to increase the size of /tmp within a vserver w/o restarting?
 +
||Details=Use the remount option for mount.
 +
# vnamespace -e XID mount -n -t tmpfs -o remount,size=32m tmpfs /<vdir>/<guest>/tmp
 +
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
 +
# vnamespace -e XID cat /proc/mounts.
 +
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?]]
 +
|Signature=derjohn/dhozac}}
 +
 
 +
 
 +
{{Question
 +
|Question=#1 ERROR:  capset(): Operation not permitted
 +
||Details=capabilities are not enabled in kernel-setup
 +
please check that CONFIG_SECURITY_CAPABILITIES is loaded or included in the kernel. ( check with "cat /path_to_kernel/.config | grep -i cap ")
 +
(2.6.11.5-vs-1.9.5 + 0.30-205)
 +
|Signature=IrcQuestions}}
 +
 
 +
{{Question
 +
|Question=How can I make 'vserver start' mount the root filesystem?
 +
||Details=Mount it via /etc/vservers/vserver-name/fstab, make sure to set the option 'dev' e.g.:
 +
<pre>/dev/drbd0    /      xfs    rw,dev          0 0</pre>
 +
|Signature=AdrianReyer}}
 +
 
 +
 
 +
{{Question
 +
|Question=I deleted a guest's directory without shutting it down. Now I have a "ghost" running. Is there any possibility to get it out of proc without rebooting?
 +
||Details=
 +
vkill --xid <xid> -s 15; sleep 2; vkill --xid <xid> -s 9
 +
 
 +
You will also need to remove guest's ip, for example with:
 +
ip addr del <ip> dev eth0
 +
|Signature=daniel_hozac & gebura }}
 +
 
 +
{{Question
 +
|Question=When using nice and su (for example, in the updatedb cron job), I get: su: Permission denied. What does it mean?
 +
||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:
 +
$ strace nice su nobody
 +
[...]
 +
setpriority(PRIO_PROCESS, 0, 0)        = -1 EACCES (Permission denied)
 +
You can use 'su nobody -c nice some_cmd' instead.
 +
 
 +
The problem is caused by the fact that host system is setting limits for guests (when instructed to do so) and the dropped capability dissallows processess on guest systems to change and increase them later. That means no process on a guest can lower nice value above the limit set by host.
 +
 
 +
If the pam_limits module is activated on a guest system it will first try to '''reset nice value to 0''' even if <tt>/etc/security/limits.conf</tt> file is empty or even if there are lower priority limits set in it. The pam_limits module does that since [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=241663 its developers decided] that it should reset some limits to defaults and start from scratch when applying new restrictions. Unfortunately, already limited guest system won't be able to do it since resetting nice value to 0 means increasing the limit which is forbidden. See [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=311058 Debian Bug report logs - #311058] for more information about that Debian bug.
 +
 
 +
See also [[Frequently_Asked_Questions#Cron is not working on my guest system (which is Debian). How can I fix it?|Cron is not working…]]
 +
 
 +
|Signature=daniel_hozac & Beuc & Paweł Wilk}}
 +
 
 +
{{Question
 +
|Question=Cron is not working on my guest system (which is Debian). How can I fix it?
 +
||Details=On a guest system the cron daemon may not work properly. When looking into the log file (e.g. <tt>/var/log/syslog</tt>) the following message may appear repeatedly:
 +
CRON[xxxxx]: Permission denied
 +
 
 +
Similar thing may happen with the <tt>su</tt> when trying to execute a command as root.
 +
 
 +
It's not the problem in Cron but in the pam_limits module on a guest system (see [[Frequently_Asked_Questions#When using nice and su (for example, in the updatedb cron job), I get: su: Permission denied. What does it mean?|FAQ:When using nice and su…]] for more information about the cause).
 +
 
 +
There are 4 ways to solve or work-around this problem:
 +
 
 +
'''1. Allowing guests to reset resource limits:'''
 +
 
 +
It's clean solution but you may expect some guest processes increasing their limits because not everything is controlled by PAM. It also breaks centralized resources limiting approach so a guest can do bad things that may cause other guests and host to be overloaded and unresponsive.
 +
 
 +
To apply it you have to add <tt>CAP_SYS_RESOURCE</tt> flag to <tt>/etc/vservers/<server name>/bcapabilities</tt> (2.6 kernels).
 +
 
 +
See [[util-vserver:Capabilities_and_Flags|Capabilities and Flags]] for more information.
 +
 
 +
'''2. Disabling pam_limits on a guest systems:'''
 +
 
 +
This workaround is easy and works fine when your guest systems aren't really multiuser but rather service boxes. It disables setting of the resource limits by PAM so the limits can only be set globally for the whole guest (using rlimits or cgroups on a host) but never increased inside of the guest system.
 +
 
 +
To apply it just enter the guest and edit the files listed below, commenting out any line containing <tt>pam_limits</tt>:
 +
 
 +
/etc/pam.d/su
 +
/etc/pam.d/sudo
 +
/etc/pam.d/cron
 +
 
 +
You can also use this one-liner on a guest:
  
{{Question|Question=I want to (re)mount a partition in a running guest ... but the guest has no rights (capability) to (re)mount?||Details=
 
A: 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 tempfs!).
 
 
<pre>
 
<pre>
# vnamespace -e XID  mount -t tmpfs -o remount,size=256m,mode=1777 none /var/lib/vservers/<guest>/tmp/
+
/bin/sed --in-place -e "s/^\s\?session.*pam_limits.so.*/\#\0/g" /etc/pam.d/{su,sudo,cron}
 
</pre>
 
</pre>
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/<guest>/fstab on the host.|Signature=derjohn}}
 
  
 +
'''3. Allowing guest's pam_limits to set limits when possible:'''
  
{{Question|Question=How do I limit a guests RAM? I want to prevent OOM situations on the host!||Details=
+
This workaround allows you to have working <tt>pam_limits</tt> inside a guest system and global limits set by a host system. What's the catch? The problematic PAM module won't fully work for the root user on a guest system as expected and there might appear some PAM's warnings in guest's <tt>auth.log</tt>. Since using pam_limits to limit regular user processes is far more frequent than using it to limit root processes, this solution may be a good compromise. It is about setting a proper limits in pam_limits configuration and about setting this PAM module in a way that its function is optional (instead of required). The last change makes PAM to continue with session even if pam_limits encounters some error during setting limits (it usually applies to superuser sessions).
A: First you can read [http://linux-vserver.org/Memory+Allocation].
+
 
If you want a recipe, do that:
+
The not so nice news is that there might be a need of keeping guest's limits configuration up to date according to limits globally set for a guest. The limits set in pam_limits configuration file(s) shouldn't be higher (lower in case of nice value) than global guest's limits.
1. Check the size of memory pages. On x86 and x86_64 is usually 4 KB per page.
+
 
2. Create /etc/vserver/<guest>/rlimits/
+
To apply it enter the guest and edit the files listed below, replacing occurences of <tt>required</tt> by <tt>optional</tt> in the lines containing <tt>pam_limits</tt>:
3. Check your physical memory size on the host, e.g. with "free -m". maxram = kilobytes/pagesize.
+
 
4. Limit the guests physical RAM to value smaller then maxram:
+
/etc/pam.d/su
 +
/etc/pam.d/sudo
 +
/etc/pam.d/cron
 +
 
 +
For example:
 +
 
 +
# Sets up user limits, please define limits for cron tasks
 +
# through /etc/security/limits.conf
 +
session      optional        pam_limits.so
 +
 
 +
Then on a guest system create the file <tt>/etc/security/limits.d/01-fixpam.conf</tt> containing:
  
 
<pre>
 
<pre>
echo %%insertYourPagesHereSmallerThanMaxram%% > /etc/vserver/<guest>/rlimits/rss
+
*        -        priority        X  # replace X with your guest's nice value
 
</pre>
 
</pre>
  
5. Check your swapspace, e.g. with 'swapon -s'. maxswap = swapkilobytes/pagesize.
+
You can automate this process to happen automagically for any guest by creating the startup script named <tt>/etc/vservers/.defaults/scripts/post-start.d/01-pamfix</tt>:
6. Limit the guest's maximum number of as pages to a value smaller than (maxram+maxswap):
+
  
 
<pre>
 
<pre>
echo %%desiredvalue%% > /etc/vserver/<guest>/rlimits/as
+
#!/bin/sh
 +
 
 +
# This script tries to fix pam_limits entries
 +
# to make it possible for PAM in a guest system to
 +
# set its own limits.
 +
 
 +
PAM_DIR="etc/pam.d"
 +
PAM_SERVICES="su sudo cron"
 +
LIMITS_FILE="etc/security/limits.d/01-pamfix.conf"
 +
 
 +
vname="$2"
 +
[ -z "$vname" ] && exit 0
 +
 
 +
vcfg=$( /usr/sbin/vserver-info "$vname" CFGDIR )
 +
[ ! -d "$vcfg" ] && exit 0
 +
 
 +
for s in $PAM_SERVICES
 +
do
 +
        pamfile="${PAM_DIR#\/}/$s"
 +
        [ -f "$pamfile" ] && /bin/sed --in-place -e "s/\(^\s\?session.*\)required\(.*pam_limits.so.*\)/\1optional\2/g" "$pamfile"
 +
done
 +
 
 +
[ ! -f "${vcfg}/nice" ] && exit 0
 +
nval=$( /usr/bin/head -1 "${vcfg}/nice" )
 +
[ -n "$nval" ] && echo "* - priority $nval # (added by vserver startup script)" > "${LIMITS_FILE#\/}"
 +
 
 +
exit 0
 
</pre>
 
</pre>
  
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 .....|Signature=derjohn}}
+
'''4. Disabling resource limits for a guest:'''
  
 +
It easy, clean and… unsafe solution. You just have to not set resource limits (e.g. priority, nice value) for a guest or set the nice value limit to 0 on a host system. Resetting it later by guest's <tt>pam_limits</tt> will not generate an error.
  
{{Question|Question=Were can I get newer versions of VServer as ready made packages for Debian?||Details=
+
|Signature=Paweł Wilk}}
A: Here you go: http://linux-vserver.derjohn.de/ . There is also some stuff on backports.org, but my kernels are always 'devel' branch.|Signature=derjohn}}
+
  
{{Question|Question=Can I use iptables ?||Details=
+
{{Question
Yes but right now only on the host (rootserver). Please realize that all traffic is local and will not touch the forward chain.|Signature=BeginnerFAQ}}
+
|Question=How do I handle NFS mounts within in a guest?
 +
||Details=There are at least four ways.
  
{{Question|Question=Trying to connect to a vserver from the host or another vserver on the same host fails||Details=
+
In any case, you probably want to force the nfs version to 3 or lower to avoid id mapping issues (one symptom of having an id mapping issue is that <tt>no_root_squash</tt> appears to be ignored). You can check whether the mount uses nfsv4 by looking at <tt>/proc/mounts</tt> inside the guest. You can force the protocol version to 3 by passing the mount options <tt>nfsvers=3,mountvers=3</tt>.
strace shows
+
 
<pre>  
+
'''1)''' Mount the NFS share from the host OS and let vserver guest access it as part of it's file system.
sin_addr=inet_addr("xx.xx.xx.xx")}, yy) = -1 EINVAL (Invalid argument)
+
 
 +
''mount --bind'' may also be beneficial in this scenario.
 +
 
 +
'''2)''' Use util-vserver and create a ''fstab.remote'' file in the /etc/vserver/<vserver_name> directory. Populate this with the NFS shares and they will be mounted in the context of the vserver guest.
 +
 
 +
See http://www.nongnu.org/util-vserver/doc/conf/configuration.html
 +
 
 +
Note that as of 0.30.216-pre3000 and kernel 3.0.4-vs2.3.1-pre10.1, the mount request will appear to originate from the IP of the host, not the guest. It is unclear (to [[User:KornAndras|Guy-]]) whether this is a bug.
 +
 
 +
'''3)''' Add capabilities to the vserver guest instance to grant sufficient rights to allow NFS mounts.
 +
 
 +
Add the following to /etc/vserver/<vserver_name>/bcapabilities
 +
SYS_ADMIN
 +
Add the following to /etc/vserver/<vserver_name>/ccapabilities
 +
SECURE_MOUNT
 +
BINARY_MOUNT
 +
 
 +
See [[Capabilities_and_Flags]] for more information about vserver capabilities.
 +
 
 +
If you want the NFS shares to be mounted when the guest starts, add them to /etc/vserver/<vserver_name>/fstab.
 +
 
 +
'''4)''' Before starting the guest, make a directory of the host "shared" using <tt>mount --make-shared /path/to/dir</tt>, then set up autofs to mount nfs shares under <tt>/path/to/dir/sharename</tt>.
 +
 
 +
rbind mount subdirectories of <tt>/path/to/dir</tt> in the guest from its fstab.
 +
 
 +
This setup is good if the nfs shares are not often needed, and especially if they're occasionally needed by more than one guest. (As of September 2011, running autofs inside a vserver guest didn't work for me. --[[User:KornAndras|Guy-]] 01:05, 30 October 2011 (UTC))
 +
 
 +
||Signature=martindk}}
 +
 
 +
 
 +
{{Question
 +
|Question=vserver start/stop/enter fails with something like "vnamespace: execvp("/usr/sbin/vserver"): No such file or directory" ?
 +
||Details=Check whether ''/usr'' is mounted in the namespace you are working with.
 +
<pre>vnamespace -e <guest> cat /proc/mounts</pre>
 +
If there is no ''/usr'', you can fix your problem with simply mounting it using the following command:
 +
<pre>vnamespace -e <guest> mount /dev/<device> /usr</pre>
 +
 
 +
||Signature=sim0n}}
 +
 
 +
{{Question
 +
|Question=The command vserver <$server> start gives '/etc/init.d/rc: line 74: /etc/default/rcS: No such file or directory', what do I do?
 +
||Details=The vserver has not been correctly installed, this has several reasons
 +
check your install log and it should tell you something about that your server didn't get installed properly
 +
* use stable distribution of debian as server (debootstrap may be different over the versions)
 +
* deny_mount, deny_caps and deny_pivot should be off if your running grsec.
 +
 
 +
||Signature=Dude}}
 +
 
 +
 
 +
{{Question
 +
|Question=How could I rename a vserver directory?
 +
||Details=Please note : this procedure renames the '''directory''', not the '''hostname''' !
 +
#Stop the vserver in question
 +
#rename the <tt>/vservers/<server name></tt> directory
 +
#rename the <tt>/etc/vservers/<server name></tt> directory
 +
#update link: <tt>/etc/vservers/<server name>/run</tt> → <tt>/var/run/vservers/<server name></tt>
 +
#update link: <tt>/etc/vservers/<server name>/vdir</tt> → <tt>/etc/vservers/.defaults/vdirbase/<server name></tt>
 +
#update link: <tt>/etc/vservers/<server name>/cache</tt> → <tt>/etc/vservers/.defaults/cachebase/<server name></tt>
 +
#update link: <tt>/var/run/vservers.rev/<server XID></tt> → <tt>/etc/vservers/<server name></tt>
 +
#Start the vserver in question. It should start properly.
 +
 
 +
|Signature=FlorianD (from ''hillct'' page in old wiki)}}
 +
 
 +
 
 +
{{Question
 +
|Question=what if i see my vserver in vserver-stat but with no name ?
 +
||Details=the link in /var/run/vservers is missing
 +
Just do a :  cat /etc/vservers/<guest>/context >  /var/run/vservers/<guest>
 +
check that the <guest> is the good one by using  vuname --get --xid <context>  with the context you have in the vserver-stat listing.
 +
|Signature=IrcQuestions}}
 +
 
 +
== Upgrade from 2.0 to 2.2 ==
 +
 
 +
{{Question
 +
|Question=I now get errors like "ncontext: vc_net_create(): Invalid argument; dynamic contexts disabled." on startup. Vservers are not started
 +
||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
 +
echo 101 > /etc/vservers/myvserv/context
 +
ADDENDUM: please consider that valid static contexts are between 2 and 49151 ( daniel_hozac on IRC ) otherwise you will end up with unexplainable error "ncontext: vc_net_migrate(): No such process" when trying to start the vserver.
 +
 
 +
|Signature=daniel_hozac&Beuc}}
 +
 
 +
 
 +
{{Question
 +
|Question=How do I assign a static context to an existing vserver?
 +
||Details=Simple ;) See the answer above.
 +
|Signature=gcc}}
 +
 
 +
 
 +
{{Question
 +
|Question=Since upgrading to a newer VS version my guest complains about "vsched: non-numeric value specified for '--priority_bias" at start time. What's wrong?
 +
||Details=The scheduler paramters changed.You can use this (ugly) script to convert them or do it by hand:
 +
<pre>
 +
# cat /usr/local/sbin/vserver-convert-schedule-to-scheddir
 +
#/bin/sh
 +
mkdir /etc/vservers/$1/sched
 +
sed -e 1p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/fill-rate
 +
sed -e 2p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/interval
 +
sed -e 3p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/tokens
 +
sed -e 4p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/tokens-min
 +
sed -e 5p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/tokens-max
 +
 
 +
mv /etc/vservers/$1/schedule /etc/vservers/$1/schedule.converted.see.scheddir
 +
 
 +
# see: http://oldwiki.linux-vserver.org/Scheduler+Parameters
 +
# see: http://www.nongnu.org/util-vserver/doc/conf/configuration.html#sched
 
</pre>
 
</pre>
A: The host/guest cannot communicate with another guest on same host.
+
||Signature=derjohn}}
* check all netmasks on all interfaces (do they overlap) ?
+
* check policy routing (disable it temporary) ?
+
* check that lo is up (Networking within a host/guest always uses lo interface)
+
|Signature=CommonProblems}}
+
  
{{Question|Question=#1 ERROR:  capset(): Operation not permitted||Details=capabilities are not enabled in kernel-setup
 
please check that CONFIG_SECURITY_CAPABILITIES is loaded or included in the kernel. ( check with "cat /path_to_kernel/.config | grep -i cap ")
 
(2.6.11.5-vs-1.9.5 + 0.30-205)|Signature=IrcQuestions}}
 
  
{{Question|Question=How can I make 'vserver start' mount the root filesystem||Details=
+
{{Question
mount it via /etc/vservers/vserver-name/fstab, make sure to set the option 'dev' e.g.:
+
|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?
<pre>/dev/drbd0    /      xfs    rw,dev          0 0</pre>
+
||Details=Every VS version that runs on a kernel >= 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.
util-vserver 210 won't be able to find some scripts for the reboot, add into /etc/vservers/vserver-name/apps/init/cmd.stop
+
Here is an example how to do so:
<pre>/etc/init.d/rc
+
6</pre>
+
|Signature=AdrianReyer}}
+
  
{{Question|Question=How do I tag a guest's directory with xid?||Details=
+
<pre>
Tagging the guest's files gives you serveral advantages, e.g. the accoutung will work properly.
+
# mkdir /etc/vservers/<vserver>/sysctl/0 -p
Filesystem XID tagging only works on supported filesystem. Those are currently: ext2/3, reiserfs/reiser3, xfs and jfs.
+
# echo kernel.shmall > /etc/vservers/<vserver>/sysctl/0/setting
To activate the XID tagging you have to mount the filesystem with "-o tagxid". Attention: It's _not_ possible to "-o remount,tagxid", 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:
+
# echo 134217728 > /etc/vservers/<vserver>/sysctl/0/value
<pre>chxid -c xid -R /var/lib/vservers/<guest></pre>
+
# mkdir /etc/vservers/<vserver>/sysctl/1 -p
|Signature=derjohn_and_gonzo}}
+
# echo kernel.shmmax > /etc/vservers/<vserver>/sysctl/1/setting
 +
# echo 134217728 > /etc/vservers/<vserver>/sysctl/1/value
 +
</pre>
 +
It's also explained on the geat flower page:
 +
# see: http://www.nongnu.org/util-vserver/doc/conf/configuration.html -> Look for "sysctl".
 +
 
 +
After changing those values, restart your guest, enter it and check if the values are set:
 +
<pre>
 +
# sysctl -a | grep shm
 +
...
 +
kernel.shmall = 134217728
 +
kernel.shmmax = 134217728
 +
</pre>
 +
 
 +
To change a value for a running guest, on the host use:
 +
<pre>
 +
vspace -e CONTEXTID --ipc sysctl -w kernel.shmall=134217728
 +
vspace -e CONTEXTID --ipc sysctl -w kernel.shmmax=134217728
 +
</pre>
 +
 
 +
||Signature=derjohn
 +
}}
  
More FAQs to be merged;
+
[[Category:Community]]
[http://www.linux-vserver.org/Frequently_Asked_Questions_scratch]
+
[[Category:Categories]]

Latest revision as of 17:01, 20 February 2018

Icon-Caution.png

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 old wiki to find the information not migrated yet.

To ease migration we created a List of old Documentation pages.

CURRENTLY THE CONTENT OF THE OLD WIKI FAQ (AND MORE) IS BEING MIGRATED TO THIS PAGE (TASK: DERJOHN)


Contents


General

What is the status of Linux-VServer?

Linux-VServer has more than a decade of maturity and is actively developed. Two projects are similar to Linux-VServer, [LXC], and [OpenVZ]. Of the two, OpenVZ is the more mature and offers some similar functionality to Linux-VServer. LXC is solely based on the kernel mechanisms such as cgroups that are present in modern kernels. These kernel mechanisms will continue to be refined and isolation will mature. As that occurs, Linux-VServer will take advantage of those new features separately from LXC and continue to provide the same robust user interface that it does currently. Currently, LXC offers significantly less functionality and isolation than Linux-vserver. LXC will eventually be a robust wrapper around kernel mechanisms but is still under heavy development and not considered ready for production use.
beck




What is a 'Guest'?

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'.
derjohn




What kind of Operating System (OS) can I run as guest?

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.
derjohn



Is this a new project? When was it started?

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 So you can expect a mature software product which does its magic quite well (And hey, we have a version > 2.0!)
derjohn



Which distributions did you test?

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.
derjohn



Is VServer comparable to XEN/UML/QEMU?

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 "emulate" 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.
derjohn



With which version should I begin?

If you are new to VServer I recommend to try the latest stable kernel patch, and the latest util-vserver "alpha" release.
derjohn



Is VServer secure?

We hope so. It should be as least as secure as Linux is. We consider it much much more secure though.
derjohn



Performance?

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).
derjohn




What is the "great flower page"?

Well, this page contains all configuration options for util-vserver. The name of the page is derived from the stylesheet(s) it contains.
derjohn




Resources usage

Resource sharing?

Yes ....
  • memory: Dynamically.
  • CPU usage: Dynamically (token bucket)
derjohn



Resource limiting?

You can put limits per guest on different subsystems.
  • 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
  • CPU usage : see CPU Scheduler
  • disk space usage : see Disk Limits and Quota
Note that you can only offer guaranteed resource availability with some ticks at the time.
derjohn&xm



How do I limit a guests RAM? I want to prevent OOM situations on the host!

First you can read [1] and Memory Limits.

If you want a recipe, do this:

  1. Check the size of memory pages. On x86 and x86_64 is usually 4 KB per page. (on linux "getconf -a
derjohn




Disk I/O limiting? Is that possible?

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:
# cat /sys/block/hdc/queue/scheduler
noop [anticipatory] deadline cfq

The default since 2.6.18 in Sept 2006 is CFQ, described below, and prior to that was anticipatory a.k.a. "AS" ([Wikipedia]). 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 "completely fair queueing" scheduler, CFQ, which can do that. (More on schedulers can be found at http://lwn.net/Articles/114770/) This is how to set the scheduler to "cfq" manually:

root# echo "cfq" > /sys/block/hdc/queue/scheduler
root# cat /sys/block/hdc/queue/scheduler
noop anticipatory deadline [cfq]

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! If you run Debian there is a predefined way to set the /sys values at boot-time:

# apt-get install sysfsutils
[...]

# grep cfq /etc/sysfs.conf
block/sda/queue/scheduler = cfq
block/sdc/queue/scheduler = cfq

# /etc/init.d/sysfsutils restart

For non-vserver processes and CFQ you can set by which key the kernel decides about the fairness:

cat /sys/block/hdc/queue/iosched/key_type
pgid [tgid] uid gid

Hint: The 'key_type'-feature has been removed in the mainline kernel recently. Don't look for it any longer :(

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 "noop" 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.

And: It's possible to tune the scheduler parameters in several ways. Have a look at /sys/block/hdc/queue/....
derjohn



Nice disk I/O scheduling, is that possible?

Well, since linux 2.6.13 processess have another priority next to the cpu nice scheduling hint, it's called io nice.

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. You can set this niceness by the tool ionice, which for debian is either in the package util-linux or schedutils. To change the io-niceness you need the CAP_SYS_NICE, and need to have the same uid as the processe you want to ionice.

Note: If you want to use any schedulung other than best-effort you will also need the CAP_SYS_ADMIN-flag. Be warned that this gives quite some capabilities to the vserver, not just for I/O scheduling!

If you want to increase the niceness of an I/O hogging process within a vserver you need to do:

chcontext --xid sponlp1 sudo -u '#2089' ionice -c2 -n5 -p24409
with sudo and ionice installed on the root server to increase the *nice*ness of pid 24409, with uid 2089
Groteblup



I want iotop to display all guest processes on host to give me a nice overview of I/O usage.

You must allow iotop to read information from all guests. Add
# setattr --watch /proc/vmstat

to, for example, rc.local, and later run iotop:

# vcontext --migrate --xid 1 -- iotop
corey via ser



Unification

What is unification (vunify)?

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.
derjohn



What is vhashify?

The successor of vunify, a tool which does unification based on hash values (which allows to find common files in arbitrary paths.)

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. 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 (?).


Guy-


Note: hashify cannot cross XFS project QUOTA because hardlinks cannot cross projects.



How do I manage a multi-guest setup with vhashify?

For 'vhashify', just do these once:
mkdir /etc/vservers/.defaults/apps/vunify/hash /vservers/.hash
ln -s /vservers/.hash /etc/vservers/.defaults/apps/vunify/hash/root

Then, do this one line per vserver:

mkdir /etc/vservers/<vservername>/apps/vunify   # vhashify reuses vunify configuration

To hashify a running vserver, do (possibly from a cronjob):

vserver name-of-guest hashify

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 vserver enter.

In order for the OS cache to benefit from the hardlinking, you'll have to restart the vservers.

To clean up hashified files that are no longer referenced by any vserver, do (possibly from a cronjob):

find /vservers/.hash -type f -links 1 -print0 | xargs -0 rm
Until you do this, the files still take up place even though no vservers need them.
Guy-



Filesystem usage

Is there a way to implement "user/group quota" per VServer?

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 "options vroot max_vroot=20" in /etc/modprobe.conf and then just do modprobe vroot
derjohn,gadnet



What about "Quota" for a context? Howto limit disk usage?

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.
derjohn



How do I tag a guest's directory with xid?

Tagging the guest's files gives you several advantages, e.g. the accounting will work properly.

Filesystem XID tagging only works on supported filesystem. Those are currently: ext2/3, reiserfs/reiser3, xfs and jfs. To activate the XID tagging you have to mount the filesystem with "-o tag" (former tagxid is outdated since VS2.2). Attention: It's _not_ possible to "-o remount,tag", 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:

chxid -c xid -R /var/lib/vservers/<guest>

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.

Note: It is not advised to tag the root filesystem, as explained by Herbert : trying to do so will expose you to some troubles !
derjohn_and_gonzo_and_are



How can I copy anything from host to guest partition, normally unvisible on host?

You should just change namespace, e.g.:
vnamespace --enter <xid> -- /bin/bash
and then use standard cp or rsync programs.
SergiuszPawlowicz



Why is the barrier attribute disappearing on reiserfs filesystem after umount or host reboot?

The filesystem has to be mounted with explicitly defining the 'attrs' option, i.e.
mount /dev/reiserfsdev /vservers -oattrs
setattr --barrier /vservers
to get the barrier survive after umount/reboot.
Nikolay Kichukov



Network

Does it support IPv6?

Currently it requires an additional patch, but the functionality should be available in 2.3+ soon. IPv6 has more information.
derjohn



I can't do all I want with the network interfaces inside the guest?

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.
derjohn



How do I add several IPs to a vserver?

First of all a single guest vserver only supports up to 16 IPs (There is a 64-IP patch available, which is in "derjohn's kernel").
Update from IRC (2011-08-22):
<mmouse> quick question: what is the maximum count of IPs (v4) I can have in a single guest?
<daniel_hozac> unlimited.

Here is a little helper-script that adds a list of IPs defined in a text file, one per line.

#!/bin/bash
j=1
for i in `cat myiplist`; do
        j=$(($j+1))
        mkdir $j
        echo $i > $j/ip
        echo "24" > $j/prefix
done
derjohn



How do I assign a new IP address to a running guest?

This is done from the host server:
  • add the ip on the host, for example
ip addr add 194.169.123.23/24 dev eth0 
  • add the ip to the guest's network context (a guests NID is the same as the XID {context ID})
naddress --add --nid <nid> --ip 194.169.123.23/24 
  • enter the guest (best via ssh)
  • restart the services that need to make use of the new address if required
  • update the config in /etc/vserver/<servername>/interfaces to reflect the changes for the next guest restart (if desired)
BenjaminGreen



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?

Yes, use iptables with SNAT to masquerade it.
iptables -t nat -I POSTROUTING -s $VSERVER_NETZ  ! -d $VSERVER_NETZ -j SNAT --to $EXT_IP

See: HowtoPrivateNetworking and

http://www.tgunkel.de/it/software/doc/linux_server.en#h3-VServer_Masquerading_SNAT (THX, [MUPPETS]Gonzo)
derjohn



If I shut down my vserver guest, the whole Internet interface ethX on the host is shut down. What happened?

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. Similarly, if your guests bring up IPs of more than one subnet, all other IPs from a specific subnet will be shut down if you stop the guest which created the first ("parent") IP.

You can check this on the host using the command "ip addr show". Example output:

1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:01:02:03:04:05 brd ff:ff:ff:ff:ff:ff
    inet 192.168.249.172/27 brd 192.168.249.191 scope global eth0
    inet 192.168.234.194/27 brd 192.168.234.223 scope global eth0
    inet 192.168.249.169/27 brd 192.168.249.191 scope global secondary eth0
    inet 192.168.234.195/27 brd 192.168.234.223 scope global secondary eth0

In this example, if you stop the guest which brings down the IP 192.168.249.172, the IP 192.168.249.169 will be brought down as well, because it is a secondary IP of the "parent" 192.168.249.172.

But in very recent kernels, there is an option settable which prevents that nasty feature. It's called "alias promotion". You may set it via sysctl by adding net.ipv4.conf.all.promote_secondaries=1 in /etc/sysctl.conf or via sysctl command line.
derjohn, Hurga



Can I run an OpenVPN Server in a guest?

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.

This is the minimal OpenVPN configuration for the Server which will be used to demonstrate how to get it running in a client:

# Networking setup
server 192.168.16.0     255.255.255.0
dev tun16
ifconfig-noexec
comp-lzo
# Certificates
dh ...
ca ...
cert ...
key ...
# Management
persist-key
keepalive 10 60
verb 4

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.

# openvpn --mktun --dev tun16
# ip link set dev tun16 txqueuelen 100
# ifconfig tun16 192.168.16.1 pointopoint 192.168.16.2 mtu 1500
# route add -net 192.168.16.0 netmask 255.255.255.0 gw 192.168.16.2

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. Additionally, the guest needs /dev/net/tun to make OpenVPN happy. This can be created with MAKEDEV:

# cd /var/lib/vserver/<myopenvpnserver>/dev/
# ./MAKEDEV tun
  (creates the dev/net/tun device accessible by the guest - even a tap interface needs /dev/net/tun !)

Finally, the guest needs to have the tun device assigned:

# head /etc/vservers/<myopenvpnserver>/interfaces/1/*
==> /etc/vservers/<myopenvpnserver>/interfaces/1/ip <==
192.168.16.1

==> /etc/vservers/<myopenvpnserver>/interfaces/1/nodev <==
tun16

==> /etc/vservers/<myopenvpnserver>/interfaces/1/prefix <==
24
#

The client's conf may look like that:

# Basic setup
client
proto tcp-client
dev tun
remote <ipaddress>
comp-lzo
verb 4

# Certificate
ca ...
[ Based on derJohn's original answer, all errors mine ]
DavidS



Trying to connect to a vserver from the host or another vserver on the same host fails

strace shows
 
sin_addr=inet_addr("xx.xx.xx.xx")}, yy) = -1 EINVAL (Invalid argument)

A: The host/guest cannot communicate with another guest on same host.

  • check all netmasks on all interfaces (do they overlap) ?
  • check policy routing (disable it temporary) ?
  • check that lo is up (Networking within a host/guest always uses lo interface)
CommonProblems



Can I use iptables ?

Yes but right now only on the host (rootserver). Please realize that all traffic is local and will not touch the forward chain.
If you really, really, really need iptables on the guest and you are aware about loosing a big part of VServer isolation and security you could add the NET_ADMIN capability. Consider writing wrappers to manage iptables on the host instead.
_are_



Is it possible to prevent guest from bringing down primary ip?

Yes. Remove /etc/vservers/<guest>/interfaces/X/dev, and touch /etc/vservers/<guest>/interfaces/X/nodev
Daniel&Serge



Is it possible to provide a different MAC address per vServer?

Short answer - yes but it's a hassle.

Real answer from _are_:

When I once needed 'real' seperate MAC-addresses I used TAP-devices and VDE2 ([http://vde.sourceforge.net/ Virtual Distributed Ethernet]).
Basically vServer is an isolation of existing resources, not a virtualization of 'new' devices.
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.
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.


You can also utilize MACVLAN ability from kernel. I.e. create macvlan0 interface with:

ip link add link eth0 address 00:19:d1:29:d2:58 macvlan0 type macvlan
[Reference]
bobnormal&swenTjuln



Is it possible to hide packet counters on the host network interface from vServer guests?

bobnormal



Services won't bind to 127.0.0.1 when I configure them to bind to all available IPs / (binding service to * doesn't bind to loopback)?

You've configured single public IP and have kernel option "Linux VServer -> Automatic Single IP Special Casing" enabled.

It means somehow "optimized" :D If you don't want this you have 3 possible solutions (quoting Bertl):

 * disable the auto single IP in the kernel
 * assign more than one IP to the guest
 * disable single ip special casing for that guest

The later is done by : echo "~single_ip" >> /etc/vservers/<VSERVER>/nflags

At runtime to avoid restarting the vserver: nattribute --set --nid <guest> --flag ~single_ip
swenTjuln



When using network namespaces and vserver together, netstat does not work in the vserver. What's wrong?

All proc entries are hidden by default in the guests. During startup of the host system a tool called vprocunhide makes some /proc files visible.

If you create a new network namespace you have to do the same in the network namespace because the new /proc/net files are not available for the vprocunhide outside the new network namespace. So something like that should be sufficient to get netstat working in vservers with network namespaces:

ip netns exec $NAMESPACE /usr/lib/util-vserver/vprocunhide
AlexanderS



Administration tools

Which guest vservers are running?

Use vserver-stat to find out. Example output:
CTX   PROC    VSZ    RSS  userTIME   sysTIME    UPTIME NAME
0       77 965.1M 334.6M  14m14s18   2m28s69   1h33m46 root server
49152    7    14M   5.2M   0m00s40   0m00s30   1h30m15 chiffon
derjohn




Is there a web-based interface for vserver that will allow creation/deletion/configuration etc. of vserver guests?

* http://OpenVPS.org which is a set of scripts with a web-interface for webhosters/ISPs
  • http://Openvcp.org which is a distributed system (agent!) with a web-interface, with which you can build/remove guests
  • http://vsmon.revolutionlinux.com/ is a distributed monitoring-only solution that allows you to search for a particular vserver in your park.
derjohn



Hosting foreign distributions

I run a Debian host and want to build an Ubuntu guest. Howto?

Simple ;) Assume you want to build a breezy guest on a sid host with IP 192.168.0.2 and hostname vubuntu, then do:
vserver vubuntu build --force -m debootstrap --hostname vubuntu.myvservers.net --netdev eth0 --interface 192.168.0.2/24 \
--context 42 -- -d breezy -m http://de.archive.ubuntu.com/ubuntu

[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:

vserver vubuntu build --force -m debootstrap --hostname vubuntu.myvservers.net --netdev eth0 --interface 192.168.0.2/24 \
--context 42 -- -d breezy -m http://de.archive.ubuntu.com/ubuntu -- --exclude=udev

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)

Well, sid's debootstrap knows how to bootstrap Ubuntu linux. Make sure to have a current debootstrap package:

apt-get update
apt-get install debootstrap
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.
derjohn




I want to build a Gentoo guest. Howto?

gcc



Application level problems

I did everything right, but the application foo does not start. What's up there?

Before asking on the IRC channel, please check out the 'problematic programs' page: Problematic Programs
derjohn



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?

Look at /etc/ssh/sshd_config of the host:
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::

And now change the setting to

Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
ListenAddress your.hosts.ip.here  # not the guests IP! 

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.) 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.

(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.)
derjohn



Bind9 does not like to start in my guest.

Check out the Problematic Programs page and/or get my vserver-guest-ready Debian package for Debian Sid guests and check out the readme. (Hint: This is fresh stuff. Please give me feedback) [UPDATE] Since VServer Devel 2.1.1-rc18 you do not need to patch the userland tools anymore. The capabilities are masked.
derjohn



My mysqld running in a guest behaves strangely and is awfully slow/locks up

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.

If you prefer not to modify or disable tmpfs, you can reconfigure MySQL to use a different tmpdir such as "/var/tmp". For example, edit /etc/my.cnf (RHEL/CentOS) or create /etc/mysql/conf.d/mysqld_custom.conf (Debian) and add the following line:

tmpdir = /var/tmp
Afterwards, restart MySQL (/etc/init.d/mysqld restart) and then review MySQL variables (mysqladmin -uroot -p variables) to confirm "tmpdir" is no longer pointing to "/tmp".
sp, jrklein



Pure-FTP does not run inside a VServer?

That's because it has capabilities enabled, make sure you rebuild your distro's package passing also the `--without-capabilities` flag to configure.
Pedro Algarvio, aka, s0undt3ch



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.

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:

pam authentication (also used with openssh) enables "pam_loginuid.so" 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:

/bin/sed --in-place -e "s/^session.*required.*pam_loginuid.so/# session\trequired\tpam_loginuid.so/g" /etc/pam.d/*
UPDATE: If you are compiling your own kernel this can be fixed system-wide by setting CONFIG_AUDIT_LOGINUID_IMMUTABLE=n in kernels .config file.
patrick, SwenTjuln



How do i install nagios-plugins on a Gentoo guest?

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.

The easiest way to do this from the host (assuming the guest is running) is:

vnamespace -e <xid> -- chroot /vservers/<name> emerge nagios-plugins -va
Hollow



Somebody runs ntpd in guest and you can't use ntpdate in host?

Try to run ntpdate with options -u :
ntpdate -u ntp.domain.xy

or you can use command:

chbind --nid 42 --ip 1.2.3.4 -- ntpdate ntp.domain.xy
where IP will be the IP of host.
Punkie/Bertl




Start / Stop a VServer

How do I make a vserver guest start by default?

At least on Debian, I can tell you how to do it with the new-style config. If your guest is called "derjohn" and you want it to be started somewhere at the of your bootstrap process, then do:
echo "default" > /etc/vservers/derjohn/apps/init/mark

If you want to start it earlier, please read the init script "/etc/init.d/util-vserver" to find out how to do it. In most cases you don't need to change this. On Debian the vservers are started at "20", so after most other stuff is up (networking etc.).

Besides that I created a small helper script for managing the autostart foo: ((vserver-autostart))
derjohn



How do I start all vservers with a mark value of something other than "default"?

To start all vservers with a mark value of foo, you can use something like:
MARK=foo NUMPARALLEL=42 LOCKFILE=vserver-foo /path/to/util-vserver/vserver-wrapper start
If you want to automate this, you can create a copy of the /etc/init.d/vservers-default script called /etc/init.d/vservers-foo, set MARK, NUMPARALLEL and LOCKFILE appropriately in it, and have it start at whatever point in the boot process.
Guy-



My host works, but when I start a guest it says that it has a problem with chbind.

You are probably using util-vserver <= 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. SE Keyword: invalid option `nid' testme.sh
derjohn



What is old-style and new-style config?

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.
derjohn



How can I reboot/halt guests?

It depends.

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 <guest>.conf file in /etc/vservers for each guest. Please have a look at /etc/init.d/rebootmgr.

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
derjohn



What is the initial PATH?

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.
daniel_hozac&Beuc



When I try to start a guest i get this message "/proc/uptime can not be accessed. Usually, this is caused by procfs-security. Please read the FAQ for more 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).
mattzerah



When I try to start a guest i get this message "vsched: vc_set_sched(): Function not implemented".

After an upgrade of the kernel/tools if you used the old scheduler function you must convert them to cgroup cpu limits. If you do not want limits search and remove/rename /etc/vservers/*/sched/ and the guest will start again. This might also happen when you use a newer kernel patch but did not yet update the vserver utils to a recent version (Thorsten).
aqueos



Kernel

Is SMP Supported?

Yes, on all SMP capable kernel architectures.
derjohn



Do I really need the legacy-interfaces? What are these legacy-interfaces?

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.
derjohn



I have a vserver running on a Linux kernel with preemption. Is VServer "preempt" safe?

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 :)
derjohn



32 vs 64 Bit? What should I take?

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:
[*] Kernel support for ELF binaries
<M> Kernel support for MISC binaries
[*] IA32 Emulation <---- without that, the entire 32bit API is not present
<M>   IA32 a.out support  

You can force the guest to behave like a 32 environment like this:

echo linux_32bit > /etc/vservers/$NAME/personality
echo i686 > /etc/vservers/$NAME/uts/machine

(thanks cehteh for the hint!)

But you can force debootstrap to put 32 bit binaries into the guest by 'export ARCH=i386';

export ARCH=i386 ; vserver build .... 

On debian when using the newvserver script "export ARCH=i386" has no effect, just use:

newvserver --arch i386 ...

On debian debootstrap can also be gived the arch option:

vserver myguest \
build -m debootstrap -n myguest \
--hostname myguest.mydomain.com \
-- -d squeeze -- \
--arch=amd64  (or i386 if you want 32bit)
derjohn



What does the guest privacy option do in the kernel settings ?

>i was wondering about the real thing that guest privacy does. 
#ifdef  CONFIG_VSERVER_PRIVACY
#define VS_ADMIN_P      (0)
#define VS_WATCH_P      (0)
#else

> > Does it just prevent the spectator context ? 
 
it prevents the spectator context and the admin 
functionality in all cases which are privacy
sensitive, which includes:

 - ptrace
 - devmapper
 - devpts
 - inode tag permissions
 - mountinfo
 - kill/signal
 - netlink dumps
 - tun control
 - iopriority

> > What security do it bring to the system ?

together with the VXF_STATE_ADMIN it can be
used to secure a guest (to some degree) from
unwanted access from the host admin, of course,
as the admin can change the kernel, this is a
voluntary feature which mostly prevents certain
kinds of accidential peeking or guest modification
 
ghislain



Distribution specific questions

VServer is included in the stable Debian GNU/Linux for years now. What VS version did they include?

There is no support in Debian for Linux-Vserver since the Wheezy release. Debian Squeeze included a 2.6.32 based kernel-package called 2.6.32-5-vserver-ARCH. This contained VServer 2.3.0.36.29.6 with some additional fixes.
scientes



Were can I get newer versions of VServer as ready made packages for Debian?

There are a number of locations

Older unmaintained repositories are/were here:

Gremble



Were can I get newer versions of VServer as ready made packages for Ubuntu?

There is only one location for
Gremble


Misc

Why isn't there a device /dev/xyz within a guest?

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.
derjohn



I want to (re)mount a virtual filesystem (like tmpfs) in a running guest ... but the guest has no rights (capability) to (re)mount?

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!).
# vnamespace -e XID  mount -t tmpfs -o remount,size=256m,mode=1777 none /var/lib/vservers/<guest>/tmp/

(if there's a problem, try expanding the symlinks in the mount path) 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/<guest>/fstab on the host.

If you get:

mount: can't find /var/lib/vservers/<guest>/tmp in /etc/fstab or /etc/mtab

then try instead:

vnamespace -e builder chroot /var/lib/vservers/<guest>/ mount -o remount,size=64m,mode=1777 /tmp
derjohn/BenjaminGreen



How do I bind mount a host directory inside a running guest?

There are two ways to do this: one is to enter the bind mount in the guest fstab and restart the guest.

To understand the other way, let me explain how mount namespaces work.

Every guest has two mount namespaces associated with it: one "management namespace" and one "operational namespace".

On starting the guest, first the management namespace is created as a copy of the host namespace (which means that everything that was mounted on the host is mounted in the new namespace as well). This has unwelcome side effects: for example, if you had a cdrom mounted while starting the guest, you wouldn't be able to eject it until you stop the guest even if you umount it on the host, because it's still mounted in the guest. Therefore, the namespace is cleaned up: filesystems that are mounted outside the root of the guest get unmounted in the guest namespace.

Subsequently, the operational namespace of the guest is created as a copy of the management namespace, and the guest's processes are started in it.

To bind mount a host directory in the guest, you must first make that host directory visible in the management namespace of the guest. This is automatically the case if the directory resides inside a mountpoint that exists in the guest namespace as well; however, if the guest config referenced no part of this mountpoint (or it didn't yet exist when you started the guest), then the cleanup mentioned above removed it from the guest's management namespace and you need to re-add it.

Let's assume, as an example, that we want a guest to see a subdirectory, called foo, of the cdrom we just mounted on the host (e.g. under /media/cdrom).

Let's enter the management namespace of the guest (that's what -i 0 is for):

# vnamespace -i 0 -e <guest-xid> -- /bin/bash

Now you have access to all host devices; mount the device that contains your directory wherever you want, but you may prefer to mount it in the same location you used on the host. (Note, though, that it's not even necessary for the device to be mounted in the host namespace at all.)

It's likely best to use mount -n lest your host /etc/mtab get polluted with mounts from other namespaces.

# mount -n /dev/sr0 /media/cdrom
# exit

We're now back in the host namespace. vmount can now be used to bind mount /media/cdrom/foo inside a running guest (in this example, under /foo inside the vserver root):

# vmount guestname -- --bind /media/cdrom/foo /mnt/foo
Guy- 01:31, 10 January 2012 (UTC)



How do I mount a device present on the host under a directory in a running guest?

Use something like:
vnamespace -e <guestname> mount -n /dev/<device> /vservers/<guest>/place/you/want/to/mount/it

This device can be unmounted with:

vnamespace -e <guestname> umount -n /vservers/<guest>/place/you/want/to/mount/it
derjohn/BenjaminGreen



Does anyone know how to increase the size of /tmp within a vserver w/o restarting?

Use the remount option for mount.
# vnamespace -e XID mount -n -t tmpfs -o remount,size=32m tmpfs /<vdir>/<guest>/tmp

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

# vnamespace -e XID cat /proc/mounts.
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?
derjohn/dhozac




#1 ERROR: capset(): Operation not permitted

capabilities are not enabled in kernel-setup please check that CONFIG_SECURITY_CAPABILITIES is loaded or included in the kernel. ( check with "cat /path_to_kernel/.config
IrcQuestions



How can I make 'vserver start' mount the root filesystem?

Mount it via /etc/vservers/vserver-name/fstab, make sure to set the option 'dev' e.g.:
/dev/drbd0     /       xfs     rw,dev          0 0
AdrianReyer




I deleted a guest's directory without shutting it down. Now I have a "ghost" running. Is there any possibility to get it out of proc without rebooting?

vkill --xid <xid> -s 15; sleep 2; vkill --xid <xid> -s 9

You will also need to remove guest's ip, for example with:

ip addr del <ip> dev eth0
daniel_hozac & gebura



When using nice and su (for example, in the updatedb cron job), I get: su: Permission denied. What does it mean?

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:
$ strace nice su nobody
[...]
setpriority(PRIO_PROCESS, 0, 0)         = -1 EACCES (Permission denied)

You can use 'su nobody -c nice some_cmd' instead.

The problem is caused by the fact that host system is setting limits for guests (when instructed to do so) and the dropped capability dissallows processess on guest systems to change and increase them later. That means no process on a guest can lower nice value above the limit set by host.

If the pam_limits module is activated on a guest system it will first try to reset nice value to 0 even if /etc/security/limits.conf file is empty or even if there are lower priority limits set in it. The pam_limits module does that since its developers decided that it should reset some limits to defaults and start from scratch when applying new restrictions. Unfortunately, already limited guest system won't be able to do it since resetting nice value to 0 means increasing the limit which is forbidden. See Debian Bug report logs - #311058 for more information about that Debian bug.

See also Cron is not working…
daniel_hozac & Beuc & Paweł Wilk



Cron is not working on my guest system (which is Debian). How can I fix it?

On a guest system the cron daemon may not work properly. When looking into the log file (e.g. /var/log/syslog) the following message may appear repeatedly:
CRON[xxxxx]: Permission denied

Similar thing may happen with the su when trying to execute a command as root.

It's not the problem in Cron but in the pam_limits module on a guest system (see FAQ:When using nice and su… for more information about the cause).

There are 4 ways to solve or work-around this problem:

1. Allowing guests to reset resource limits:

It's clean solution but you may expect some guest processes increasing their limits because not everything is controlled by PAM. It also breaks centralized resources limiting approach so a guest can do bad things that may cause other guests and host to be overloaded and unresponsive.

To apply it you have to add CAP_SYS_RESOURCE flag to /etc/vservers/<server name>/bcapabilities (2.6 kernels).

See Capabilities and Flags for more information.

2. Disabling pam_limits on a guest systems:

This workaround is easy and works fine when your guest systems aren't really multiuser but rather service boxes. It disables setting of the resource limits by PAM so the limits can only be set globally for the whole guest (using rlimits or cgroups on a host) but never increased inside of the guest system.

To apply it just enter the guest and edit the files listed below, commenting out any line containing pam_limits:

/etc/pam.d/su
/etc/pam.d/sudo
/etc/pam.d/cron

You can also use this one-liner on a guest:

/bin/sed --in-place -e "s/^\s\?session.*pam_limits.so.*/\#\0/g" /etc/pam.d/{su,sudo,cron}

3. Allowing guest's pam_limits to set limits when possible:

This workaround allows you to have working pam_limits inside a guest system and global limits set by a host system. What's the catch? The problematic PAM module won't fully work for the root user on a guest system as expected and there might appear some PAM's warnings in guest's auth.log. Since using pam_limits to limit regular user processes is far more frequent than using it to limit root processes, this solution may be a good compromise. It is about setting a proper limits in pam_limits configuration and about setting this PAM module in a way that its function is optional (instead of required). The last change makes PAM to continue with session even if pam_limits encounters some error during setting limits (it usually applies to superuser sessions).

The not so nice news is that there might be a need of keeping guest's limits configuration up to date according to limits globally set for a guest. The limits set in pam_limits configuration file(s) shouldn't be higher (lower in case of nice value) than global guest's limits.

To apply it enter the guest and edit the files listed below, replacing occurences of required by optional in the lines containing pam_limits:

/etc/pam.d/su
/etc/pam.d/sudo
/etc/pam.d/cron

For example:

# Sets up user limits, please define limits for cron tasks
# through /etc/security/limits.conf
session       optional        pam_limits.so

Then on a guest system create the file /etc/security/limits.d/01-fixpam.conf containing:

*         -        priority        X   # replace X with your guest's nice value 

You can automate this process to happen automagically for any guest by creating the startup script named /etc/vservers/.defaults/scripts/post-start.d/01-pamfix:

#!/bin/sh

# This script tries to fix pam_limits entries
# to make it possible for PAM in a guest system to
# set its own limits.

PAM_DIR="etc/pam.d"
PAM_SERVICES="su sudo cron"
LIMITS_FILE="etc/security/limits.d/01-pamfix.conf"

vname="$2"
[ -z "$vname" ] && exit 0

vcfg=$( /usr/sbin/vserver-info "$vname" CFGDIR )
[ ! -d "$vcfg" ] && exit 0

for s in $PAM_SERVICES
do
        pamfile="${PAM_DIR#\/}/$s"
        [ -f "$pamfile" ] && /bin/sed --in-place -e "s/\(^\s\?session.*\)required\(.*pam_limits.so.*\)/\1optional\2/g" "$pamfile"
done

[ ! -f "${vcfg}/nice" ] && exit 0
nval=$( /usr/bin/head -1 "${vcfg}/nice" )
[ -n "$nval" ] && echo "* - priority $nval # (added by vserver startup script)" > "${LIMITS_FILE#\/}"

exit 0

4. Disabling resource limits for a guest:

It easy, clean and… unsafe solution. You just have to not set resource limits (e.g. priority, nice value) for a guest or set the nice value limit to 0 on a host system. Resetting it later by guest's pam_limits will not generate an error.
Paweł Wilk



How do I handle NFS mounts within in a guest?

There are at least four ways.

In any case, you probably want to force the nfs version to 3 or lower to avoid id mapping issues (one symptom of having an id mapping issue is that no_root_squash appears to be ignored). You can check whether the mount uses nfsv4 by looking at /proc/mounts inside the guest. You can force the protocol version to 3 by passing the mount options nfsvers=3,mountvers=3.

1) Mount the NFS share from the host OS and let vserver guest access it as part of it's file system.

mount --bind may also be beneficial in this scenario.

2) Use util-vserver and create a fstab.remote file in the /etc/vserver/<vserver_name> directory. Populate this with the NFS shares and they will be mounted in the context of the vserver guest.

See http://www.nongnu.org/util-vserver/doc/conf/configuration.html

Note that as of 0.30.216-pre3000 and kernel 3.0.4-vs2.3.1-pre10.1, the mount request will appear to originate from the IP of the host, not the guest. It is unclear (to Guy-) whether this is a bug.

3) Add capabilities to the vserver guest instance to grant sufficient rights to allow NFS mounts.

Add the following to /etc/vserver/<vserver_name>/bcapabilities

SYS_ADMIN

Add the following to /etc/vserver/<vserver_name>/ccapabilities

SECURE_MOUNT
BINARY_MOUNT

See Capabilities_and_Flags for more information about vserver capabilities.

If you want the NFS shares to be mounted when the guest starts, add them to /etc/vserver/<vserver_name>/fstab.

4) Before starting the guest, make a directory of the host "shared" using mount --make-shared /path/to/dir, then set up autofs to mount nfs shares under /path/to/dir/sharename.

rbind mount subdirectories of /path/to/dir in the guest from its fstab.

This setup is good if the nfs shares are not often needed, and especially if they're occasionally needed by more than one guest. (As of September 2011, running autofs inside a vserver guest didn't work for me. --Guy- 01:05, 30 October 2011 (UTC))
martindk




vserver start/stop/enter fails with something like "vnamespace: execvp("/usr/sbin/vserver"): No such file or directory" ?

Check whether /usr is mounted in the namespace you are working with.
vnamespace -e <guest> cat /proc/mounts

If there is no /usr, you can fix your problem with simply mounting it using the following command:

vnamespace -e <guest> mount /dev/<device> /usr
sim0n



The command vserver <$server> start gives '/etc/init.d/rc: line 74: /etc/default/rcS: No such file or directory', what do I do?

The vserver has not been correctly installed, this has several reasons

check your install log and it should tell you something about that your server didn't get installed properly

  • use stable distribution of debian as server (debootstrap may be different over the versions)
  • deny_mount, deny_caps and deny_pivot should be off if your running grsec.
Dude




How could I rename a vserver directory?

Please note : this procedure renames the directory, not the hostname !
  1. Stop the vserver in question
  2. rename the /vservers/<server name> directory
  3. rename the /etc/vservers/<server name> directory
  4. update link: /etc/vservers/<server name>/run/var/run/vservers/<server name>
  5. update link: /etc/vservers/<server name>/vdir/etc/vservers/.defaults/vdirbase/<server name>
  6. update link: /etc/vservers/<server name>/cache/etc/vservers/.defaults/cachebase/<server name>
  7. update link: /var/run/vservers.rev/<server XID>/etc/vservers/<server name>
  8. Start the vserver in question. It should start properly.
FlorianD (from hillct page in old wiki)




what if i see my vserver in vserver-stat but with no name ?

the link in /var/run/vservers is missing

Just do a : cat /etc/vservers/<guest>/context > /var/run/vservers/<guest>

check that the <guest> is the good one by using vuname --get --xid <context> with the context you have in the vserver-stat listing.
IrcQuestions



Upgrade from 2.0 to 2.2

I now get errors like "ncontext: vc_net_create(): Invalid argument; dynamic contexts disabled." on startup. Vservers are not started

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
echo 101 > /etc/vservers/myvserv/context
ADDENDUM: please consider that valid static contexts are between 2 and 49151 ( daniel_hozac on IRC ) otherwise you will end up with unexplainable error "ncontext: vc_net_migrate(): No such process" when trying to start the vserver.
daniel_hozac&Beuc




How do I assign a static context to an existing vserver?

Simple ;) See the answer above.
gcc




Since upgrading to a newer VS version my guest complains about "vsched: non-numeric value specified for '--priority_bias" at start time. What's wrong?

The scheduler paramters changed.You can use this (ugly) script to convert them or do it by hand:
# cat /usr/local/sbin/vserver-convert-schedule-to-scheddir
#/bin/sh
mkdir /etc/vservers/$1/sched
sed -e 1p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/fill-rate
sed -e 2p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/interval
sed -e 3p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/tokens
sed -e 4p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/tokens-min
sed -e 5p -n /etc/vservers/$1/schedule > /etc/vservers/$1/sched/tokens-max

mv /etc/vservers/$1/schedule /etc/vservers/$1/schedule.converted.see.scheddir

# see: http://oldwiki.linux-vserver.org/Scheduler+Parameters
# see: http://www.nongnu.org/util-vserver/doc/conf/configuration.html#sched
derjohn




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?

Every VS version that runs on a kernel >= 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.

Here is an example how to do so:

# mkdir /etc/vservers/<vserver>/sysctl/0 -p
# echo kernel.shmall > /etc/vservers/<vserver>/sysctl/0/setting
# echo 134217728 > /etc/vservers/<vserver>/sysctl/0/value
# mkdir /etc/vservers/<vserver>/sysctl/1 -p
# echo kernel.shmmax > /etc/vservers/<vserver>/sysctl/1/setting
# echo 134217728 > /etc/vservers/<vserver>/sysctl/1/value

It's also explained on the geat flower page:

  1. see: http://www.nongnu.org/util-vserver/doc/conf/configuration.html -> Look for "sysctl".

After changing those values, restart your guest, enter it and check if the values are set:

# sysctl -a | grep shm
...
kernel.shmall = 134217728
kernel.shmmax = 134217728

To change a value for a running guest, on the host use:

 vspace -e CONTEXTID --ipc sysctl -w kernel.shmall=134217728
 vspace -e CONTEXTID --ipc sysctl -w kernel.shmmax=134217728
derjohn
Personal tools