Difference between revisions of "Updating Debian template"
(cagegorized) |
Botinki Kira (talk | contribs) m (Robot: Automated text replacement (-VE +container)) |
||
Line 1: | Line 1: | ||
This article describes how you can update an existing precreated Debian or Ubuntu template. The procedure is pretty easy. | This article describes how you can update an existing precreated Debian or Ubuntu template. The procedure is pretty easy. | ||
− | == Creating/configuring a temporary | + | == Creating/configuring a temporary container == |
− | First, you need to create a | + | First, you need to create a container based on the template you want to update. Here is an example: |
[HN]# vzctl create 555 --ostemplate debian-4.0-i386-minimal | [HN]# vzctl create 555 --ostemplate debian-4.0-i386-minimal | ||
Line 10: | Line 10: | ||
[HN]# 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 | + | You can get the value of nameserver from your /etc/resolv.conf. Your container should have an Internet access, so you either supply a public IP, or see [[using NAT for container with private IPs]] for information about how to use private IP and NAT. |
− | Finally, check that Internet is working from inside a | + | Finally, check that Internet is working from inside a container: |
[HN]# vzctl exec 555 ping -n 3 www.ru | [HN]# vzctl exec 555 ping -n 3 www.ru | ||
== Update == | == Update == | ||
− | Enter the | + | Enter the container: |
[HN]# vzctl enter 555 | [HN]# vzctl enter 555 | ||
Update metadata and install updates: | Update metadata and install updates: | ||
− | [ | + | [container]# apt-get update && apt-get upgrade |
Cleanup: | Cleanup: | ||
− | [ | + | [container]# apt-get clean |
− | [ | + | [container]# > /etc/resolv.conf |
− | Clean unused log files, .bash_history etc, then exit from a | + | Clean unused log files, .bash_history etc, then exit from a container: |
− | [ | + | [container] # exit |
− | Stop a | + | Stop a container, remove its IP: |
[HN]# vzctl stop 555 | [HN]# vzctl stop 555 | ||
[HN]# vzctl set 555 --ipdel all --save | [HN]# vzctl set 555 --ipdel all --save | ||
Line 55: | Line 55: | ||
The sizes should not differ much. | The sizes should not differ much. | ||
− | Try to create and start | + | Try to create and start container made from your new template: |
[HN]# vzctl create 222 --ostemplate debian-4.0-i386-minimal | [HN]# vzctl create 222 --ostemplate debian-4.0-i386-minimal | ||
[HN]# vzctl set 222 --ipadd 10.0.0.222 --save | [HN]# vzctl set 222 --ipadd 10.0.0.222 --save | ||
Line 61: | Line 61: | ||
[HN]# vzctl enter 222 | [HN]# vzctl enter 222 | ||
− | Now execute a few basic commands to check | + | Now execute a few basic commands to check container is fine. Examples are: <code>ps axf</code>, <code>dpkg -l</code>, etc. |
− | Finally, clean up the testing | + | Finally, clean up the testing container: |
[HN]# vzctl stop 222 | [HN]# vzctl stop 222 | ||
[HN]# vzctl destroy 222 | [HN]# vzctl destroy 222 |
Revision as of 13:00, 11 March 2008
This article describes how you can update an existing precreated Debian or Ubuntu template. The procedure is pretty easy.
Contents
Creating/configuring a temporary container
First, you need to create a container 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 container should have an Internet access, so you either supply a public IP, or see using NAT for container with private IPs for information about how to use private IP and NAT.
Finally, check that Internet is working from inside a container:
[HN]# vzctl exec 555 ping -n 3 www.ru
Update
Enter the container:
[HN]# vzctl enter 555
Update metadata and install updates:
[container]# apt-get update && apt-get upgrade
Cleanup:
[container]# apt-get clean [container]# > /etc/resolv.conf
Clean unused log files, .bash_history etc, then exit from a container:
[container] # exit
Stop a container, remove its IP:
[HN]# vzctl stop 555 [HN]# 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 container 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 container is fine. Examples are: ps axf
, dpkg -l
, etc.
Finally, clean up the testing container:
[HN]# vzctl stop 222 [HN]# vzctl destroy 222 [HN]# rm -f /etc/vz/conf/222.conf.destroyed