Comparing
version 2 and
version 1 backh2. VServer Tips and Tricks
h3. Bootstrap debian (sarge)
root% vserver sarge build -m debootstrap -- -d sarge -m http://ftp.jp.debian.org/debian/
Will create *{vservers}/sarge* and will bootstrap debian sarge there.
h3. Bind a service to given IP (interface)
# description: Wrapper to start httpd bound to a single IP
IP=eth0
exec /usr/sbin/chbind --ip $IP /etc/init.d/httpd $*
h3. Commands observing ALL vservers
root% vps -ax
root% vpstree -ap
root% vtop
root% vuname -g --xid tol
All of these commands are simply wrappers which are actually doing:
root% chcontext --ctx 1 pstree $*
eg. _chcontext --ctx ps auxw_
h3. Execution of commands with wild-cards
The trick is to use a shell on the other side (in the vserver). The command is simply rewritten like this:
root% /usr/sbin/vserver server exec /bin/sh -c "command *"
h3. Kill all processes in given context
Get the context CTX with _vserver-stat_:
root% vserver-stat
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 79 127.9M 10.5K 1h44m14 24m15s41 23h14m47 root server
1151 9 164.9M 6.5K 0m00s54 0m00s46 12m42s24 sarge
Then kill those processes:
# for example: vkill --xid 1151 -s TERM
root% vkill --xid -s TERM
root% vkill --xid -s KILL
h3. Update the ARP caches
When a virtual server is moved from one physical server to another, other network nodes will keep trying to contact the server on the old MAC address for the length of their arp-cache timeout.
To update the ARP caches of other network notes (and so make your new server reachable), send a gratuitous ARP request like this:
root% arping -c 10 -S virtual.server.IP -B
That command will broadcast your new MAC address 10 times to the local network. Hopefully they will get the idea and your vserver will be reachable.!!!
h3. Mount a dir from one vserver into another from the host
root% vnamespace -e mount --rbind /directory/to/mount/somewhere /where/to/mount/it
Also you can edit _/etc/vservers//fstab_ (gentoo-specific binding follows):
none /proc proc defaults 0 0
none /tmp tmpfs size=16m,mode=1777 0 0
none /dev/pts devpts gid=5,mode=620 0 0
# Portage related dirs
/usr/distfiles /usr/distfiles auto rbind 0 0
/usr/portage /usr/portage auto rbind 0 0
/usr/shadow /usr/shadow auto rbind 0 0
/usr/vpackages /usr/packages auto rbind 0 0
h2. See also
* "Linux-VServer Wiki":http://linux-vserver.org/
* "Gentoo Linux-VServer Howto":http://www.gentoo.org/doc/en/vserver-howto.xml
* "The content of the /etc/vservers directory":http://www.nongnu.org/util-vserver/doc/conf/configuration.html -- have some crazy page background (copy in locally and remove it)
* "The 'alpha branch' of util-vserver":http://linux-vserver.org/alpha+util-vserver -- have interesting hints about vunify, vshelper etc.