Linux: Install and run OpenVZ in Debian Lenny


Install OpenVZ in DebianThere 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:

  1. Install a kernel with OpenVZ
    aptitude install linux-image-openvz-amd64
  2. 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
  3. Reboot the server
  4. 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.
  5. 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.
  6. 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
  7. 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
  8. Create a container
    vzctl create 101 ostemplate debian-5.0-x86 config vps.basic
    (101 – is a unique container identifier)
  9. Specify that the container was launched along with OpenVZ
    vzctl set 101 onboot yes save
  10. 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
  11. Launch the container and state a password for root
    vzctl start 101
    vzctl exec 101 passwd
  12. Enter the container
    vzctl enter 101
    To exit container, use a command exit. You can enter it via ssh.
  13. Install the necessary software in the container.
  14. 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.

Bookmark and Share

Related Posts

, , , , , , ,

  1. No comments yet.
(will not be published)
  1. No trackbacks yet.