Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Centos Upgrade 4.x to 5.x

1,496 bytes added, 22:25, 2 June 2011
improved tar based backup/restore
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>
2  ==Install centos- Enter in 5-release packages==Use <code>vzctl exec</code> to execute the rpm install command on the container: 
<pre>
vzctl enter exec $CTID</pre>3 - Install centos-5-release packages<pre>rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.56-0.i386.rpmrpm -Uvh \ http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-56.el5.centos.1.i386.rpm
</pre>
Note: centos-release-5 depends on notes-package, start with that one.
4 - ==Backup your dev== Backup the container /dev/directory, since as initscripts need needs udev and will remove vzdev you'll net need the backup: 
<pre>
tar -cf $CTID.dev.tar .-C /vz/private/$CTID dev
</pre>
5 - ==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.3033-21.el5.centos.i386.rpm --force --nodeps
</pre>
6 - Exit from 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>
exitOSTEMPLATE="centos-4-i386-minimal"
</pre>
7 - In /etc/vz/conf/CSID.conf replacewith
<pre>
OSTEMPLATE="centos-45-i386-minimal"
</pre>
 Alternatively, use the 'sed' command toreplace it:
<pre>
sed -i 's#OSTEMPLATE="centos-4#OSTEMPLATE="centos-5-i386-minimal"#g' /etc/vz/conf/$CTID.conf
</pre>
8 - Coppy ==Copy existing template== Copy existing template from: 
<pre>
/vz/template/centos/4
/vz/template/centos/5
</pre>
9 - In /vz/template/centos/4/i386/config/yum.conf change mirrors to CentOS 5
10 - Upgrade container packages using vzyum (32bit only)==Update yum.conf== In /vz/template/centos/5/i386/config/yum.conf change mirrors to CentOS 5 Using sed: 
<pre>
vzyum CTID upgradesed -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>
Note: on 64-bit yum db-version might complain. Do "rm /vz/root/VZNUM/var/lib/rpm/__*" to delete conflicting DB.
11 ==Upgrade container packages== db- Stop your VEversion will complain, so delete the conflicting database first:
<pre>
vzctl stop rm -fr /vz/root/$CTID/var/lib/rpm/__*
</pre>
12 - Replace Now run vzyum to upgrade the new /dev/ with the old onecontain packages:
<pre>
cd /vz/private/vzyum $CTIDrm -rf devtar -xvf dev.tarupgrade
</pre>
13 ===Troubleshooting=== If you get this error: <pre>Error: Missing Dependency: python- Leave the container private dir (abi = 2.3 is needed by package python-elementtree</pre> and/or it will not stard)
<pre>
cdwarning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897Public key for libsepol-1.15.2-3.el5.i386.rpm is not installed
</pre>
14 - Start You need to run the containerfollowing before trying again: 
<pre>
vzctl start exec $CTIDrpm -e --justdb python-elementtree --nodepsvzctl exec $CTID rpm --import http://mirrors.kernel.org/centos/RPM-GPG-KEY-CentOS-5
</pre>
15 - Remove container IP==Test your VE==Check you can enter your VE:
<pre>
vzctl set --ipdel container_IPenter $CTID
</pre>
16 - Stop containerAll went OK? Exit the VE:
<pre>
vzctl stop CTIDexit
</pre>
17 ===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 your 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.oldtar -xvf $CTID.dev.tar -C /vz/private/$CTID</pre> == Remove container IP ==<pre>vzctl set $CTID --ipdel all -- save</pre> ==Create the template==
<pre>
cd /vz/private/$CTID
tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .
</pre>
27
edits