How to create OpenVZ virtual machine?

[Total: 5    Average: 5/5]

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:

[root@24x7serversolutions ~]# cd /vz/template/cache
[root@24x7serversolutions ~]# wget

Download CentOS 64 bit template:

[root@24x7serversolutions ~]# cd /vz/template/cache
[root@24x7serversolutions ~]# 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: [10 is VPS ID you can use as per your requirement]

[root@24x7serversolutions ~]# vzctl create 10 –ostemplate ubuntu-9.04-x86_64
[root@24x7serversolutions ~]# vzctl set 10 –onboot yes --save

Set IP for VPS

[root@24x7serversolutions ~]# vzctl set 10 –ipadd --save

Set Nameservers IP for VPS

[root@24x7serversolutions ~]# vzctl set 10 –nameserver --save
[root@24x7serversolutions ~]# vzctl set 10 –nameserver --save

Set Hostname IP for VPS

[root@24x7serversolutions ~]# vzctl set 10 --save

Set Disk quota for VPS (10G min [soft] and 11G max hard limit)

[root@24x7serversolutions ~]# vzctl set 10 –diskspace 10G:11G --save

Start the vps

[root@24x7serversolutions ~]# vzctl start 10

Set root user password for VPS

[root@24x7serversolutions ~]# 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.