How to make a new OpenVZ template from an existing template for Proxmox
Category : How-to
The kind folks over at OpenVZ.org have created a rift of templates which we can use as a starting point for our template. It is possible however, to create your own template from scratch based on your favorite Linux distribution – that will be coming in a later blog post.
The starting point for this blog post is to have downloaded a template and started it up in a container. If you don’t have any templates you can download one from OpenVZ. If you use Proxmox as your hypervisor you can download one via the web gui by clicking on your storage, clicking and finally Templates.
So, as I say, you need to have a container up and running and for this post we are going to assume it is running under the VMID of 100. Make any required changes to the template such as:
- apt-get update && apt-get upgrade (for Debian based containers).
- yum update (for anything RedHat).
When you are ready to create the template, turn of the container by using the GUI’s Shutdown button or issuing the command halt in the containers terminal.
Once this is complete, login via SSH to the Proxmox server and cd to the root directory of the container. If you have the default setup, this will be /var/lib/vz/private/100.
ssh root@proxmoxserver cd /var/lib/vz/private/100
Issue the tar command to create the template archive (remember to keep the . on the end, it’s important!). You can change the container template name to anything you like, but I have found it best to conform to the following formula:
tar -cvzpf /var/lib/vz/template/cache/oracle-6-x86_64-intitial.tar.gz .
That’s it! You can now select the container when creating a template from either the GUI or using CLI commands.
I have made a patch for the Proxmox web GUI to add this functionality to the the interface. See my GUI changes blog post for more information.