= Installing OpenVZ on Ubuntu 10.04 = These instructions have been taken mostly from https://help.ubuntu.com/community/OpenVZ with some modifications. The instructions on that page are outdated or broken in some areas. The correct installation is below. The original instructions state OpenVZ can be installed from RPM files, but some of the dependencies are broken. The best way to install OpenVZ on Ubuntu 10.04 is to use the set of instructions below. These instructions only apply to the desktop version referred to in step 1. === Setting up OpenVZ === 1. Create a [https://www.virtualbox.org VirtualBox] container, and install Ubuntu 10.04 LTS from http://releases.ubuntu.com/lucid/ubuntu-10.04.4-desktop-i386.iso. For easy use you can optionally install Guest Additions on the Ubuntu VM to copy-paste commands in the terminal from your host machine. 2. Before getting started make sure the machine is up to date.[[br]] `sudo apt-get update`[[br]] `sudo apt-get upgrade` 3. Reconfigure dash. When the "Configuring dash" screen appears select NO.[[br]] `sudo dpkg-reconfigure dash` 4. Install required packages to compile the kernel. This will be needed when the OpenVZ kernel is compiled.[[br]] `sudo apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 module-assistant debhelper build-essential bridge-utils` 5. Set the following variables that will be used.[[br]] `Variant="linux-image-generic"`[[br]] `VersionAppendix="-openvz"`[[br]] `MyConfigFile="kernel-2.6.32-i686.config.ovz"`[[br]] 6. Set the build dependencies for OpenVZ[[br]] `Package="$(apt-cache showpkg $Variant | grep "^2\.6\.32" | grep "linux-image")"`[[br]] `Package=$(ReturnWord () { echo $3; }; ReturnWord $Package)`[[br]] `sudo apt-get build-dep --no-install-recommends $Package`[[br]] 7. Prepare the linux headers before compiling, and create the configuration for the kernel.[[br]] `sudo m-a prepare`[[br]] `sudo kernel-packageconfig` 9. Set up multi-core support. This step may not be necessary if your VM is only using one core, but it does not hurt to execute this line anyway.[[br]] `Cores=$(Nr () { echo $#; }; Nr $(grep "processor" /proc/cpuinfo | cut -f2 -d":"))`[[br]] `echo "CONCURRENCY_LEVEL := $(($Cores + 1))" | sudo tee -a /etc/kernel-pkg.conf`[[br]] 10. Download the linux kernel source code.[[br]] `cd /usr/src`[[br]] `sudo wget http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux_2.6.32.orig.tar.gz` 11. Get the OpenVZ patch for the linux kernel, and the OpenVZ kernel itself.[[br]] `sudo wget http://download.openvz.org/kernel/branches/2.6.32/current/patches/patch-feoktistov.1-combined.gz`[[br]] `sudo wget http://download.openvz.org/kernel/branches/2.6.32/current/configs/$MyConfigFile` 12. Unpack the source code.[[br]] `sudo rm -fR linux-2.6.32`[[br]] `sudo tar -xpf linux_2.6.32.orig.tar.gz`[[br]] `sudo rm -fR "linux-2.6.32$VersionAppendix"`[[br]] `sudo mv linux-2.6.32 "linux-2.6.32$VersionAppendix"`[[br]] `sudo rm linux`[[br]] `sudo ln -s "linux-2.6.32$VersionAppendix" linux` 13. Apply the OpenVZ patch to the kernel.[[br]] `cd /usr/src/linux`[[br]] `sudo gunzip -dc /usr/src/patch-feoktistov.1-combined.gz | sudo patch -p1 --batch`[[br]] `sudo cp -f "/usr/src/$MyConfigFile" .config`[[br]] `sudo make oldconfig` 14. One of the make files has a bug in it that needs to be fixed.[[br]] `sudo gedit Documentation/lguest/Makefile` Change the following lines; `all: lguest`[[br]] `clean:`[[br]] `rm -f lguest` To be the following; `all:`[[br]] `clean:`[[br]] `rm -f lguest` 15. Now build the OpenVZ kernel. '''WARNING''': This may take some time, upwards of 1 or 2 hours.[[br]] `cd /usr/src/linux`[[br]] `sudo make-kpkg --initrd --append-to-version=$VersionAppendix --revision=1 kernel_image kernel_headers`[[br]] 16. Install the OpenVZ kernels that were just built.[[br]] `cd /usr/src`[[br]] `sudo dpkg -i linux-image-2.6.32.28-openvz_1_i386.deb`[[br]] `sudo dpkg -i linux-headers-2.6.32.28-openvz_1_i386.deb`[[br]] 17. Setup the grub menu to load the OpenVZ kernel at boot.[[br]] `sudo mkinitramfs -k 2.6.32.28-openvz -o /boot/initrd.img-2.6.32.28-openvz`[[br]] `sudo update-grub`[[br]] 18. Create a new internet configuration.[[br]] `sudo gedit /etc/sysctl.d/10-openvz.conf`[[br]] Place the following text in the file. `### Optimized for Ubuntu 10.04`[[br]] `# vim:ft=sysctl`[[br]] `# sysctl config for OpenVZ`[[br]] `#net.ipv4.ip_forward=1`[[br]] `net.ipv4.conf.default.forwarding = 1`[[br]] `net.ipv4.conf.default.proxy_arp = 1`[[br]] `net.ipv4.ip_forward = 1`[[br]] `# Enables source route verification`[[br]] `net.ipv4.conf.all.rp_filter = 1`[[br]] `# Enables the magic-sysrq key`[[br]] `kernel.sysrq = 1`[[br]] `# TCP Explict Congestion Notification`[[br]] `#net.ipv4.tcp_ecn = 0`[[br]] `# we do not want all our interfaces to send redirects`[[br]] `net.ipv4.conf.default.send_redirects = 0`[[br]] 19. Apply the changes to the network configuration.[[br]] `sudo sysctl -p /etc/sysctl.d/10-openvz.conf`[[br]] 20. Install the tools used by OpenVZ for managing containers.[[br]] `sudo apt-get install --no-install-recommends vzctl vzquota vzdump` 21. Create a symlink to be FHS-compliant and then reboot.[[br]] `sudo ln -s /var/lib/vz /vz`[[br]] `sudo reboot` 22. Once rebooted, check to make sure the correct kernel was started. `uname -r` The result of that command should be something similar to "2.6.32.28-openvz". 23. Open a web browser and navigate to a website to make sure the internet configurations were set properly. If there is no internet connection check step 18 and that the text in the file 10-openvz.conf is correct. 24. Finally, download the Ubuntu 10.04 OpenVZ container template.[[br]] `cd /vz/template/cache/`[[br]] `sudo wget http://download.openvz.org/template/precreated/ubuntu-10.04-x86.tar.gz` === Testing OpenVZ in Ubuntu 10.04 === 1. From a terminal try to create an OpenVZ container.[[br]] `sudo vzctl create 101 --ostemplate=ubuntu-10.04-x86` There should be no errors seen from this command. It will take about a minute to create the container. 2. Start the container to make sure it was created properly.[[br]] `sudo vzctl start 101` 3. Stop and destroy the test container.[[br]] `sudo vzctl stop 101`[[br]] `sudo vzctl destroy 101` If these commands failed refer to the OpenVZ documentation on vzctl create/start/stop/destroy. If any of the commands cannot be found refer back to step 20 and make sure the packages were installed. If no errors were encountered you have successfully installed OpenVZ on Ubuntu 10.04.