Install OpenVZ on CentOS 6

Posted by in Scripts

I have put together a script for installing OpenVZ on CentOS 6. Part of this script was borrowed from Tim at

yum update -y
yum install -y wget
cd /etc/yum.repos.d
rpm --import
yum install -y vzkernel.x86_64
yum install -y vzctl vzquota
sed -i 's/kernel.sysrq = 0/kernel.sysrq = 1/g' /etc/sysctl.conf
sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
echo 'net.ipv4.conf.default.proxy_arp = 0' >> /etc/sysctl.conf
echo 'net.ipv4.conf.all.rp_filter = 1' >> /etc/sysctl.conf
echo 'net.ipv4.conf.default.send_redirects = 1' >> /etc/sysctl.conf
echo 'net.ipv4.conf.all.send_redirects = 0' >> /etc/sysctl.conf
echo 'net.ipv4.icmp_echo_ignore_broadcasts=1' >> /etc/sysctl.conf
echo 'net.ipv4.conf.default.forwarding=1' >> /etc/sysctl.conf
sysctl -p
sed -i 's/NEIGHBOUR_DEVS=detect/NEIGHBOUR_DEVS=all/g' /etc/vz/vz.conf
sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/sysconfig/selinux
cd /vz/template/cache
yum install -y ntp
ntpdate -u
chkconfig ntpd on
iptables -D FORWARD 1

After you run this, assuming all goes as it should, just reboot and you’ll be all set!