Installing And Using OpenVZ On Debian Squeeze

Valic —  March 31, 2011 — Leave a comment

OpenVZ is container-based virtualization for Linux. OpenVZ creates multiple secure, isolated containers (otherwise known as VE or VPS) on a single physical server enabling better server utilization and ensuring that applications do not conflict. Each container performs and executes exactly like a stand-alone server; a container can be rebooted independently and have root access, users, IP addresses, memory, processes, files, applications, system libraries and configuration files.

Step 1. Installation:
An OpenVZ kernel and the vzctl and vzquota packages are available in the Debian Squeeze repositories, so we can install them as follows:

apt-get install linux-image-openvz-686  vzctl  vzquota

Step 2. Create a symlink from /var/lib/vz to /vz to provide backward compatibility:

ln -s /var/lib/vz /vz

Step 3. Open with your favorite editor (eg: nano, vim) /etc/sysctl.conf and edit as following :

net.ipv4.conf.default.proxy_arp = 0
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

After you’ve edited /etc/sysctl.conf file run:

sysctl -p

Step 4. Open /etc/vz/vz.conf and set as following:

NOTE: This is important! If you don’t do this, networking will not work in the virtual machines!


Step 5. Reboot the system using:

reboot or shutdown -r now

Step 6. After reboot run:

uname -r

Your output should be like this:


Step 6. Using OpenVZ

Before we can create virtual machines we need to have a template for the distribution that we want to use  in the /var/lib/vz/template/cache directory.

You can find a list of precreated templates on For example, we can download a minimal Debian Squeeze template.

Step 7. Basic commands for using OpenVZ:

a) To set up a VPS from the debian-6.0-i386-minimal template run:

vzctl create 101 –ostemplate debian-6.0-1386-minimal –config basic

NOTE: 101 is the ID of your virtual machine. Each virtual machine must have  unique ID

b) Set the virtual machine to be started at boot:

vzctl set 101 –onboot yes –save

c) Set a hostname and IP address for the virtual machine:

vzctl set 101 –hostname –save
vzctl set 101 –ipadd –save

d) Start the virtual machine:

vzctl start 101

e) Set a root password for the virtual machine:

vzctl exec 101 passwd.

For more commands you can use the man vzctl command.

This tutorial is adapted for debian squeeze from


Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

No Comments

Be the first to start the conversation.

Leave a Reply