There is a server with Debian Lenny installed. We need to configure several VPSs on the server. That’s how to install and run OpenVZ in Debian Lenny:
- Install a kernel with OpenVZ
aptitude install linux-image-openvz-amd64 - To make OpenVZ containers work correctly, a file /etc/sysctl.conf needs to feature these lines:
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
net.ipv4.conf.eth0.proxy_arp=1 - Reboot the server
- Check if the server was loaded with the new kernel – uname -r
Everything has been installed correctly if the system shows 2.6.26-2-openvz-amd64. - The kernel installed by default is not needed anymore, delete it with the command:
apt-get remove ––purge linux-image-2.6.26-2-amd64. If you want to leave the kernel, just omit this step.
- I have created a separate division at for OpenVZ containers. By default, OpenVZ in Debian locates everything at /var/lib/vz. Move all data from /var/lib/vz to /vz and create a symlink: /etc/init.d/vz stop ; mv /var/lib/vz/* /vz/ ; rmdir /var/lib/vz ; ln -s /vz /var/lib/vz ; /etc/init.d/vz start
- I will have Debian Lenny х86 working at my container. Download a container template from OpenVZ website.
cd /var/lib/vz/template/cache
wget -c http://download.openvz.org/template/precreated/debian-5.0-x86.tar.gz - Create a container
vzctl create 101 ––ostemplate debian-5.0-x86 ––config vps.basic
(101 – is a unique container identifier) - Specify that the container was launched along with OpenVZ
vzctl set 101 ––onboot yes ––save - Configure host name, IP and dns-server for container
vzctl set 101 ––hostname vps1.local ––save
vzctl set 101 ––ipadd 10.1.1.101 ––save
vzctl set 101 ––nameserver 10.1.1.2 ––save - Launch the container and state a password for root
vzctl start 101
vzctl exec 101 passwd - Enter the container
vzctl enter 101
To exit container, use a command exit. You can enter it via ssh.
- Install the necessary software in the container.
- Just use it.
P.S. Some useful commands to work with containers:
vzlist -a – a list of running containers
vzctl stop <UID> – stop container
vzctl restart <UID> – restart container
vzctl destroy <UID> – delete container
where <UID> – is a unique identifier of OpenVZ-container.



Recent Comments