Last updated: May 15, 2007
I have recently begun playing with Linux-Vserver, which is yet another virtualization method, which can be compared to UML, Xen, and OpenVZ (this list isn’t meant to be exhaustive). All these methods obviously differ much in their approach to virtualization, and have different levels of performance and security, but all might be worth giving a try to.
I have already covered UML in a previous article.
In this article, I will explain how to perform a basic set up of a Vserver on an up-to-date Etch system using the Debian specific method. Guests will also run Etch.
Linux-Vserver requires the kernel to be patched. Pre-build kernel images are available in the official Debian repositories, which avoids manual configuration and compilation:
host:~# aptitude install linux-image-vserver-686You will surely want to chose whatever image suits to your architecture.
To install the verser utilities and the tools needed to set up and run vservers, you just need to install the following packages:
host:~# aptitude install util-vserver vserver-debiantoolsReboot on the newly installed kernel.
Using the Debian specific tools to create a vserver allows you to install/remove packages on install (or just after), and remove the links to unneeded RC scripts automatically. It will also run basic configuration after set up (root password, time zone, creation of a standard user etc.) - all these steps have to be done manually with the standard method.
First, we need to configure the default options for all newly created vservers:
# cat /etc/vservers/newvserver-vars | grep -e '^$' -e '^#' -v EXTRA_PACKAGES="locales,openssh-server,openssh-client,nullmailer" REMOVE_LINKS="klogd hwclock.sh setserial urandom networking umountfs halt reboot" DIST="etch" MIRROR="http://ftp.fr.debian.org/debian" INTERFACE="eth0" PKGCACHE=0
You surely want to adapt these options to suit your needs (see newvserver(1) for complete list of options).
host:~# newvserver --hostname vps1 --domain domain.com \ --fakeinit --ip 192.168.1.95/24 --context 10
Again, the options should be changed.
Once the basic tools are installed on the guest, you can start the vserver:
host:~# vserver vps1 startand immediately use it:
host:~# vserver vps1 enterSave the following script as /etc/vservers/vps1/scripts/post-start (you will have to create the scripts/directory):
/usr/sbin/vdlimit --xid 10 \ --set space_total=2000000 \ --set space_used=`du -s /var/lib/vservers/vps1/ | awk '{print $1}'` \ --set inodes_total=2000000 \ --set inodes_used=`ls -1aRi /var/lib/vservers/vps1/ | awk '/^[0-9]+ / { print $1 }' | sort -u | wc -l` \ --set reserved=5 /var/lib/vservers/vps1/
vreboot used to be necessary to reboot/halt your vserver (from within the guest). the reboot now works with a kernel helper, so it is sufficient to change nothing at all, just call into the kernel (from the
guest) and request a reboot (with reboot -f) or a halt (with halt -f.
You can set aliases n your ~/.bashrc:
alias reboot='reboot -f'
alias halt='halt -f'
Note that the default runlevel for vserver guests is 3.
host:~ # echo "default" > /etc/vservers/vps1/apps/init/markCheck in /etc/default/util-vserver that the $MARK variable is set to default for this to work.
Networking in a Vserver environment is not virtualized, this can pose a problem when default configurations specify to listen on all interfaces. Each service should be configured to listen to the specified IP address, both on the host and on the guests.
Here are some examples for some current services:
ListenAddress 192.168.1.95
SLAPD_SERVICES="ldap://192.168.1.95:389/
You will find here some information about me and my different projects. I am involved in several open source projects, and try to promote Free software. This site is thus mainly dedicated to Free Software use on GNU/Linux systems. Please do not hesitate to contact me for any comments on this site.