Sunday, August 28, 2011

OpenVZ on Ubuntu 8.10


ther OpenVZ Ubuntu 8.10 guides that I’ve seen have you use the old lenny repository; since this no longer exists let’s try another way!
I used a 64-bit machine; steps will be the same for 32-bit. If you have 64-bit and just want to download the kernel I used: http://bbis.us/~will/openvz-ubuntu810.tar.gz
Now let’s build the kernel.
cd /usr/src
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.tar.bz2
tar xjf linux-2.6.27.tar.bz2
cd linux-2.6.27
wget http://download.openvz.org/kernel/branches/2.6.27/2.6.27-briullov.1/patches/patch-briullov.1-combined.gz
gunzip patch-briullov.1-combined.gz
wget http://download.openvz.org/kernel/branches/2.6.27/2.6.27-briullov.1/configs/kernel-2.6.27-x86_64.config.ovz
#OR
wget http://download.openvz.org/kernel/branches/2.6.27/2.6.27-briullov.1/configs/kernel-2.6.27-i686.config.ovz
cp kernel-2.6.27-*.config.ovz .config
patch -p1 < patch*
make oldconfig
make
make modules_install install
cd /boot
mkinitramfs -o /boot/initrd.img-2.6.27 2.6.27
vi /boot/grub/menu.lst
#Replace uuid entries with your disks uuid
title           Ubuntu 8.10 OpenVZ 2.6.27
uuid            2d5b2466-4bdf-44c7-b8e5-4d46a9f927c8
kernel          /boot/vmlinuz-2.6.27 root=UUID=2d5b2466-4bdf-44c7-b8e5-4d46a9f927c8 ro quiet splash
initrd          /boot/initrd.img-2.6.27
quiet
grub-install /dev/sda
apt-get install vzctl vzquota
reboot
If everything went according to plan, you’ll boot into your new kernel. If you get a kernel panic, or things are not working as expected, you may have to
make menuconfig
Once the kernel is working, let’s create a container.
cd /var/lib/vz/private
mkdir 1
debootstrap hardy 1
When you see:
#I: Base system installed successfully.
You can continue.
vi /etc/vz/dists/default
#Change redhat to debian OR copy ubuntu.conf to default
Create the container and set an IP
vzctl set 1 –applyconfig vps.basic –save
vzctl set 1 –ipadd 192.168.100.7 –save
vzctl set 1 –nameserver 192.168.100.1 –save
vzctl start 1
At this time you cannot enter the container. You will receive the error
Unable to open pty: No such file or directory
To fix this:
vzctl exec 1 update-rc.d -f udev remove
Restart and enter the container
vzctl restart 1
vzctl enter 1
If network doesn’t work add to /etc/sysctl.conf on server (not container):
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.all.forwarding=1

No comments: