Difference between revisions of "Updating Debian template"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(Update: Stop a VE, remove its IP)
(I think the common abbreviation for Hardware Node is HN, not HW. Also why does it suddenly use VE0?)
Line 5: Line 5:
 
First, you need to create a VE based on the template you want to update. Here is an example:
 
First, you need to create a VE based on the template you want to update. Here is an example:
  
  [HW]# vzctl create 555 --ostemplate debian-4.0-i386-minimal
+
  [HN]# vzctl create 555 --ostemplate debian-4.0-i386-minimal
  
 
Next, you want to specify an IP address and a nameserver:
 
Next, you want to specify an IP address and a nameserver:
  [HW]# vzctl set 555 --ipadd x.x.x.x --nameserver y.y.y.y --save
+
  [HN]# vzctl set 555 --ipadd x.x.x.x --nameserver y.y.y.y --save
  
 
You can get the value of nameserver from your /etc/resolv.conf. Your VE should have an Internet access, so you either supply a public IP, or see [[using NAT for VE with private IPs]] for information about how to use private IP and NAT.
 
You can get the value of nameserver from your /etc/resolv.conf. Your VE should have an Internet access, so you either supply a public IP, or see [[using NAT for VE with private IPs]] for information about how to use private IP and NAT.
  
 
Finally, check that Internet is working from inside a VE:
 
Finally, check that Internet is working from inside a VE:
  [HW]# vzctl exec 555 ping -n 3 www.ru
+
  [HN]# vzctl exec 555 ping -n 3 www.ru
  
 
== Update ==
 
== Update ==
 
   
 
   
 
Enter the VE:
 
Enter the VE:
  [HW]# vzctl enter 555
+
  [HN]# vzctl enter 555
  
 
Update metadata and install updates:
 
Update metadata and install updates:
Line 37: Line 37:
  
 
Now, rename the existing template cache:
 
Now, rename the existing template cache:
  [HW]# mv /vz/template/cache/debian-4.0-i386-minimal.tar.gz{,-old}
+
  [HN]# mv /vz/template/cache/debian-4.0-i386-minimal.tar.gz{,-old}
  
 
Now create a new tarball:
 
Now create a new tarball:
  [HW]# cd /vz/private/555
+
  [HN]# cd /vz/private/555
  [HW]# tar czf /vz/template/cache/debian-4.0-i386-minimal.tar.gz .
+
  [HN]# tar czf /vz/template/cache/debian-4.0-i386-minimal.tar.gz .
  
 
Clean up:
 
Clean up:
  [HW]# vzctl destroy 555
+
  [HN]# vzctl destroy 555
  [HW]# rm -f /etc/vz/conf/555.conf.destroyed
+
  [HN]# rm -f /etc/vz/conf/555.conf.destroyed
  
 
== Test new template cache ==
 
== Test new template cache ==
  
 
First, compare the sizes of the old and the new template caches:
 
First, compare the sizes of the old and the new template caches:
  [HW]# ls -lh /vz/template/cache/debian-4.0-i386-minimal*
+
  [HN]# ls -lh /vz/template/cache/debian-4.0-i386-minimal*
 
  -rw-r--r-- 1 root root  55M 2007-11-13 18:11 /vz/template/cache/debian-4.0-i386-minimal.tar.gz
 
  -rw-r--r-- 1 root root  55M 2007-11-13 18:11 /vz/template/cache/debian-4.0-i386-minimal.tar.gz
 
  -rw-r--r-- 1 root root  53M 2007-08-31 02:46 /vz/template/cache/debian-4.0-i386-minimal.tar.gz-old
 
  -rw-r--r-- 1 root root  53M 2007-08-31 02:46 /vz/template/cache/debian-4.0-i386-minimal.tar.gz-old
Line 56: Line 56:
  
 
Try to create and start VE made from your new template:
 
Try to create and start VE made from your new template:
  [HW]# vzctl create 222 --ostemplate debian-4.0-i386-minimal
+
  [HN]# vzctl create 222 --ostemplate debian-4.0-i386-minimal
  [HW]# vzctl set 222 --ipadd 10.0.0.222 --save
+
  [HN]# vzctl set 222 --ipadd 10.0.0.222 --save
  [HW]# vzctl start 222
+
  [HN]# vzctl start 222
  [HW]# vzctl enter 222
+
  [HN]# vzctl enter 222
  
 
Now execute a few basic commands to check VE is fine. Examples are: <code>ps axf</code>, <code>dpkg -l</code>, etc.
 
Now execute a few basic commands to check VE is fine. Examples are: <code>ps axf</code>, <code>dpkg -l</code>, etc.
  
 
Finally, clean up the testing VE:
 
Finally, clean up the testing VE:
  [HW]# vzctl stop 222
+
  [HN]# vzctl stop 222
  [HW]# vzctl destroy 222
+
  [HN]# vzctl destroy 222
  [HW]# rm -f /etc/vz/conf/222.conf.destroyed
+
  [HN]# rm -f /etc/vz/conf/222.conf.destroyed

Revision as of 00:51, 16 November 2007

This article describes how you can update an existing precreated Debian or Ubuntu template. The procedure is pretty easy.

Creating/configuring a temporary VE

First, you need to create a VE based on the template you want to update. Here is an example:

[HN]# vzctl create 555 --ostemplate debian-4.0-i386-minimal

Next, you want to specify an IP address and a nameserver:

[HN]# vzctl set 555 --ipadd x.x.x.x --nameserver y.y.y.y --save

You can get the value of nameserver from your /etc/resolv.conf. Your VE should have an Internet access, so you either supply a public IP, or see using NAT for VE with private IPs for information about how to use private IP and NAT.

Finally, check that Internet is working from inside a VE:

[HN]# vzctl exec 555 ping -n 3 www.ru

Update

Enter the VE:

[HN]# vzctl enter 555

Update metadata and install updates:

[VE]# apt-get update && apt-get upgrade

Cleanup:

[VE]# apt-get clean
[VE]# > /etc/resolv.conf

Clean unused log files, .bash_history etc, then exit from a VE:

[VE] # exit

Stop a VE, remove its IP:

[VE0]# vzctl stop 555
[VE0]# vzctl set 555 --ipdel all --save

Packing a new template cache

Now, rename the existing template cache:

[HN]# mv /vz/template/cache/debian-4.0-i386-minimal.tar.gz{,-old}

Now create a new tarball:

[HN]# cd /vz/private/555
[HN]# tar czf /vz/template/cache/debian-4.0-i386-minimal.tar.gz .

Clean up:

[HN]# vzctl destroy 555
[HN]# rm -f /etc/vz/conf/555.conf.destroyed

Test new template cache

First, compare the sizes of the old and the new template caches:

[HN]# ls -lh /vz/template/cache/debian-4.0-i386-minimal*
-rw-r--r-- 1 root root  55M 2007-11-13 18:11 /vz/template/cache/debian-4.0-i386-minimal.tar.gz
-rw-r--r-- 1 root root  53M 2007-08-31 02:46 /vz/template/cache/debian-4.0-i386-minimal.tar.gz-old

The sizes should not differ much.

Try to create and start VE made from your new template:

[HN]# vzctl create 222 --ostemplate debian-4.0-i386-minimal
[HN]# vzctl set 222 --ipadd 10.0.0.222 --save
[HN]# vzctl start 222
[HN]# vzctl enter 222

Now execute a few basic commands to check VE is fine. Examples are: ps axf, dpkg -l, etc.

Finally, clean up the testing VE:

[HN]# vzctl stop 222
[HN]# vzctl destroy 222
[HN]# rm -f /etc/vz/conf/222.conf.destroyed