27
edits
Changes
improved tar based backup/restore
{{wikify}} [[Category:Templates]] To create a centos CentOS 5 minimal template from centos-4-i386-minimal ,follow these steps: ==Create the container== Create a container using centos-4-i386-minimal and set a valid nameserver:<pre>vzctl create $CTID --ostemplate centos-4-i386-minimal --config CONFIG_TEMPLATE --ipadd container_IP --hostname tempvzctl set $CTID --nameserver NAMESERVER_IP --save</pre> ==Install centos-5-release packages==Use <code>vzctl exec</code> to execute the next stepsrpm install command on the container: <pre>vzctl exec $CTID rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.6-0.i386.rpm \ http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-6.el5.centos.1.i386.rpm</pre>Note: centos-release-5 depends on notes-package, start with that one. ==Backup dev== Backup the container /dev/ directory, as initscripts needs udev and will remove vzdev you'll need the backup: <pre>tar -cf $CTID.dev.tar -C /vz/private/$CTID dev</pre> ==Install initscripts package== Install initscripts package (forced and with no deps), as per below:
<pre>
vzctl create VEID exec $CTID rpm --ostemplate Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-48.45.33-1.el5.centos.i386-minimal --config CONFIG_TEMPLATE --ipadd VPS_IP --hostname tempvzctl set VEID .rpm --nameserver NAMESERVER_IP force --savenodeps
</pre>
<pre>
</pre>
<pre>
</pre>
Alternatively, use the 'sed' command to replace it:<pre>sed -i 's#OSTEMPLATE="centos-4#OSTEMPLATE="centos-5#g' /etc/vz/conf/$CTID.conf</pre> ==Copy existing template== Copy existing template from: <pre>/vz/template/centos/4</pre>to<pre>/vz/template/centos/5</pre> ==Update yum.conf== In /vz/template/centos/5/i386/config/yum.conf change mirrors to CentOS 5 Using sed: <pre>sed -i 's#centos4#centos5#g' /vz/template/centos/5/i386/config/yum.confsed -i 's#CentOS 4 #CentOS 5#g' /vz/template/centos/5/i386/config/yum.confsed - Backup your i 's#centos/dev4/#centos/5/#g' /vz/template/centos/5/i386/config/yum.conf</pre> ==Upgrade container packages== db-version will complain, since initscripts need udev and will remove vzdev you'll net so delete the backupconflicting database first:
<pre>
</pre>
<pre>
</pre>
<pre>
</pre>
<pre>
</pre>
<pre>
vzctl stop VEIDenter $CTID
</pre>
<pre>
</pre>
<pre>
</pre>
<pre>
vzctl start VEIDstop $CTID
</pre>
<pre>
</pre>
<pre>
vzctl stop VEIDset $CTID --ipdel all --save
</pre>
<pre>
cd /vz/private/VEID$CTIDtar --numeric-owner -zcf /vz/template/cache/centos-5.05-i386-minimal.tar.gz .
</pre>