This article describes only using precreated templates and not creating it. If you want to run distro, which hasn't available template, you have to create it. This article applicable to Debian 6.
Terms: $CTID - id of your vps container, can be known while you enter to serial console (entered into CT 4711, here, for example, it is equal to 4711). $VPSIP - ip of vps, can be known from control panel. $HOSTNAME - hostname of vps, can be known for control panel.
0. Check if you have access to serial console (not ssh root@vpsip, but ssh firstname.lastname@example.org). If you have not, don't even start process of installing.
1. We need linux machine with openvz kernel and vzctl (utility to control openvz containers) I used debian 6 inside Virtualbox, where it can be installed with
# apt-get install linux-headers-2.6.32-5-openvz-686 linux-headers-2.6.32-5-common-openvz linux-image-2.6-openvz-686 vzctlIt suggests to install package grub(virtual package which allows migrate from grub-legacy to grub2), so let's do it.
# apt-get install grubWhen we got it installed, we have to go reboot with
# shutdown -r now.2. OK, we booted with openvz kernel and
# uname -rshows us
2.6.32-5-openvz-686. And we are ready to next step: choosing distro. So, we go to download.openvz.org/template/precreated/ to take a look on official templates, or go to download.openvz.org/template/precreated/contrib/ to take a look on contributed templates, or we google "%DISTRONAME% openvz template" if we haven't found neither official nor contributed template on download.openvz.org.
I choosed openSUSE-12.1-x86 template, and start download it with
wget download.openvz.org/template/precreated/suse-12.1-x86.tar.gz -O /var/lib/vz/template/cache/suse-12.1-x86.tar.gz.
But, download speed on download.openvz.org is pretty slow for me, so I taked look to mirror list on wiki.openvz.org/Download_mirrors and downloaded from mirror which is closer to me.
3. OK, we download template and it is time to create container with openSUSE. Do it with command
vzctl create $CTID --ostemplate suse-12.1-x86 --ipadd $VPSIP --hostname $HOSTNAME4. Now, you can change root password with
vzctl exec $CTID passwd. I don't noticed that option in man vzctl and changed it later.
5. We got working container and it is time to transfer it to vps.
First, stop container with
vzctl stop $CTID. Then, make a tar.gz archive with your container with
tar cfvz archive.tar.gz /var/lib/vz/private/$CTID/. Then, transfer archive to your machine with
scp archive.tar.gz root@vpsip:/.
6. OK, we got archive.tar.gz in /. Now, we should make symlinks in order to have files exctracted in right place. Let's do it with
cd /var/lib && mkdir vz && cd vz && mkdir private && cd private && ln -sf / /var/lib/vz/private/$CTID/Now, (I understand that it shouldn't be necessary, but i got errors while extracting without it) we go to directory /var/lib/vz/private/$CTID/ with
cd /var/lib/vz/private/$CTID/and start extract archive.tar.gz with
tar xfvz archive.tar.gz.
7. Now, it should make a final cleanup (not must), and remove files which wasn't accessed last 120 minutes (i.e. which wasn't extracted). I'd suggest you check what files will be deleted before deleting with
find -amin +120and delete them with
find -amin +120 -delete.
8. Reboot machine with
shutdown -r now.
9. If you did step 4, skip that step. If you didn't, install root password via serial console with
10. Finally, you got machine, which runs distro, which wasn't supposed to you by Haphost.
Licensed under CC-BY-NC-SA.