Centos4 to Centos5 upgrade

Linux specific questions/information are gathered here. The main thrust of topics are applied to Centos/RedHat(RH)/Debian/Ubuntu/Gentoo distributives

Centos4 to Centos5 upgrade

Postby lik » Wed Feb 17, 2010 9:45 am

How to update Centos4 to Centos5 without complete OS reload/re-setup

1. First of all we need to ensure that we have the latest Centos4 system:
Code: Select all
yum -y update

2. Make sure you disable all other repos and only have CentOS Base and Updates repositories enabled. It will require a bit more manual steps to perform an update in case other (non-default ones) repos were in use.
Code: Select all
cd/etc/yum.repos.d/

/etc/yum.repos.d/CentOS-Base.repo :
Code: Select all
# CentOS-Base.repo                                     
#                                                       
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and 
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.                             
#                                                                           
# If the mirrorlist= does not work for you, as a fall back you can try the   
# remarked out baseurl= line instead.                                       
#                                                                           
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


3. Save complete list of installed RPM packages in the system (for further clean up):
Code: Select all
mkdir /root/migration45
cd /root/migration45/
rpm -qa > rpm4_list

4. Downloading and installing centos-release-5* and centos-release-notes-5* packages:
Code: Select all
wget "http://mirror.centos.org/centos/5.4/os/i386/CentOS/centos-release-5-4.el5.centos.1.i386.rpm"
wget "http://mirror.centos.org/centos/5.4/os/i386/CentOS/centos-release-notes-5.4-4.i386.rpm"
rpm -Uvh centos-*.rpm
rpm --import http://mirrors.kernel.org/centos/RPM-GPG-KEY-CentOS-5


5. Installing the latest Centos5 kernel (this step helps us to resolve multiple minor dependencies issues):
Code: Select all
wget "http://mirror.centos.org/centos/5.4/os/i386/CentOS/kernel-2.6.18-164.el5.i686.rpm"
rpm -ivh kernel-2.6.18-164.el5.i686.rpm --nodeps


6. Removing all Centos4 kernels from the system to avoid unresolved dependencies in future:
Code: Select all
rpm -e `rpm -qa | grep kernel | grep -v kernel-2.6.18-164.el5`

Some packages may have dependencies, so we remove those ones also:
Code: Select all
rpm -e pcmcia-cs-3.2.7-3.5


7. python-elementtree-1.2.6-5 (centos5) has the same release number as python-elementtree-1.2.6-5.el4.centos) (centos4)
"The only way I could make it work was to remove the old python-elementtree with --nodeps but save its files and copy them back in order to have a working yum"
Centos wiki*/forum* quote


Code: Select all
mkdir tmp_elementtree
rsync -a /usr/lib/python2.3/site-packages /root/migration45/tmp_elementtree/
rpm -e python-elementtree --nodeps
rsync -a /root/migration45/tmp_elementtree/site-packages /usr/lib/python2.3/


8. Clean and rebuild rpmdb for Centos5:
Code: Select all
rm -f /var/lib/rpm/__*
rpm --rebuilddb


9. Clean all yum cache
Code: Select all
yum clean all


10. Updating/installing Centos5 packages:
Code: Select all
yum update


11. Yum will give an error message after upgrade therefore we have to force install python-sqlite:
Code: Select all
wget "http://mirror.centos.org/centos/5.4/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm"
rpm -Uvh python-sqlite-1.1.7-1.2.1.i386.rpm --replacepkgs


12. Ensure that boot loader configuration is correct (GRUB, LILO, etc):
Code: Select all
cat /boot/grub/grub.conf


13. Reboot the server
Code: Select all
shutdown -r now


14. Remove old packages and check the system:
Code: Select all
yum update


Code: Select all
rm -rfv /usr/lib/python2.3/
cd /root/migration45
cat rpm4_list | grep -v -e centos-release -e kernel |xargs -I {} rpm -e {}


NOTE: Every mentioned above step requires strong understanding and brain activity! :)
lik
Founder
Founder
 
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am

Return to Linux specific

 


  • Related topics
    Replies
    Views
    Last post
cron