How To Create OpenVZ Virtual Machines (VPS)

How do I create OpenVZ virtual machine (VPS) to run CentOS or Debian as VPS?

OpenVZ comes with a template for each VPS or virtual machine. OpenVZ provides templates for all leading Linux distributions. You need to download those templates in order to create a VPS. Visit this page to grab templates for vps.

Download Ubuntu Linux VPS

Type the following commands to download precreated Ubuntu Linux template:
# cd /vz/template/cache
# wget

Create VPS

Now you’ve download the template for your virtual machine. You can just start a VPS based on the template you have just downloaded, by typing the following commands:
# vzctl create 10 --ostemplate ubuntu-9.04-x86_64
vzctl set 10 --onboot yes --save
### Set IP for VPS ###
vzctl set 10 --ipadd --save
### Set Nameservers IP for VPS ###
vzctl set 10 --nameserver --save
vzctl set 10 --nameserver --save
### Set Hostname IP for VPS ###
vzctl set 10 --hostname --save
### Set Disk quota for VPS (10G min [soft] and 11G max hard limit) ###
vzctl set 10 --diskspace 10G:11G --save
### Okat let start it ###
vzctl start 10
### Set root user password for VPS ###
vzctl exec 10 passwd

vzctl is used to create and set various vps properties such as memory, disk usage and much more. Where,

  • create 10 : Your VPS ID.
  • –ostemplate ubuntu-9.04-x86_64 : VPS template.
  • –config vps.ubuntu: Save configuration.
  • set 10 : Set various option for VPS ID # 10.
  • –onboot yes : Make sure VPS boots automatically after a reboot.
  • –save : Save changes to config file.

Common OpenVZ Admin Tasks

vzctl act as a master tool for various tasks:

How Do I Set VPS Name to ?

# vzctl set 10 --hostname --save

How Do I Set VPS IP Address?

# vzctl set 10 --ipadd --save

How Do I Set VPS DNS Name Servers?

# vzctl set 10 --nameserver --save

How Do I Set Disk Quota?

# vzctl set 10 --diskspace SoftLimitG:HardLimitG --save
# vzctl set 10 --diskspace 10G:12G --save

How Do I Stop / Start / Restart VPS Servers?

# vzctl start 10
# vzctl restart 10
# vzctl stop 10

How Do I Run a Command For VPS?

You can run command as follows
# vzctl exec 10 w
# vzctl exec 10 df
# vzctl exec 10 date
# vzctl exec 10 ps aux

How Do I Login Into VPS Server (container)?

Type the following command
# vzctl enter 10
To exit, simply type:
# exit
You can remotely login to your VPS using a ssh client itself or using putty:
$ ssh

How Do I Destroy VPS?

Type the following command to delete VPS:
# vzctl destroy 10

Another Example: Creating a CentOS Linux VPS

Download CentOS 64 bit template:
# cd /vz/template/cache
# wget

Create a VPS and set various limits (see vzctl man page):
# vzctl create 11 --ostemplate centos-5-x86_64
# vzctl set 11 --quotaugidlimit 150 --numproc 400:400 \
--kmemsize 16384000:18022400 --privvmpages 262144:292912 \ --diskspace 2000000:2000000 \
--shmpages 16384:16384 --ipadd \
--nameserver --nameserver --save
# vzctl set 11 --onboot yes --save

Set the password for vps root user:
# vzctl set 11 --userpasswd root:pass
Start VPS:
# vzctl start 11
Enter into VPS:
# vzctl enter 11
Now you can install additional software and configure your vps:
[vps #] yum update
[vps #] yum install httpd

This entry is 3 of 5 in the RHEL / CentOS Linux OpenVZ Virtualization Tutorial series. Keep reading the rest of the series:
  1. How To Setup OpenVZ under RHEL / CentOS Linux
  2. CentOS Linux Install OpenVZ Virtualization Software
  3. How To Create OpenVZ Virtual Machines (VPS)
  4. OpenVZ Iptables: Allow Traffic To Pass Via venet0 To All VPS
  5. OpenVZ Virtual Machine (VPS) Management

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 10 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
10 comments… add one
  • Solaris Aug 26, 2009 @ 8:45

    From the OpenVz manual:
    “OpenVZ reserves the IDs ranging from 0 to 100. Though OpenVZ uses only ID 0, different versions might use additional Virtual Private Servers IDs for internal needs. To facilitate upgrading, please do not create Virtual Private Servers with IDs below 101.”

  • Amar Apr 30, 2010 @ 13:38


    whn i hve created a VPS with all the instruction u hve mentioned.

    but i can not download anythng on the VPS it gives error –
    wget: unable to resolve host address `’

    i hve added open dns name servers also.

    wht might be the problem??

  • Amar Apr 30, 2010 @ 13:59


    had to edit the firewall settings…


  • AMar Jul 31, 2010 @ 12:58


    How can i add multiple ips to a VPS??

  • Sushant Chawla Nov 8, 2010 @ 12:08

    Hi Vivek

    Can you send me a step by step tutorial for creating template for RHEL5.3. I need it desperately.

    Sushant Chawla

  • Snehal Masne Dec 12, 2010 @ 11:07

    OMG.. Thank you so much..
    I was looking for this info since many days… finally I got it and its working with my server communication to run thin clients…

    Thank you so much, again :)

  • dragun0v Apr 23, 2014 @ 21:28

    Just curious, would renaming domain name of the OpenVZ server impact the openvz containers? Would it require a reboot ?

  • asean4 Dec 17, 2015 @ 4:15

    Thanks admin!

  • namhv Jan 15, 2016 @ 8:18

    Centos 7 error
    “[root@demogame02 ~]# /etc/init.d/network start
    Failed to get D-Bus connection: No such file or directory
    Starting network (via systemctl): Failed to get D-Bus connection: No such file or directory”
    Fix error

  • Syed Sep 12, 2016 @ 8:31

    can i create multiple vps inside a vps?

    i am having a 8GB memory and 100GB disk vps with Cent OS, would like to conform can i divided it and give the individual user panel for users eg: 2GB memory and 25GB disk for each.
    OpenVZ work for this? how to do this

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum