Building A Virtual Server (VPS) With Debian 3.1 (Sarge) And OpenVZ
Author: Till Brehm <t.brehm [at] howtoforge [dot] com >
In this HowTo I will describe the steps to be taken to prepare a server for OpenVZ virtual machines on Debian 3.1 (Sarge) 32Bit Linux. With OpenVZ you can create multiple Virtual Private Servers (VPS) on the same hardware, similar to Xen and the Linux Vserver project. OpenVZ is the open-source branch of Virtuozzo, a commercial virtualization solution used by many providers that offer virtual servers. The OpenVZ kernal patch is licensed under the GPL license, and the user-level tools are under the QPL license.
In the first chapter I will compile the linux kernel for Debian with the OpenVZ patches. This results in an easy-to-install .deb package. This is nescessary when you need drivers that are not compiled in the stock kernel that is avilable from systs.org. You can skip the first chapter if the precompiled kernel fulfills your needs and install the kernel as described in chapter 1.2.
I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!
Please note: if you want to use the precompiled OpenVZ kernel, you can skip the sections 1 and 1.1 and go directly to 1.2. If you want to compile your own kernel, please read the sections 1 and 1.1 before you proceed with 1.2.
First we install some prerequisites for the kernel compilation.
apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
Downloading The Kernel Sources
The OpenVZ patch is currently available for the kernel 2.6.8 only. We will use the vanilla kernel from kernel.org and patch and configure it for our needs. To download and unpack the sources, execute the following commads:
tar xjf linux-2.6.8.tar.bz2
Getting The OpenVZ Patch And Patch The Kernel
Now we download the OpenVZ kernel patch from OpenVZ.org and apply it to the kernel sources.
gzip -d patch-022stab078-combined.gz
patch -p1 < patch-022stab078-combined
Getting The Kernel Config For OpenVZ
OpenVZ.org offers several kernel configurations from generic i686 to enterprise configurations. I select the generic i686 configuration. You may select another config depending on your hardware and processor. The configs can be downloaded from here: http://openvz.org/download/kernel/
Now run "make menuconfig", select "Load an alternate configuration file" and select the file "/usr/src/linux-2.6.8/kernel-2.6.8-022stab078-i686.config.ovz".
If you have some special kernel config requirements, change them now. Then select Exit and then Save to save the kernel configuration.
Now we compile the kernel.
fakeroot make-kpkg --revision=OpenVZ.2.6.8 kernel_image
If the compilation stops with an error, run
and then re-run the previous commands starting with
If you have skipped the first chapter, you can install the precompiled Debian kernel now.
Add the repository for the OpenVZ Tools to /etc/apt/sources.list:
echo "deb http://debian.systs.org/ stable openvz" >> /etc/apt/sources.list
Install the packages:
apt-get install kernel-image-2.6.8-stable-ovz
Install the packages:
apt-get install vzctl vzquota vzctl-template
Now you should reboot your server:
shutdown -r now