Posted on August 31, 2023 by nexonhost
How To Install OpenVZ On Ubuntu 20.4
1. Add OpenVZ Repository
Switch to root user:
sudo su
First, we will add OpenVZ Repository.
cat << EOF > /etc/apt/sources.list.d/openvz-rhel6.list deb http://download.openvz.org/debian wheezy main # deb http://download.openvz.org/debian wheezy-test main EOF
Import OpenVZ GPG key:
wget http://ftp.openvz.org/debian/archive.key
apt-key add archive.key
2. Install OpenVZ kernel
Update software sources using command:
sudo apt-get update
Now, install OpenVZ kernel:
apt-get install linux-image-openvz-amd64
Or, if you still have i686:
apt-get update && apt-get install linux-image-openvz-686
3. Setting up Kernel parameters
Make sure you have added the following kernel parameters before logging into vz kernel.
vi sysctl.conf
Add the following lines:
# On Hardware Node we generally need # 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 # Enables source route verification net.ipv4.conf.all.rp_filter = 1 # Enables the magic-sysrq key kernel.sysrq = 1 # We do not want all our interfaces to send redirects net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0
5. Install OpenVz usage statistics tools
The following tools to be installed to gather the OpenVZ usage statistics.
apt-get install vzctl vzquota ploop vzstats
→ reboot
While creating VMs, make sure you have the same subnet on both physical and virtual machine. If you want to use different subnet, you have to edit /etc/vz/vz.conf file,
vi /etc/vz/vz.conf
Find and uncomment the line:
NEIGHBOUR_DEVS=detect
And, change it to:
NEIGHBOUR_DEVS=all