Creating OpenVZ Containers on Debian Etch

By lalapet • October 17th, 2008

1. Add the OpenVZ repository to the /etc/apt/sources.list. To do this, add the line
deb http://download.openvz.org/debian-systs etch openvz in the sources.list file.

2. Run wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add - && apt-get update. The repository contains six OpenVZ kernels. Choose one and install.

+ ovzkernel-2.6.18: uniprocessor | up to 4GB of RAM | i386 and amd64
+ ovzkernel-2.6.18-smp: symmetric multiprocessor | up to 4 GB of RAM | i386 and amd64
+ ovzkernel-2.6.18-enterprise: SMP + PAE support + 4/4GB split | up to 64 GB of RAM | i386 only
+ fzakernel-2.6.18-686: uni- and multiprocessor | up to 4GB of RAM | i386
+ fzakernel-2.6.18-686-bigmem: symmetric multiprocessor | up to 64 GB of RAM | i386
+ fzakernel-2.6.18-amd64: uni- and multiprocessor | amd64

In this example, the fzakernel-2.6.18-686 kernel was selected and installed using the following command
apt-get install fzakernel-2.6.18-686

3. If the GRUB boot loader is not updated, then update it using the command
update-grub

4. Install OpenVZ tools and a minimal Debian Etch template. This minimum OS template will be used to create virtual machines.
apt-get install vzctl vzquota vzctl-ostmpl-debian vzprocps vzdump

5. Create a symbolic link
ln -s /var/lib/vz /vz

6. Open the /etc/sysctl.conf file and make sure the following lines are present
net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.ip_forward=1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

If you modified the file, run sysctl -p

Edit /etc/vz/vz.conf and set
NEIGHBOUR_DEVS=all

7. Reboot using the new kernel.
uname -r should return 2.6.18-12-fza-686

8. Create a minimal VM form the minimal Debian Etch template (/var/lib/vz/template/cache) by using the command
vzctl create 62 –ostemplate debian-4.0-i386-minimal –config vps.basic

Note: Make sure OpenVZ is running
/etc/init.d/vz status
Start it using
/etc/init.d/vz start

The 62 is a unique ID. Each VM has a unique ID. In our example we used 192.168.1.62 for the IP address and the hostname was open62

Set the hostname, ip address, number of sockets, and nameservers

vzctl set 62 –hostname open62 –save
vzctl set 62 –ipadd 192.168.1.62 –save
vzctl set 62 –numothersock 62 –save
vzctl set 62 –nameserver 68.238.96.12 –nameserver 68.238.112.12 –save

To start on boot
vzctl set 62 –onboot yes –save

9. To start the vm
vzctl start 62
To set a root password
vzctl exec 62 passwd
Login from console using
vzctl enter 62
(or use putty)
To exit console, type exit
To stop the vm
vzctl stop 62
To restart
vzctl restart 62
To delete
vzctl destroy 62
To list vm’s
vzlist -a
To get info about allocated resources
vzctl exec 62 cat /proc/user_beancounters.
The failcnt column should have all zeros. If not, make changes to the vm’s config file.

 

Leave a Comment

You must be logged in to post a comment.

« Using Openfiler Storage Appliance with VMware Workstation 6 | Home | Online Backup vs. Tape Backup »

Solaris 10 - Useful Links

January 24, 2010
by: lalapet • Solaris 10

All Things Virtual

December 24, 2008
by: lalapet • Popular, Virtualization

Online Backup vs. Tape Backup

November 6, 2008
by: lalapet • Offsite Data Backup, Popular

Creating OpenVZ Containers on Debian Etch

October 17, 2008
by: lalapet • Popular, Virtualization