Editing Centos Upgrade 4.x to 5.x

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 6: Line 6:
 
follow these steps:
 
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
 +
vzctl set CTID --nameserver NAMESERVER_IP --save
 +
</pre>
  
Create a container using centos-4-i386-minimal and set a valid nameserver:
+
==Enter in container==
 
<pre>
 
<pre>
vzctl create $CTID --ostemplate centos-4-i386-minimal --config CONFIG_TEMPLATE --ipadd container_IP --hostname temp
+
vzctl enter CTID
vzctl set $CTID --nameserver NAMESERVER_IP --save
 
 
</pre>
 
</pre>
 
  
 
==Install centos-5-release packages==
 
==Install centos-5-release packages==
Use <code>vzctl exec</code> to execute the rpm install command on the container:
 
 
 
<pre>
 
<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
+
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.5-0.i386.rpm
 +
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-5.el5.centos.i386.rpm
 
</pre>
 
</pre>
 
Note: centos-release-5 depends on notes-package, start with that one.
 
Note: centos-release-5 depends on notes-package, start with that one.
  
==Backup dev==
+
==Backup your /dev/, since initscripts need udev and will remove vzdev you'll net the backup==
 
+
<pre>
Backup the container /dev/ directory, as initscripts needs udev and will remove vzdev you'll need the backup:
+
tar -cf dev.tar ./dev
 +
</pre>
  
 +
==Install initscripts package (forced and with no deps)==
 
<pre>
 
<pre>
tar -cf $CTID.dev.tar -C /vz/private/$CTID dev
+
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.30-2.el5.centos.i386.rpm --force --nodeps
 
</pre>
 
</pre>
  
==Install initscripts package==
+
==Exit from container==
 
 
Install initscripts package (forced and with no deps), as per below:
 
 
 
 
<pre>
 
<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
+
exit
 
</pre>
 
</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.
+
==In /etc/vz/conf/CSID.conf replace==
 
 
==Update conf file==
 
 
 
Edit /etc/vz/conf/$CSID.conf and replace
 
 
<pre>
 
<pre>
 
OSTEMPLATE="centos-4-i386-minimal"
 
OSTEMPLATE="centos-4-i386-minimal"
 
</pre>
 
</pre>
with
+
to
 
<pre>
 
<pre>
 
OSTEMPLATE="centos-5-i386-minimal"
 
OSTEMPLATE="centos-5-i386-minimal"
 
</pre>
 
</pre>
  
Alternatively, use the 'sed' command to replace it:
+
==Copy existing template from==
<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>
 
<pre>
 
/vz/template/centos/4
 
/vz/template/centos/4
Line 69: Line 57:
 
</pre>
 
</pre>
  
==Update yum.conf==
+
==In /vz/template/centos/4/i386/config/yum.conf change mirrors to CentOS 5==
 
 
In /vz/template/centos/5/i386/config/yum.conf change mirrors to CentOS 5
 
 
 
Using sed:
 
  
 +
==Upgrade container packages using vzyum (32bit only)==
 
<pre>
 
<pre>
sed -i 's#centos4#centos5#g' /vz/template/centos/5/i386/config/yum.conf
+
vzyum CTID upgrade
sed -i 's#CentOS 4#CentOS 5#g' /vz/template/centos/5/i386/config/yum.conf
 
sed -i 's#centos/4/#centos/5/#g' /vz/template/centos/5/i386/config/yum.conf
 
 
</pre>
 
</pre>
 +
Note: If yum db-version complains do "rm /vz/root/VZNUM/var/lib/rpm/__*" to delete conflicting db.
  
==Upgrade container packages==
+
==Stop your VE==
 
 
db-version will complain, so delete the conflicting database first:
 
<pre>
 
rm -fr /vz/root/$CTID/var/lib/rpm/__*
 
</pre>
 
 
 
Now run vzyum to upgrade the contain packages:
 
<pre>
 
vzyum $CTID upgrade
 
</pre>
 
 
 
===Troubleshooting===
 
 
 
If you get this error:
 
 
 
<pre>
 
Error: 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 e8562897
 
Public key for libsepol-1.15.2-3.el5.i386.rpm is not installed
 
</pre>
 
 
 
You need to run the following before trying again:
 
 
 
 
<pre>
 
<pre>
vzctl exec $CTID rpm -e --justdb python-elementtree --nodeps
+
vzctl stop CTID
vzctl exec $CTID rpm --import http://mirrors.kernel.org/centos/RPM-GPG-KEY-CentOS-5
 
 
</pre>
 
</pre>
  
==Test your VE==
+
==Replace the new /dev/ with the old one==
Check you can enter your VE:
 
 
<pre>
 
<pre>
vzctl enter $CTID
+
cd /vz/private/CTID
 +
rm -rf dev
 +
tar -xvf dev.tar
 
</pre>
 
</pre>
  
All went OK? Exit the VE:
+
==Leave the container private dir (or it will not start)==
 
<pre>
 
<pre>
exit
+
cd
 
</pre>
 
</pre>
  
===Troubleshooting===
+
==Start the container==
 
 
 
<pre>
 
<pre>
Unable to open pty: No such file or directory
+
vzctl start CTID
 
</pre>
 
</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:
+
==Remove container IP==
 
<pre>
 
<pre>
mv /vz/private/$CTID/dev /vz/private/$CTID/dev.old
+
vzctl set --ipdel container_IP
tar -xvf $CTID.dev.tar -C /vz/private/$CTID
 
 
</pre>
 
</pre>
  
== Remove container IP ==
+
==Stop container==
 
<pre>
 
<pre>
vzctl set $CTID --ipdel all --save
+
vzctl stop CTID
 
</pre>
 
</pre>
  
 
==Create the template==
 
==Create the template==
 
<pre>
 
<pre>
cd /vz/private/$CTID
+
cd /vz/private/CTID
 
tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .
 
tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .
 
</pre>
 
</pre>

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: