Building A Virtual Server (VPS) With Debian 3.1 (Sarge) And OpenVZ

Want to support HowtoForge? Become a subscriber!
 
Submitted by till (Contact Author) (Forums) on Thu, 2006-09-07 21:47. :: Debian | OpenVZ | Virtualization

This is a "copy & paste" HowTo! The easiest way to follow this tutorial is to use a command line client/SSH client (like PuTTY for Windows) and simply copy and paste the commands (except where you have to provide own information like IP addresses, hostnames, passwords,...). This helps to avoid typos.

Building A Virtual Server (VPS) With Debian 3.1 (Sarge) And OpenVZ

Version 1.2
Author: Till Brehm <t.brehm [at] howtoforge [dot] com >
Last edited 09/07/2006

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.

1 Prepare Your Server To Host Virtual Private Servers

First we install some prerequisites for the kernel compilation.

apt-get install kernel-package libncurses5-dev fakeroot wget bzip2

1.1 Compiling The OpenVZ linux kernel

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:

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.8.tar.bz2
tar xjf linux-2.6.8.tar.bz2
cd linux-2.6.8/

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.

wget http://download.openvz.org/kernel/stable/022stab078.14/patches/patch-022stab078-combined.gz
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/

wget http://download.openvz.org/kernel/stable/022stab078.14/configs/kernel-2.6.8-022stab078-i686.config.ovz

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

make menuconfig

If you have some special kernel config requirements, change them now. Then select Exit and then Save to save the kernel configuration.

make-kpkg clean

Now we compile the kernel.

fakeroot make-kpkg --revision=OpenVZ.2.6.8 kernel_image

If the compilation stops with an error, run

make clean

and then re-run the previous commands starting with

make menuconfig

1.2 Installing The OpenVZ Kernel

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
apt-get update

Install the packages:

apt-get install kernel-image-2.6.8-stable-ovz

1.3 Installing OpenVZ Tools

Install the packages:

apt-get install vzctl vzquota vzctl-template

Now you should reboot your server:

shutdown -r now


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Fri, 2006-06-23 09:26.

Hi, 

with the packages from debian.systs.org I also hat the

arpsend: can't get iface 'eth0:' address : Cannot assign requested address

problem. The real problem is the ':'... Change /usr/share/vz/vps-functions with 

100c97
<       awk "/^[0-9].*:/&&/UP/ {print substr(\\$2, 0, length(\\$2))}"`
---
>       awk "/^[0-9].*:/&&/UP/ {print substr(\\$2, 0, length(\\$2)-1)}"`

and networking works as expected...

 

Submitted by Anonymous (not registered) on Mon, 2006-07-03 22:24.

please be carefully:

from now the vzctl depends on gawk, so there is no need to modify the "vps-functions".

I've someone hit a bug in the debian packages ... please let me know :-)

Thorsten Schifferdecker

--

tsd [at] debian.systs.org

or look at http://debian.systs.org/ 

 

Submitted by Anonymous (not registered) on Mon, 2006-07-03 22:18.

please be careful:

from now the vzctl (>= 3.0.10-1dso1) depends on "gawk" not on the plain awk!

so there 's no need to change the source in "vps-functions" 

And if someone detected a "bug" please let me know :-)

Thorsten Schifferdecker

--

tsd [at] debian.systs.org

see more at http://debian.systs.org/

Submitted by Anonymous (not registered) on Thu, 2006-06-22 14:54.

http://download.openvz.org/kernel/022stab064.1/configs/kernel-2.6.8-022stab064-i686.config.ovz

should be

http://download.openvz.org/kernel/stable/022stab064.1/configs/kernel-2.6.8-022stab064-i686.config.ovz

Submitted by Anonymous (not registered) on Thu, 2006-06-22 14:48.

wget http://download.openvz.org/kernel/022stab064.1/patches/patch-022stab064-combined.gz

should be :

wget http://download.openvz.org/kernel/stable/022stab064.1/patches/patch-022stab064-combined.gz

stable is missing...

Submitted by Anonymous (not registered) on Fri, 2006-03-17 11:17.

it should be

echo "deb http://debian.systs.org/ stable openvz" >> /etc/apt/sources.list

Submitted by Anonymous (not registered) on Fri, 2006-03-10 18:54.

I tried befor the Xen tutorial from Falko but had some problems with compiling ACPI options in the Xen kernel.
This OpenVZ howto works right from the first time i set it up like you explained with the ACPI options compiled in the VZ kernel and everything. So i can shut off and WOL start the host system now too.
Installing the virtual systems is easy and fast. I'm a happy man hehe
Very cool Howto! Thanks!