Gentoo Linux-VServer Howto
Gentoo Linux-VServer Howto
Introduction
The Linux-VServer Concept
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.
Terms used in this Howto
Term Description
Linux-VServer is the official name of the project and used in this
Linux-VServer, VServer
Howto the same way
virtual server, vserver, guest All these are interchangable and refer to one instance of a server
system (i.e. one virtual server)
The physical machine running your Gentoo Linux will host all
host system, host
virtual servers
The util-vserver package contains all programs necessary for
util-vserver
maintaining your virtual servers
2. Host configuration
Install a VServer kernel
# emerge vserver-sources
After the vserver-sources are installed it's time to configure them using make menuconfig.. Below is
a common configuration for 2.1.1 and above. If you are using 2.0.x some configuration options may
not be present.
# cd /usr/src/linux-<KERNELVERSION>-vserver-<VSERVERVERSION>
# make menuconfig
Note: If you are using reiserfs as filesystem on the partition where guest images are stored, you will
need to enable extended attributes for reiserfs in your kernel config and additionally add the attrs
option in /etc/fstab.
After you've built and installed the kernel, update your boot loader and finally reboot to see if the
kernel boots correctly.
# emerge >=sys-cluster/util-vserver-0.30.212
You have to run the vprocunhide command after every reboot in order to setup /proc permissions
correctly for vserver guests. Two init scripts have been installed by util-vserver which run the
vprocunhide command for you and take care of virtual servers during shutdown of the host.
3. Guest creation
Download a precompiled stage3
Since many hardware related commands are not available inside a virtual server, there has been a
patched version of baselayout known as baselayout-vserver. However, since baselayout-2/openrc,
all required changes have been integrated, eliminating the need for seperate vserver stages, profiles
and baselayout. Stage tarballs can be downloaded from our mirrors.
Since a stage3 contains a complete root filesystem you can use the template build method of util-
vserver. However, this method only works reliable since util-vserver-0.30.213_rc5, so make sure
you have the right version installed.
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).
Note: The context ID should be 1 < ID < 49152.
You should now be able to start and enter the vserver by using the commands below.
Update guests
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 /var/cache/vpackages on the
host and mount it to /usr/portage/packages in every guest.
# 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 vupdateworld to update every guest. The command is equivalent to something
like emerge --deep --update --newuse world depending on command line options.
Note: In order to get binary packages you can either use PORTAGE_BINHOST (see man
make.conf) or set FEATURES="buildpkg" in one or more guests.
After a successful update you can easily update all configuration files with vdispatch-conf. It is a
simple wrapper for dispatch-conf and behaves exactly the same.