What are VServers
The Linux VServer Project provides multiple Linux environments running inside a single Linux kernel.
You can think of it as a bit like running a new system inside a chroot, but with a different host name and IP address, a de-fanged root user, and configurable resource management. This is a similar feature to jails on FreeBSD and containers on Solaris 10+.
VServers are a different approach to the popular XEN Hypervisor; with XEN you end up with a kernel for each virtual server; VServers do not. So, with VServer you have less (virtually no) overhead, on the other hand you also have fewer features - it is currently impossible to have a VServer with a different time set to the host system, for instance. However it is possible to run a different time zone, as that is a purely user-space feature. The design of UNIX in general mean that for the vast majority of applications, this virtualisation technique is perfectly adequate.
Note that Xen and VServer are orthogonal approaches - that is, it is perfectly possible and sometimes even sensible to run Xen virtual machines on a Linux system, then Linux VServers within those Xen machines.
Karmic, Jaunty, Intrepid and Hardy
This describes how to install the VServer-enabled kernel packages built on top of Edgy's stock kernel (source is in http://git.u32.net/). If you want to verify the packages, you can add the package key to apt's keyring (this is optional). As of now packages are only available for x86 and amd64, hopefully more architectures will be supported soon.
No kernel pre-built for feisty currently exists for Ubuntu. You'll have to use the Edgy 2.6.17 for now. Also, be careful to install the VServer tools using the Edgy repository, or versions won't match and you'll get segmentation faults.
$ wget -O - http://bronson.rinspin.com/u32-package-key.gpg | sudo apt-key add -
Now add the following repositories to your /etc/apt/sources.list. Read this page for instructions on how to add repositories.
deb http://dpkg.u32.net/ubuntu edgy vserver deb-src http://dpkg.u32.net/ubuntu edgy vserver
Now, install the software packages and the kernel. Instead of vserver-generic, you can also supply any Ubuntu-supported flavor (vserver-i386, vserver-server, etc). Run 'cat /proc/version' to see what flavor kernel you're running now.
$ sudo apt-get install util-vserver vserver-debiantools $ sudo apt-get install linux-vserver-image-2.6.17-11-vserver-generic
And reboot into your new, VServer-enabled kernel.
This 2.6.17 Edgy kernel runs just fine on Dapper as well. Occasionally dpkg may stop claiming "error in postinst." This is just a bad interaction between older and newer kernel tools and, other than preventing the install from completing, it's harmless. Just purge and reinstall and it should work.
You may want to run run ln -sf /vservers /etc/vservers/.defaults/vdirbase to specify where your vservers should reside (this puts them in /vservers). By default they are stored in /var/lib/vservers.
The git tree for the patched kernel can be downloaded from http://git.u32.net.
Create a new guest
/etc/vservers/newvserver-vars (man newvserver(1) for options):
This command creates a new Ubuntu Dapper image. You can change "dapper" to "edgy" or whatever you want above. You can run virtually any Linux distribution as a guest (for instance, Gentoo).
- newvserver -v --hostname NAME --domain EXAMPLE.COM --interface ETHX --ip IPADDRESS
See this page for some tweaks to make your Dapper guest a little more vserver-friendly. Run 'vserver NAME start' to start your new guest image, then 'vserver NAME enter' to use it.
Installation is quite simple - you need:
- Kernel with VServer patch
You can install these packages if you add the following lines to your sources.list:
deb http://ubuntu.uni-klu.ac.at/ubuntu.uniklu/ dapper uniklu-vserver #deb-src http://ubuntu.uni-klu.ac.at/ubuntu.uniklu/ dapper uniklu-vserver
- edgy (not needed, already in universe)
The uniklu archives are signed - if you want get rid of apt-get warnings:
$ wget -nv http://ubuntu.uni-klu.ac.at/uniklu-debuild.pub -O - | sudo apt-key add -
To install the VServer Kernel and utils enter:
# apt-get install linux-image-2.6.15-(dapper_abi+1)-686 # apt-get install util-vserver vserver-debiantools
# apt-get install kernel-patch-vserver # apt-get install util-vserver
You should get the following revisions
At the moment the kernel is one revision behind the offical Ubuntu Kernel - will be fixed soon !
Make sure you install the kernel from the uniklu-vserver archive. You may want to remove linux-image-<arch>-<kernel_type> and linux-<arch>-<kernel_type>. Also, you may create /etc/apt/preferences file with content:
Package: * Pin: release v=6.04*,a=dapper,c=uniklu-vserver,o=UniversityKlagenfurt,l=uniklu Pin-Priority: 1001
The vserver-debiantools do not work 100% but should help you setting your first vserver quickly - see Uniklu VServer Info
The Kernel is the standard Ubuntu Kernel with the Vserver patch applied.
dapper: Vserver patch >= 2.0.2-rc13 for kernel-2.6.15
- edgy: patch from universe should be up2date
The Kernel and binaries are available for i386 and amd64
It is possible and supported to run 32bit i386 VServers on an amd64 VServer Kernel.
Distributed Remote Block Device (DRBD)
DRBD can be used with VServer to build simple, robust and cheap High Availability (HA) solutions with disaster failover capabilty to a remote location.
Simply put your VServers on a DRBD and let a heartbeat in another building take over the DRBD and start your VServers.
DRBD utilities and kernel modules for the VServer enabled kernels are available in the above archive:
apt-get install drbd0.7-module-2.6.15-(dapper_abi+1)-arch drbd0.7-utils
I've created a tgz of the diffs and build script I'm using for building the kernel debs.
$ wget http://ubuntu.uni-klu.ac.at/ubuntu.uniklu/dists/dapper/uniklu-vserver/vserver-image-build.tgz $ tar -xzf vserver-image-build.tgz $ cd linux-vserver-2.6.15 $ ./kbuild.sh