The long term support edition 8.04 of Ubuntu Linux will provide security updates until 2013. Therefore it is an ideal distribution for building the base of a secure hosting solution. In this article I will describe how you can setup the virtualization software OpenVZ on Ubuntu 8.04. OpenVZ allows you to run multiple virtual Linux servers on top of your Ubuntu system. It is extremely performant and OpenVZ is also the base of the well known Virtuozzo solution which is widely used in the web hosting market. Compared to Xen, OpenVZ is more limited in regards to different operating system you can run, but on the other hand it has a lower overhead and is therefore more performant. It is also possible to run OpenVZ inside of VirtualBox which is not possible with Xen.
The first step in setting up an OpenVZ server is to install a minimal setup of Ubuntu server 8.04. When installing Ubuntu you should select LVM in the partitioning options as this will enable backups of your OpenVZ containers without downtime while they are running. The only service that we will install is OpenSSH to access the installation remotely.
Once the base system is setup and you can login remotely via SSH you could update the whole system to make sure you have the latest versions of all installed applications:
sudo apt-get update sudo apt-get dist-upgrade
The OpenVZ-Kernel does not work well with the AppArmor package, which is installed by default, so disable it:
sudo update-rc.d -f apparmor remove
Now it is time to install the OpenVZ-kernel:
sudo apt-get install linux-openvz
The above package is a meta package which will install the kernel, the kernel modules and any required header-files and libraries. Now take a look at the file
/boot/grub/menu.lst and make sure that the new OpenVZ kernel is the default kernel when booting. Now reboot and check that the correct kernel is loaded:
If you can see something like
2.6.24-18-openvz when running the above command, the correct kernel has been booted. If not, check your boot config.
The next step is to install the OpenVZ tools:
sudo apt-get install vzctl vzquota
Now you can run the OpenVZ daemon:
sudo /etc/init.d/vz start
Basically that’s it. OpenVZ is now running and you can setup your VZ containers. The OpenVZ project page has a lot of different container templates you can use as a starting point. Take a look at the list on http://wiki.openvz.org/Download/template/precreated and download all templates you want to use to
/var/lib/vz/template/cache. You can choose from a wide selection of Linux distributions.
You can now start creating your virtual machine containers and run them:
sudo vzctl create 101 --ostemplate ubuntu-8.04-i386-minimal sudo vzctl start 101
Of course you need to configure your containers, but this is a different topic which I will describe in a followup to this article.