Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Centos Upgrade 4.x to 5.x

1,855 bytes added, 22:25, 2 June 2011
improved tar based backup/restore
{{wikify}}
 
[[Category:Templates]]
 
To create a CentOS 5 minimal template from centos-4-i386-minimal,
follow these steps:
1 - ==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 rpm 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 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 container_IP --hostname tempvzctl set CTID .rpm --nameserver NAMESERVER_IP force --savenodeps
</pre>
2 - Enter in containerNote: If the "transfer failed", go to the [http://mirror.centos.org/centos/5/os/i386/CentOS/ CentOS5 mirror] and find the latest initscripts rpm and use that instead. ==Update conf file== Edit /etc/vz/conf/$CSID.conf and replace
<pre>
vzctl enter CTIDOSTEMPLATE="centos-4-i386-minimal"
</pre>
3 - Install centos-5-release packageswith
<pre>
rpm -Uvh http://mirror.centos.org/centos/5.0/os/i386/CentOS/OSTEMPLATE="centos-release-notes-5.0.0-2.i386.rpmrpm -Uvh http://mirror.centos.org/centos/5.0/os/i386/CentOS/centos-release-5-0.0.el5.centos.2.i386.rpmminimal"
</pre>
Note: centos-release-5 depends on notes-package, start with that one.
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>
tar rm -cf dev.tar .fr /devvz/root/$CTID/var/lib/rpm/__*
</pre>
5 - Install initscripts package (forced and with no deps)Now run vzyum to upgrade the contain packages:
<pre>
rpm -Uvh http://mirror.centos.org/centos/5.0/os/i386/CentOS/initscripts-8.45.14.EL-1.el5.centos.1.i386.rpm --force --nodepsvzyum $CTID upgrade
</pre>
6 - Exit from container===Troubleshooting=== If you get this error: 
<pre>
exitError: Missing Dependency: python-abi = 2.3 is needed by package python-elementtree</pre> and/or<pre>warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897Public key for libsepol-1.15.2-3.el5.i386.rpm is not installed
</pre>
7 - Upgrade container packages using vzyum (32bit only)You need to run the following before trying again: 
<pre>
vzyum vzctl exec $CTID upgraderpm -e --justdb python-elementtree --nodepsvzctl exec $CTID rpm --import http://mirrors.kernel.org/centos/RPM-GPG-KEY-CentOS-5
</pre>
Note: on 64-bit yum db-version might complain. Do "rm /vz/root/VZNUM/var/lib/rpm/__*" to delete conflicting DB.
8 - Stop ==Test your VE==Check you can enter your VE:
<pre>
vzctl stop enter $CTID
</pre>
9 - Replace All went OK? Exit the new /dev/ with the old oneVE:
<pre>
cd /vz/private/CTIDrm -rf devtar -xvf dev.tarexit
</pre>
10 - Leave the container private dir (or it will not stard)===Troubleshooting=== 
<pre>
cdUnable to open pty: No such file or directory
</pre>
11 - Start If you see errors like this, see the container[[VPS_enter_failed]] article. ==Stop your VE==
<pre>
vzctl start stop $CTID
</pre>
12 - Remove container IP==Restore dev== This will replace the new /dev/ with the old one:
<pre>
vzctl set mv /vz/private/$CTID/dev /vz/private/$CTID/dev.oldtar -xvf $CTID.dev.tar -ipdel container_IPC /vz/private/$CTID
</pre>
13 - Stop == Remove containerIP ==
<pre>
vzctl stop set $CTID--ipdel all --save
</pre>
14 - ==Create the template==
<pre>
cd /vz/private/$CTIDtar --numeric-owner -zcf /vz/template/cache/centos-5.05-i386-minimal.tar.gz .
</pre>
27
edits