Installing And Using OpenVZ On Debian Wheezy (AMD64) - Page 2
2.2 Installing The Debian Wheezy Kernel From The OpenVZ Project
Add the following line to /etc/apt/sources.list:
[...] deb http://download.openvz.org/debian wheezy main
Add the OpenVZ key to apt:
wget -O- "http://ftp.openvz.org/debian/archive.key" | apt-key add -
Update the packages database:
Install the OpenVZ kernel, vzctl, vzquota, and vzdump as follows:
apt-get install vzkernel vzctl vzquota vzdump
Next we have to make sure that the correct kernel (the OpenVZ kernel) is booted when you restart the system. In the output of the last command, you should see something like this:
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-4-amd64
Found initrd image: /boot/initrd.img-3.2.0-4-amd64
Found linux image: /boot/vmlinuz-2.6.32-042stab059.7
Found initrd image: /boot/initrd.img-2.6.32-042stab059.7
This means there is also another kernel on the system (3.2.0), and the openVZ kernel (2.6.32) is not the first in the list. So to make the OpenVZ kernel the default kernel, we have two options - adjust the default kernel in GRUB (recommended) or remove the non-VZ kernel(s).
To adjust the default kernel in GRUB, open /etc/default/grub...
... and modify the GRUB_DEFAULT line (counting starts with 0; because each kernel comes also with a recovery mode, our OpenVZ kernel is the third kernel, so we need to put in 2 here):
[...] GRUB_DEFAULT=2 [...]
Update GRUB afterwards:
To remove the default kernel, run...
apt-get remove linux-image-amd64 linux-image-3.2.0-4-amd64
... and update GRUB:
Now that we have made sure the correct kernel will boot, we can go on.
Next we must check that we are using UUIDs instead of device names in /etc/fstab because otherwise the system might not boot with the OpenVZ kernel. Run...
... to find out the UUIDs of your devices/partitions:
[email protected]:/tmp# blkid
/dev/mapper/server1-swap_1: UUID="c465cb44-1bf9-4fbe-bb31-17139fd43004" TYPE="swap"
/dev/sda5: UUID="WRK6Xm-fg52-T836-sp4k-6uxm-trHH-FiRdBx" TYPE="LVM2_member"
/dev/sda1: UUID="46d1bd79-d761-4b23-80b8-ad20cb18e049" TYPE="ext2"
/dev/mapper/server1-root: UUID="d5ac6d76-0b69-46da-b0c1-a4376f2f0e4e" TYPE="ext4"
My original /etc/fstab looks as follows (as you see, the UUID of the /boot partition is already being used, but for / and swap, the device names are in use):
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> /dev/mapper/server1-root / ext4 errors=remount-ro 0 1 # /boot was on /dev/sda1 during installation UUID=46d1bd79-d761-4b23-80b8-ad20cb18e049 /boot ext2 defaults 0 2 /dev/mapper/server1-swap_1 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
Modify it so that UUIDs are used for all partitions:
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> #/dev/mapper/server1-root / ext4 errors=remount-ro 0 1 UUID=d5ac6d76-0b69-46da-b0c1-a4376f2f0e4e / ext4 errors=remount-ro 0 1 # /boot was on /dev/sda1 during installation UUID=46d1bd79-d761-4b23-80b8-ad20cb18e049 /boot ext2 defaults 0 2 #/dev/mapper/server1-swap_1 none swap sw 0 0 UUID=c465cb44-1bf9-4fbe-bb31-17139fd43004 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
Create a symlink from /var/lib/vz to /vz to provide backward compatibility:
ln -s /var/lib/vz /vz
Open /etc/sysctl.conf and make sure that you have the following settings in it:
[...] 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 [...]
If you need to modify /etc/sysctl.conf, run
The following step is important if the IP addresses of your virtual machines are from a different subnet than the host system's IP address. If you don't do this, networking will not work in the virtual machines!
Open /etc/vz/vz.conf and set NEIGHBOUR_DEVS to all:
[...] # Controls which interfaces to send ARP requests and modify APR tables on. NEIGHBOUR_DEVS=all [...]
Finally, reboot the system:
If your system reboots without problems, then everything is fine!
and your new OpenVZ kernel should show up: