Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Centos Upgrade 4.x to 5.x

1,168 bytes added, 22:25, 2 June 2011
improved tar based backup/restore
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 temp
</pre>
 == Enter container Install centos-5-release packages==Use <code>vzctl exec</code> to execute the rpm install command on the container: 
<pre>
vzctl enter exec $CTIDrpm -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.
==Install centos-5-release packagesBackup dev==  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.i386.rpm
NoteBackup the container /dev/ directory, as initscripts needs udev and will remove vzdev you'll need the backup: centos-release-5 depends on notes-package, start with that one.
==Backup your /dev/, since initscripts need udev and will remove vzdev you'll net 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 exec $CTID rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.33-1.el5.centos.i386.rpm --force --nodeps
</pre>
Note: 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.
 
==Exit from container==
<pre>
exit
</pre>
==Update conf file==
Alternatively, use the 'sed' command to replace it:
<pre>
sed -i 's#OSTEMPLATE="centos-4#OSTEMPLATE="centos-5#g' /etc/vz/conf/$CSIDCTID.conf
</pre>
==Copy existing template from== Copy existing template from: 
<pre>
/vz/template/centos/4
</pre>
==Update yum.conf== In /vz/template/centos/45/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 -i 's#centos/4/#centos/5/#g' /vz/template/centos/5/i386/config/yum.conf</pre> ==Upgrade container packages== db-version will complain, so delete the conflicting database first:<pre>rm -fr /vz/root/$CTID/var/lib/rpm/__*</pre>
==Upgrade container Now run vzyum to upgrade the contain packages using vzyum (32bit only)==:
<pre>
vzyum $CTID upgrade
</pre>
Note: If yum db-version complains do "rm /vz/root/VZNUM/var/lib/rpm/__*" to delete conflicting db.
==Stop your VE=Troubleshooting=== If you get this error: 
<pre>
vzctl stop $CTIDError: Missing Dependency: python-abi = 2.3 is needed by package python-elementtree
</pre>
==Replace the new and/dev/ with the old one==or
<pre>
cd /vz/private/$CTIDwarning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897rm Public key for libsepol-rf devtar 1.15.2-xvf dev3.el5.i386.tarrpm is not installed
</pre>
==Leave You need to run the container private dir (or it will not start)==following before trying again: 
<pre>
cdvzctl exec $CTID rpm -e --justdb python-elementtree --nodepsvzctl exec $CTID rpm --import http://mirrors.kernel.org/centos/RPM-GPG-KEY-CentOS-5
</pre>
==Start the containerTest your VE==Check you can enter your VE:
<pre>
vzctl start enter $CTID
</pre>
==Remove container IP==All went OK? Exit the VE:
<pre>
vzctl set $CTID --ipdel all --saveexit</pre> ===Troubleshooting=== <pre>Unable to open pty: No such file or directory
</pre>
If you see errors like this, see the [[VPS_enter_failed]] article.
==Stop containeryour VE==
<pre>
vzctl stop $CTID
</pre>
 
==Restore dev==
 
This will replace the new /dev/ with the old one:
<pre>
mv /vz/private/$CTID/dev /vz/private/$CTID/dev.old
tar -xvf $CTID.dev.tar -C /vz/private/$CTID
</pre>
 
== Remove container IP ==
<pre>
vzctl set $CTID --ipdel all --save
</pre>
27
edits