OpenVZ Forum


Home » General » Support » Create a Template from Existing Container (Don't want to run OpenVZ Web Panel)
Create a Template from Existing Container [message #44422] Tue, 06 December 2011 22:37 Go to next message
aaaronic is currently offline  aaaronic
Messages: 2
Registered: December 2011
Location: Canada
Junior Member
I am running Centos 5.7 with kernel 2.6.18-274.7.1.el5.028stab095.1.

I have just vzctl and vzquota installed (these are the only tools available now it seems).

I have read the OpenVZ User Guide and cannot get the package tools that they mention for template creation.

Currently I am successfully cloning my VPS containers using the method in the OpenVZ Wiki (Article name: Cloning_VE)

I had a development server that I installed the OpenVZ Web Panel. Using this Web Panel I was able to create a template based off an existing container. It seemed to do this with just vzctl I think.

I do not want to install the resource intense Control Panel on my production server - but I would love to know how to create a template from an existing container! If anyone knows the command(s) that would be very helpful.

Thanks!
Re: Create a Template from Existing Container [message #44467 is a reply to message #44422] Fri, 09 December 2011 12:11 Go to previous messageGo to next message
azagzin is currently offline  azagzin
Messages: 38
Registered: May 2008
Location: Vilnius
Member
try to use vzdump to make backup of container, and then use this dump as a template. with vzrestore $VE.dump $NEW_VE_ID you can clone your containers.
Re: Create a Template from Existing Container [message #44472 is a reply to message #44467] Fri, 09 December 2011 13:04 Go to previous messageGo to next message
aaaronic is currently offline  aaaronic
Messages: 2
Registered: December 2011
Location: Canada
Junior Member
I already can clone a container perfectly using the guide I mentioned in my first post. I am looking for the exact command(s) to create an actual template from existing container.

I know this is possible with only vzctl as the OpenVZ Web Panel (ovz-web-panel) was able to create a template from an existing container. Does anyone know the commands that the Web Panel would have ran to do this??

Thanks
Re: Create a Template from Existing Container [message #44478 is a reply to message #44422] Fri, 09 December 2011 20:44 Go to previous messageGo to next message
Ales is currently offline  Ales
Messages: 330
Registered: May 2009
Senior Member
Quote:
I am looking for the exact command(s) to create an actual template from existing container.


A template is nothing more than a targzipped dir of a stopped container.

So, for example, you could start with an existing official template, start it up, add / remove some programs, change settings, etc.. Than you'd want to make your custom template out of it. All you'd need to do is clean up within the VM (logs, users, etc.), stop the VM and targzip it's top directory. That's it.

You'd be looking to get something like somedistro-ver-arch.tar.gz with no additional subdirs inside. You can look at the existing templates to get a better picture how the tar.gz should look like.

Than you'd put your tar.gz within /vz/template/cache dir and use it as you're using any other existing template. It really is that simple.

[Updated on: Fri, 09 December 2011 20:47]

Report message to a moderator

Re: Create a Template from Existing Container [message #44525 is a reply to message #44478] Mon, 12 December 2011 20:45 Go to previous message
mustardman is currently offline  mustardman
Messages: 91
Registered: October 2009
Member
I got the following information from the bottom of this procedure .

http://www.powerpbx.org/content/rhel-openvz-template-install -guide

From command line on the actual node.

Create a variable for the OpenVZ container which in this example is 110.

CTID=110

Alternatively you can substitute "$CTID" with the actual CTID in the following commands.

Stop the container by typing vzctl stop $CTID.
Make sure you are in the /vz/private/$CTID folder.
cd /vz/private/$CTID

Finally, package up the new template by typing:
tar -czvf /vz/template/cache/centos-5-<ARCH>-<DISTRO>.tar.gz ./

"centos-5" can also be "centos-6" or "scientificlinux-6" or ? OpenVZ expects the format "OS + "-" + "version".
<ARCH> is also mandatory and MUST be one of the following:
i386, x86, x86_64

<DISTRO> can be whatever you want it to be.

The template is ready for use.

[Updated on: Mon, 12 December 2011 20:50]

Report message to a moderator

Previous Topic: speed problem with CentOS 5
Next Topic: Starting container crashes host
Goto Forum:
  


Current Time: Sat Nov 02 17:59:39 GMT 2024

Total time taken to generate the page: 0.03236 seconds