OpenVZ Logo

Install OpenVZ and a CentOS Container

OpenVZ (Open Virtuozzo) is an operating system-level virtualization technology based on the Linux kernel and operating system. OpenVZ allows a physical server to run multiple isolated operating system instances, called containers, virtual private servers (VPSs), or virtual environments (VEs). OpenVZ is similar to FreeBSD jails and Solaris Containers.

Download the OpenVZ repo.

wget -P /etc/yum.repos.d/

Import OpenVZ GPG key.

rpm --import

Install OpenVZ

yum install -y ovzkernel vzctl vzquota ploop

Modify the /etc/sysctl.conf file

# Enables the kernel magic-sysrq key
kernel.sysrq = 1

# Not all the network interfaces should send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

# Enables source route verification
net.ipv4.conf.all.rp_filter = 1

# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0

Permanately disable SELinux by modifying /etc/sysconfig/selinux


Download a template

cd /vz/template/cache

reboot to the default OpenVZ kernel.

Create a new container

vzctl create 1001 --ostemplate centos-5-x86_64

Modify settings

vzctl set 1001 --hostname --ipadd --userpasswd root:[newpasswd] --save

If you wanted it to boot up with the system

vzctl set 1001 --onboot yes --save

Start / stop the container

vzctl start 1001
vzctl stop 1001
vzctl stop 1001 --fast

Enter the container

vzctl enter 1001

Run commands from within vzctl

vzctl exec 1001 service sshd status

List containers

vzlist 1001
vzlist -a 

Create a computer name

vzctl set 1001 --name computer1 --save
vzctl stop computer1