6,534
edits
Changes
created
This article describes the procedure of manual template update, using Fedora template as an example.
This is useful in the case you have some precreated template which is a bit old, and you want to create many VEs based on it. To escape the updating of all those new VEs right after their creation, it makes sense to update the template itself.
The idea is simple: you create a temporary VE, start it, run the update cycle and then pack the results into a tarball. Some caution must be taken in order for this tarball to be clean though.
The below instructions are for updating Fedora 7 template for PPC architecture, using VE IDs 111 and 222 as temporary VEs. Please substitute your own VE IDs and template names.
== Creating/starting a temporary VE ==
You should create a temporary VE first.
# vzctl create 111 --ostemplate fedora-7-ppc-minimal
Next you should assign a proper IP address to it. This IP does not have to be public -- see [[Using NAT for VE with private IPs]].
# vzctl set 111 --ipadd 10.0.0.111 --save
Finally, start your new VE:
# vzctl start 111
== Updating a VE ==
First, enter a VE:
# vzctl enter 111
Check that you can access Internet:
<pre>
# ping -c 1 www.ru
PING www.ru (194.87.0.50) 56(84) bytes of data.
64 bytes from www.ru (194.87.0.50): icmp_seq=1 ttl=56 time=1.92 ms
--- www.ru ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.920/1.920/1.920/0.000 ms
</pre>
Next, run the update procedure:
# yum -y update
As this can take a few minutes or even hours, this is good time to go make some coffee.
== Clean up ==
Сlean the yum repository inside a VE to minimize:
# yum clean all
Еxit from a VE and stop it:
# logout
exited from VE 111
# vzctl stop 111
Remove the IP from the VE:
# vzctl set 111 --ipdel all --save
== Packing a new template cache ==
Now, rename or remove the existing template cache:
# mv /vz/template/cache/fedora-7-ppc-minimal.tar.gz /vz/template/cache/fedora-7-ppc-minimal.tar.gz-old
Now create a new tarball:
# cd /vz/private/111
# tar czf /vz/template/cache/fedora-7-ppc-minimal.tar.gz .
Clean up:
# vzctl destroy 111
== Testing ==
First, compare the sizes of the old and the new template caches:
# ls -lh /vz/template/cache/fedora-7-ppc-minimal*
-rw-r--r-- 1 root root 99M 2007-11-13 18:11 /vz/template/cache/fedora-7-ppc-minimal.tar.gz
-rw-r--r-- 1 root root 91M 2007-08-31 02:46 /vz/template/cache/fedora-7-ppc-minimal.tar.gz-old
The sizes should not differ much.
Try to create and start VE made from your new template:
# vzctl create 222 --ostemplate fedora-7-ppc-minimal
# vzctl set 222 --ipadd 10.0.0.222 --save
# vzctl start 222
# vzctl enter 222
Now execute a few basic commands to check VE is fine. Examples are: ps ax, rpm -qa, etc.
Finally, clean up the testing VE:
# vzctl stop 222
# vzctl destroy 222
[[Category: HOWTO]]
[[Category: Templates]]
This is useful in the case you have some precreated template which is a bit old, and you want to create many VEs based on it. To escape the updating of all those new VEs right after their creation, it makes sense to update the template itself.
The idea is simple: you create a temporary VE, start it, run the update cycle and then pack the results into a tarball. Some caution must be taken in order for this tarball to be clean though.
The below instructions are for updating Fedora 7 template for PPC architecture, using VE IDs 111 and 222 as temporary VEs. Please substitute your own VE IDs and template names.
== Creating/starting a temporary VE ==
You should create a temporary VE first.
# vzctl create 111 --ostemplate fedora-7-ppc-minimal
Next you should assign a proper IP address to it. This IP does not have to be public -- see [[Using NAT for VE with private IPs]].
# vzctl set 111 --ipadd 10.0.0.111 --save
Finally, start your new VE:
# vzctl start 111
== Updating a VE ==
First, enter a VE:
# vzctl enter 111
Check that you can access Internet:
<pre>
# ping -c 1 www.ru
PING www.ru (194.87.0.50) 56(84) bytes of data.
64 bytes from www.ru (194.87.0.50): icmp_seq=1 ttl=56 time=1.92 ms
--- www.ru ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.920/1.920/1.920/0.000 ms
</pre>
Next, run the update procedure:
# yum -y update
As this can take a few minutes or even hours, this is good time to go make some coffee.
== Clean up ==
Сlean the yum repository inside a VE to minimize:
# yum clean all
Еxit from a VE and stop it:
# logout
exited from VE 111
# vzctl stop 111
Remove the IP from the VE:
# vzctl set 111 --ipdel all --save
== Packing a new template cache ==
Now, rename or remove the existing template cache:
# mv /vz/template/cache/fedora-7-ppc-minimal.tar.gz /vz/template/cache/fedora-7-ppc-minimal.tar.gz-old
Now create a new tarball:
# cd /vz/private/111
# tar czf /vz/template/cache/fedora-7-ppc-minimal.tar.gz .
Clean up:
# vzctl destroy 111
== Testing ==
First, compare the sizes of the old and the new template caches:
# ls -lh /vz/template/cache/fedora-7-ppc-minimal*
-rw-r--r-- 1 root root 99M 2007-11-13 18:11 /vz/template/cache/fedora-7-ppc-minimal.tar.gz
-rw-r--r-- 1 root root 91M 2007-08-31 02:46 /vz/template/cache/fedora-7-ppc-minimal.tar.gz-old
The sizes should not differ much.
Try to create and start VE made from your new template:
# vzctl create 222 --ostemplate fedora-7-ppc-minimal
# vzctl set 222 --ipadd 10.0.0.222 --save
# vzctl start 222
# vzctl enter 222
Now execute a few basic commands to check VE is fine. Examples are: ps ax, rpm -qa, etc.
Finally, clean up the testing VE:
# vzctl stop 222
# vzctl destroy 222
[[Category: HOWTO]]
[[Category: Templates]]