The basic concept of the Linux-VServer solution is to separate the user-space environment into distinct units (sometimes called Virtual Private Servers) in such a way that each VPS looks and feels like a real server to the processes contained within.
| Term | Description |
|---|---|
| Linux-VServer, VServer | |
| virtual server, vserver, guest system | |
| host system, host | |
| util-vserver |
# emerge vserver-sources
After the vserver-sources are installed it's time to configure them using
# cd /usr/src/linux-<KERNELVERSION>-vserver-<VSERVERVERSION> # make menuconfig Linux VServer ---> [ ] Enable Legacy Kernel API [*] Disable Legacy Networking Kernel API(Highly recommended) [*] Enable Proc Security [*] Enable Hard CPU Limits Persistent Inode Context Tagging (UID24/GID24) ---> [ ] Tag NFSD User Auth and Files [ ] Compile Debugging Code
File systems ---> <*> Reiserfs support [*] ReiserFS extended attributes
/dev/hdb1 /vservers reiserfs noatime,attrs 0 0
After you've built and installed the kernel, update your boot loader and finally reboot to see if the kernel boots correctly.
(Building the kernel) # make(Installing) # make modules_install # cp arch/<arch>/boot/bzImage /boot/kernel-<KERNELVERSION>-vserver-<VSERVERVERSION>(Edit bootloader config file as required and) # reboot
To maintain your virtual servers you need the util-vserver package which
contains all necessary programs and many useful features. Be aware that there
is also a package called
# emerge util-vserver
You have to run the
# rc-update add vservers default # /etc/init.d/vservers start
The vshelper script is used to restart virtual servers correctly. You have to tell the kernel where the vshelper script is located:
# echo 'kernel.vshelper = /usr/lib/util-vserver/vshelper' >> /etc/sysctl.conf # sysctl -p
You have to download a vserver prepared stage3 from one of
You have to choose a context ID for your vserver (dynamic context IDs are discouraged) as well as the necessary network device information (In this example eth0 is configured with 192.168.1.253/24 and the context ID is equivalent to the last two parts of the virtual servers IP).
# vserver-new gentoo-template \ --hostname gentoo \ --context 1253 \ --interface eth0:192.168.1.253/24 \ stage3 /path/to/stage3-<arch>-<date>.tar.bz2 <arch>
You don't have to build a stage3 tarball for every guest. The
# cd /vservers/gentoo-template # tar cjvpf ../gentoo-template-<arch>-<date>.tar.bz2 ./
To create a new guest using this tarball just use
# cd /vservers # vserver-new myguest \ --hostname myguest \ --context 1252 \ --interface eth0:192.168.1.252/24 \ template ./gentoo-template-<arch>-<date>.tar.bz2 <arch>
You should be able to start and enter the vserver by using the commands below.
If you miss commands like
# vserver myguest start
# vserver-stat
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 90 1.4G 153.4K 14m00s11 6m45s17 2h59m59 root server
1252 2 3M 286 0m00s45 0m00s42 0m02s91 myguest
# vserver myguest enter
# ps ax
PID TTY STAT TIME COMMAND
1 ? S 0:00 init [3]
22887 ? Ss 0:00 /usr/sbin/syslog-ng
20496 pts/0 S 0:00 /bin/bash -login
20508 pts/0 R+ 0:00 ps ax
# logout
You can start certain guests during boot. Each guest can be assigned a MARK. Now everything you have to do is configure these MARKs in the guests configuration and tell the init script to run all MARKed guests.
(Do this for every guest you want to start) # mkdir -p /etc/vservers/myguest/apps/init # echo "default" > /etc/vservers/myguest/apps/init/mark
The util-vserver ebuild has installed some goodies for Gentoo guests. You know
The script
(Sync metadata for 'myguest') # vesync myguest(Sync metadata for all guests) # vesync -a(Sync metadata for all guests except 'myguest') # vesync -a -e myguest(Sync 'myoverlay' for all guests) # vesync -a \ --overlay /usr/local/overlays/myoverlay \ --overlay-host rsync://rsync.myhost.com/myoverlay \ --overlay-only(emerge app-editors/vim in 'myguest') # vemerge myguest app-editors/vim -va
Gentoo guests can share packages to save compilation time. In order to use
shared packages, you have to create a central directory for packages on the
host. We will use
# mkdir -p /var/cache/vpackages # $EDITOR /etc/vservers/myguest/fstab(Add this line at the end) /var/cache/vpackages /usr/portage/packages none bind,rw 0 0
Now you can use
(Pretend update for 'myguest') # vupdateworld -p myguest(Update 'myguest' using binary packages) # vupdateworld -k myguest(Update all guests using binary packages) # vupdateworld -ka
After a successful update you can easily update all configuration files with
(Update configuration files for 'myguest') # vdispatch-conf myguest(Update configuration files for all guests) # vdispatch-conf -a
Please feel free to contact the