Creating an OpenVZ template in Proxmox

Written by admin on March 15, 2015. Posted in Virtualisation

We use Proxmox in our hosted servers (of which 90 % are voip servers) at http://vps4hire.com . At one time i needed to create a template in proxmox of a CT for use in automatic deployments on the server. Most of the templates i had been migrated from SolusVM. I googled around and found this article  https://raymii.org/s/tutorials/OpenVZ_Proxmox_Container_to_Template.html. However every time i tried to use the method i got a message saying

tar: Cowardly refusing to create an empty archive
Try 'tar --help' or 'tar --usage' for more information.

The solution i found was to create it the following way.

Lets say container is number is 132

in command prompt you must stop the container before creating the image:

vzctl stop 132
Stopping container ...
Container was stopped
Container is unmounted

Go to the private folder:

cd /var/lib/vz/private/

Then start image creation:

cd 132/ && tar -zcvf ../centos-v-1.tar.gz . && cd .. 

Then copy your created file to templates folder:

cp centos-v-1.tar.gz /var/lib/vz/private/template/cache

Thats it you can now start using the template. Remember to specify you OS in the name of your template.