Host configuration

Install a Linux-VServer kernel

Installing a prepatched kernel is as easy as:

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

Note: If you are using reiserfs as file system on the partition where guest images are stored, you will need to enable extended attributes for reiserfs in your kernel configuration and additionally add the attrs option in /etc/fstab.

Setup host environment

To maintain your virtual servers you need the util-vserver package which contains all necessary programs and many useful features.

# 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 use. An init script has been installed by util-vserver. To use it you should add it to a runlevel:

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 separate vserver stages, profiles and baselayout. The
only (temporary) drawback is that baselayout-2/openrc is still in testing
(~arch) and there are no stages with baselayout-2/openrc available on the
mirrors yet.

As soon as baselayout-2/openrc is stable you can use a precompiled stage3 from
one of the Gentoo mirrors. In the meantime
please download a stage3 or gentoo-vserver stage from
here. Since a
stage3 contains a complete root file system 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).

Using the template build method

For a long time now, plain init style was the only init style available for
gentoo, i.e. a normal init process will be started inside the guest, just like
on any common Unix system. However this approach has some drawbacks:

No possibility to see output of init/rc scripts

Wasted resources for idle init processes in each guest

Annoying conflicts for /etc/inittab

Therefore, many users have requested the gentoo init style to be reimplemented,
which has been abandoned since it was a very hacky implementation and more
or less worked by accident due to other modifications done to baselayout back
then. However, as of util-vserver-0.30.212 the gentoo init style has been
reimplemented in a concise manner and will become the default in the future.

Maintenance made easy

Start guests on boot

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.

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.