R-fx Networks

Upgrade CentOS 4.8 to 5.x (32bit)

by on Oct.20, 2009, under HowTo

Traditionally, the dist upgrade path that many were familiar with from the RH8/9->Fedora or similarly Fedora dist upgrades, have applied more or less to RHEL/CentOS but with the release of 4.5 and early releases of 5.0 the actual dist upgrade path was messy or nearly impossible. The early versions of 5.0 (up to 5.2) had excessive dependency issues with versions later than 4.4 for straight dist upgrades that would often result in a box blowing up on you or forcing a messy downgrade attempt of 4.5+ to 4.4 to try get things to dist upgrade. With more recent release updates the gap has closed and now dist upgrades on are far more reasonable to complete with little in the way of problems.

If you are currently running a version of RHEL/CentOS earlier than 4.8 (cat /etc/redhat-release) then please do a proper ‘yum update’ and get yourself on 4.8. Although this is intended for CentOS it “should” (read: at own risk) work on RHEL systems as well, in the unfortunate situation that something does blow up please post a comment and I will try to assist.

The first thing we must do is make sure none of our core binaries, libraries or other content is set immutable as this will cause a package to fail on installation. If you are running an earlier version of LES or you use immutable bits on system paths (sbin/bin/share/include/libexec/etc) then you should run the following:

wget http://www.rfxn.com/downloads/disable.les.rpmpkg
sh disable.les.rpmpkg

Once that is done we should go ahead and have a quick run through of cleaning up yum cache, double check that any pending updates are installed and rebuild the rpmdb:

rpm --rebuilddb
yum clean all
yum update

If for some reason the rpm rebuild hangs for more than a few minutes then you may need to manually clear the rpmdb files:

rm -f /var/lib/rpm/__db.00*
rpm --rebuilddb

If you run into any minor dependency issues for packages that are not essential, such as syslinux and lftp then you can either exclude them or better yet remove them. If you are not sure what a package does, then you should query it for description details and make an educated choice (rpm -qi PACKAGE):

rpm -e lftp syslinux mkbootdisk

OR (but not recommended)

yum update --exclude=syslinux --exclude=lftp --exclude=mkboot

At this point you should be able to run a ‘yum update’ command with optional exclude and receive no errors (again, I recommend you remove conflicts items instead of using exclusions).

# yum update –exclude=nagios-plugins
Setting up Update Process
Setting up repositories
Reading repository metadata in from local files
Excluding Packages in global exclude list
Finished
No Packages marked for Update/Obsoletion

Now we are ready to get going, I have put together a small package that contains the needed packages for this upgrade in addition to a few that you might require to resolve dependency conflicts:

wget http://www.rfxn.com/downloads/CentOS-5up.tar.gz
tar xvfz CentOS-5up.tar.gz
cd CentOS-5up

We need to go ahead and setup the centos-release package as follows:

rpm -Uhv centos-release-*

If you see that CentOS-Base.repo was created as /etc/yum.repos.d/CentOS-Base.repo.rpmnew then go ahead and move it into the proper place:

mv /etc/yum.repos.d/CentOS-Base.repo.rpmnew /etc/yum.repos.d/CentOS-Base.repo

Now we are ready to go with kernel changes, this is an important part so pay attention. The key to successful upgrade is that you remove ALL OLD KERNELS as many packages will fail to install during the upgrade if they detect a release 4.x kernel due to minimum kernel version dependency checks. We will start with first installing the new kernel so it preserves grub templating:

rpm -ivh kernel-2.6.18-164.el5.i686.rpm kernel-devel-2.6.18-164.el5.i686.rpm --nodeps

NOTE: release 5.x has smp support integrated into the standard kernel, so no -smp version is required for mp systems

If you are running an older system the chances are you got allot of older kernel packages installed so make sure you get them all out of the way:

rpm -e $(rpm -qa | grep kernel | grep -v 2.6.18 | tr '\n' ' ')

You may end up with a few dependencies coming up such as lm_sensors and net-snmp if the list is fairly small and packages you do not recognize as critical (if unsure always query the package for info ‘rpm -qi PACKAGE’, remember you can reinstall them later):

# rpm -e $(rpm -qa | grep kernel | grep -v 2.6.18)
error: Failed dependencies:
kernel-utils is needed by (installed) lm_sensors-2.8.7-2.40.5.i386

The command the ended up being required on most of my servers to get the kernel packages and related dependencies came out to the following:

rpm -e $(rpm -qa | grep kernel | grep -v 2.6.18 | tr '\n' ' ') lm_sensors net-snmp net-snmp-devel net-snmp-utils

That said and done you should now only have 2 kernel packages installed which are the 2.6.18 release 5.x kernels, DO NOT under any circumstance continue if you still got 2.6.9 release 4.x kernels packages still installed, remove them!

# rpm -qa | grep -i kernel
kernel-2.6.18-164.el5
kernel-devel-2.6.18-164.el5

A cleanup of /etc/grub.conf may be required, though if all went as planned then the rpm command should have done this up for us but review it anyways for good measure. You should find that 2.6.18-164.el5 is the only kernel in the file, if it is not go ahead and clean it by removing all older entries for 2.6.9 kernels.

There is a known bug with python-elementtree package versions which cause yum/rpm to think the release 4.x version is newer than the 5.x version, to get around this without blowing up the entire python installation we need to remove the package from just the rpmdb as follows:

rpm -e --justdb python-elementtree --nodeps

We can now go ahead and use yum to start the upgrade process, this is a dry run and will take a few minutes to compile list of available packages and associated dependency checks. You should carry the exclude options, if any, that you used during the ‘yum update’ process as so to avoid unresolvable dependencies:

yum clean all
yum upgrade --exclude=nagios-plugins

You will end up with a small list of dependency errors, these should be resolved by again evaluating a packages need as a critical system component and either removing it with ‘rpm -e’ or excluding it with ‘–exclude’ (remember to query description with ‘rpm -qi PACKAGE’ if you are unsure what something does). In my case the packages that threw up red flags were stuff I had manually installed over time such as iftop and mrtg in addition to default installed samba, these can all safely be removed or excluded as you prefer (removal always safest to prevent dependency chain issues).

Error: Missing Dependency: libpcap.so.0.8.3 is needed by package iftop
Error: Missing Dependency: perl(Convert::ASN1) is needed by package samba
Error: Missing Dependency: libevent-1.1a.so.1 is needed bypackage nfs-utils
Error: Missing Dependency: perl-Socket6 is needed by package mrtg
Error: Missing Dependency: perl-IO-Socket-INET6 is needed by package mrtg


rpm -e iftop samba nfs-utils mrtg system-config-samba

At this point we should be ready to do a final dry run of with yum and see where we stand on dependencies, rerun the earlier ‘yum upgrade’ while making sure to carry over any exclude options you are using.

yum upgrade --exclude=nagios-plugins

You should now end up with a summary of actions that yum needs to perform, go ahead and kick it off… this will take a bit to complete so go grab some coffee/jolt/redbull and maybe a small snack cause it could be a long night if this blows up on you.

Transaction Summary
=============================================================================
Install 183 Package(s)
Update 327 Package(s)
Remove 0 Package(s)
Total download size: 299 M
Is this ok [y/N]:

Once yum has completed (hopefully without major errors) we need to fix a few things, the first is the rpmdb needs a rebuild due to version changes that will cause any rpm commands to fail:

# rpm -qa
rpmdb: Program version 4.3 doesn’t match environment version
error: db4 error(-30974) from dbenv->open: DB_VERSION_MISMATCH: Database environment version mismatch
error: cannot open Packages index using db3 – (-30974)
error: cannot open Packages database in /var/lib/rpm

This can be fixed by running the following to manually rebuild the rpmdb:

rm -f /var/lib/rpm/__db.00*
rpm --rebuilddb
yum clean all

The next issue on the list is python-elementtree and python-sqlite, one or both of these may have ended up in a broken state that will cause all yum commands to break, so we will go ahead and reinstall both of these for good measure:

rpm -e --justdb python-elementtree --nodeps
rpm -ivh python-elementtree-1.2.6-5.el5.i386.rpm
rpm -ivh python-sqlite-1.1.7-1.2.1.i386.rpm --nodeps --force

The yum command should now work, go ahead and run it with no options, if you do not get any errors you are all sorted.

Hopefully the install went well for you, the only thing left to do is go ahead and reboot the system; this is the last point at which you have to make backups (but we all maintain backups right?). For the sake of avoiding a heart attack if the system goes into an fsck, we will reboot with the -f option to skip fsck:

shutdown -rf now

That’s a wrap, I hope you found this HowTo useful, if you did run into any issues then go ahead and post them into the comments field and I will try to assist but when in doubt typically google is the fastest alternative.

:, ,

40 Comments for this entry

  • Juan Manuel

    I have a dependency issue with filesystem:
    Error: Missing Dependency: filesystem >= 2.3.7-1 is needed by package xorg-x11-filesystem
    Error: Missing Dependency: filesystem >= 2.3.7-1 is needed by package xorg-x11-server-utils
    Error: Missing Dependency: filesystem >= 2.3.6-1 is needed by package xorg-x11-utils

    I try to download and install filesystem 2.4 rpm from CentOS 5 but I get this error:
    file /usr/lib/X11 from install of filesystem-2.4.0-3.el5.centos conflicts with file from package filesystem-2.3.0-1

    I try excluding xorg-x11* and filesystem with no luck.

    Can anyone tell me how to fix this? Thanks in advance!

  • Lik

    Have also performed dist upgrade on a production server from Centos4 to Centos5. For sure, it`s far to simpler to migrate to the new server with the desired OS, but sometimes it`s not optimal solution.

    http://forum.likg.org.ua/linux-specific/centos4-to-centos5-upgrade-t255.html

  • Adam

    Awesome, thanks.

  • shelby

    Many thanks for this especially since Centos 4 was recently end-of-lifed!

  • Ted

    Great post, this worked wonderfully. I had to remove all of KDE, once that was done, this worked like a charm. So grateful!

    again, many thanks

  • kaveman

    Worked for me 100%

    One little thing before 1-st yum update I had to update glibc manualy from mounted CD (yum had some major dependence issues)

    rpm -U glibc-common-2.5-49.i386.rpm glibc-2.5-49.i386.rpm

    Then evrything worked fine
    Thx ;)

  • erwin amin

    I upgraded Scientific Linux 4.9 to Scientific Linux 5.7 arch i386, with a few modified.
    Thank you for sharing

  • Don

    Wow..Thanks! I just went from 4.9 to 5.7 with these excellent instructions. Can’t thank you enough. Cheers!

  • Bahram

    Thnakyou very much ryan, very good project, works perfectly ;)

    Congratulation man ;)

  • ATUL KHACHANE

    Are there any suggestions how to update centos from 5.7 to 6 version?

    Thank you.

  • ktp

    Edit: the solution is to use the command:
    yum upgrade –exclude=mesa-libGLw

  • ktp

    Hello,

    After yum upgrade, I got this error:
    –> Finished Dependency Resolution
    Error: Missing Dependency: libXm.so.4 is needed by package mesa-libGLw

    How I can fix it?
    Thank you.

  • ioannis

    Are there any suggestions how to update centos from 5.5 to 6 version?

  • Pete

    Thanks for a great post. This worked well for me with one exception.
    I use a VPS running Virtuozzo. After the upgrade, when I rebooted the server, the network service failed with the error “…Device lo does not seem to be present, delaying initialization…”
    “…Device venet0 does not seem to be present, delaying initialization…”

    A quick google search led me to the file
    /etc/vz/conf/CTID.conf
    Where the line
    TECHNOLOGIES=”x86 nptl”
    had to be changed to
    TECHNOLOGIES=”x86 nptl sysfs”

    I believe if you do this prior to rebooting, it the network should start successfully.

  • chriss007

    Thank you for this tutorial, I used it to upgrade from centos 4.8 to centos 5.6 on my x86_64 HP server and it worked well. all you need to do is change all packages with 386 in the above tutorial with x86_64 corresponding one.

  • Ryan M.

    I just performed perhaps in excess of my 100th CentOS 4 to 5 upgrade. The upgrade I performed today was on CentOS 4.9 to CentOS 5.5, following this howto to the letter resulted in a successful upgrade process without any issues.

    So I stress to those who have taken it upon themselves to make substitutions and modifications to the process then run into problems; to simply follow to the letter this howto and you will find it is a hassle free process.

  • Chad

    Since this is from 2009, I did not run

    rpm -ivh kernel-2.6.18-164.el5.i686.rpm kernel-devel-2.6.18-164.el5.i686.rpm –nodeps

    I ran yum install kernel instead

    I got these errors:

    –> Processing Dependency: hotplug >= 2001_04_24-9 for package: pcmcia-cs
    –> Restarting Dependency Resolution with new changes.
    –> Populating transaction set with selected packages. Please wait.
    –> Running transaction check
    Error: Missing Dependency: hotplug >= 2001_04_24-9 is needed by package pcmcia-cs
    Error: Missing Dependency: libcrypto.so.6 is needed by package openldap
    Error: Missing Dependency: libssl.so.6 is needed by package openldap
    Error: Missing Dependency: libcrypto.so.6 is needed by package openssh-clients
    Error: Missing Dependency: libssl.so.6 is needed by package wget
    Error: Missing Dependency: libssl.so.6 is needed by package neon
    Error: Missing Dependency: libcrypto.so.6 is needed by package neon
    Error: Missing Dependency: libcrypto.so.6 is needed by package curl
    Error: Missing Dependency: libssl.so.6 is needed by package curl
    Error: Missing Dependency: libcrypto.so.6 is needed by package cyrus-sasl
    Error: Missing Dependency: openssl >= 0.9.8e is needed by package openssh
    Error: Missing Dependency: libcrypto.so.6 is needed by package libc-client
    Error: Missing Dependency: libssl.so.6 is needed by package libc-client
    Error: Missing Dependency: libcrypto.so.6 is needed by package openssh
    Error: Missing Dependency: libcrypto.so.6 is needed by package openssh-server
    Error: Missing Dependency: libcrypto.so.6 is needed by package wget
    Error: Missing Dependency: libssl.so.6 is needed by package gnupg
    Error: Missing Dependency: libssl.so.6 is needed by package python
    Error: Missing Dependency: python-abi = 2.3 is needed by package python-elementtree
    Error: Missing Dependency: libcrypto.so.6 is needed by package cyrus-sasl-md5
    Error: Missing Dependency: libcrypto.so.6 is needed by package gnupg
    Error: Missing Dependency: libcrypto.so.6 is needed by package python
    Error: Missing Dependency: libcrypto.so.6 is needed by package postgresql-libs
    Error: Missing Dependency: perl-String-CRC32 is needed by package lftp
    Error: Missing Dependency: perl(String::CRC32) is needed by package lftp
    Error: Missing Dependency: libssl.so.6 is needed by package postgresql-libs
    Error: Missing Dependency: libcrypto.so.6 is needed by package fipscheck
    Error: Missing Dependency: libcrypto.so.6 is needed by package pam_ccreds
    Error: Unable to satisfy dependencies
    Error: Package python needs libssl.so.6, this is not available.
    Error: Package neon needs libssl.so.6, this is not available.
    Error: Package openldap needs libcrypto.so.6, this is not available.
    Error: Package gnupg needs libssl.so.6, this is not available.
    Error: Package libc-client needs libcrypto.so.6, this is not available.
    Error: Package openldap needs libssl.so.6, this is not available.
    Error: Package python-elementtree needs python-abi = 2.3, this is not available.
    Error: Package neon needs libcrypto.so.6, this is not available.
    Error: Package initscripts needs kernel < 2.6.12, this is not available.
    Error: Package curl needs libcrypto.so.6, this is not available.
    Error: Package wget needs libssl.so.6, this is not available.
    Error: Package cyrus-sasl-md5 needs libcrypto.so.6, this is not available.
    Error: Package postgresql-libs needs libcrypto.so.6, this is not available.
    Error: Package libc-client needs libssl.so.6, this is not available.
    Error: Package openssh needs libcrypto.so.6, this is not available.
    Error: Package lftp needs perl(String::CRC32), this is not available.
    Error: Package postgresql-libs needs libssl.so.6, this is not available.
    Error: Package curl needs libssl.so.6, this is not available.
    Error: Package fipscheck needs libcrypto.so.6, this is not available.
    Error: Package autofs needs kernel < 2.6.17, this is not available.
    Error: Package lksctp-tools needs kernel = 0.9.8e, this is not available.
    Error: Package gnupg needs libcrypto.so.6, this is not available.
    Error: Package lftp needs perl-String-CRC32, this is not available.
    Error: Package wget needs libcrypto.so.6, this is not available.
    Error: Package python needs libcrypto.so.6, this is not available.
    Error: Package openssh-clients needs libcrypto.so.6, this is not available.
    Error: Package pcmcia-cs needs hotplug >= 2001_04_24-9, this is not available.

    • Ryan M.

      If you strictly follow the howto including using the kernel in the included packages, it will work without issue, the post-run at the end of the howto of yum update will take care of the dated kernel for you — you need the kernel to resolve dependencies moving up from CentOS 4 to CentOS 5 kernels (2.6.9 to 2.6.18 iirc), and using a kernel much newer than the one included in this package will cause allot of issues as shown above.

  • Chad

    I ran yum update and got this:

    –> Finished Dependency Resolution
    Error: Missing Dependency: rtld(GNU_HASH) is needed by package ash
    Error: Missing Dependency: rtld(GNU_HASH) is needed by package lha
    Error: Missing Dependency: rtld(GNU_HASH) is needed by package swig
    Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package swig
    Error: Missing Dependency: libswigpy.so.0 is needed by package subversion
    Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package ash

  • Rui Lopes

    I’m getting a 2 WARNINGs after the step:
    rpm -ivh kernel-2.6.18-164.el5.i686.rpm kernel-devel-2.6.18-164.el5.i686.rpm –nodeps

    warning: kernel-2.6.18-164.el5.i686.rpm: V3 DSA signature: NOKEY, key ID e8562897

    WARNING: No module aarich found for kernel 2.6.18-164.el5, continuing anyway

    What can I do?

    I have a IBM x306 with RAID1 – ServeRAID-7E…
    I only have the aarich for kernel 2.6.9-42.0.2.ELsmp

    Can I continue with the migration?????

    Thanks,
    Rui Lopes

  • Arrie

    hi ..

    if i want to update from 4.8 to centos 5.5 for i386 is there same step and files that i have to download ?

    thank you

  • Scott Miller

    Many thanks to you for this easy process. I successfully upgraded my Centos 4.8 server to 5.5 yesterday afternoon.

  • Ryan M.

    I can find no issue with the CentOS-5up.tar.gz URL, it works fine for me and some others I had test the URL, please try again.


    Andrew Mangold:

    Was following your steps in Upgrading CentOS 4.8 to 5.x when I got a 404 on ‘wget http://www.rfxn.com/downloads/CentOS-5up.tar.gz‘ Thought I would inquire as to the status of this file.

  • Andrew Mangold

    Was following your steps in Upgrading CentOS 4.8 to 5.x when I got a 404 on ‘wget http://www.rfxn.com/downloads/CentOS-5up.tar.gz‘ Thought I would inquire as to the status of this file.

  • Ryan M.

    Yes, this works without issue on cpanel servers, on occasion you may need to recompile apache after upgrade.


    zero:

    Has someone tried this on a cpanel server?

  • zero

    Has someone tried this on a cpanel server?

  • SuperNoob

    Bravo!!! You have taken a fearful task and made it come out smooth. WELL DONE TUTORIAL!

  • Ryan M.

    I changed the article name to reflect this


    Ørjan:

    You should mention that the package you put togheter is for 32 bit only..

  • Ørjan

    You should mention that the package you put togheter is for 32 bit only..

  • Amr

    Always amazed by your work Ryan :)

    It went smoothly, without any dependency errors from 4.8 to 5.5 .. Thanks a lot!

  • Ryan M.

    This works perfectly fine still even going to CentOS 5.5. Of course the kernel that this installs is from 5.3 but it still has no issues as such, as once you get to the end of the howto, that will in turn get replaced with the latest 5.5 kernel.


    Tony Kammerer:

    Hey Ryan, I ran across the following copy of your howto:

    http://planet.admon.org/howto/update-centos-4-to-centos-5-remotely/

    I know your article was published first but cannot verify since your articles have no publish dates (which drives me nuts).

    I haven’t yet tried this but have a few candidates for it so may soon.

  • Tony Kammerer

    Nevermind about publish dates, I see it now :)

    [QUOTE]
    This entry was posted by Ryan M. on October 20, 2009 at 3:10 am, and is filed under HowTo
    [/QUOTE]

  • Tony Kammerer

    Hey Ryan, I ran across the following copy of your howto:

    http://planet.admon.org/howto/update-centos-4-to-centos-5-remotely/

    I know your article was published first but cannot verify since your articles have no publish dates (which drives me nuts).

    I haven’t yet tried this but have a few candidates for it so may soon.

  • Bruce

    many many thanks, this project with a little tweaking made it possible for to install centos 5.4 and BlueOnyx on to my Cobalt RaQ550
    I intend to publish my method and will use some of this post and I will give credit to you
    once again many many thanks

  • Ricardo J. Barberis

    Hi Ryan,

    You’re right, I forgot udev and similar can/will cause issues and prevent booting.

    Regards

  • Ryan M.

    Ricardo,
    Rebooting the system to the new kernel is done last as it is a major release change from CentOS 4.x’s 2.6.9 kernel tree to 5.x’s 2.6.18 kernel tree. Some software such as udev may not operate properly on the new kernel till all associated packages are updated to 5.x versions , this can leave the server in an unusable state if rebooting before that point or lock it up on boot during the udev initialization process.

  • Ricardo J. Barberis

    One more thing: shouldn’t you reboot into the new 2.6.18 kernel before removing the 2.6.9 versions?

    I know it’s not necessary, but removing the currently running kernel gives me the creep :)

  • Ricardo J. Barberis

    Hi, just a small thing, I think rpm -q should be rpm -qi as you intend to view the info of the package and not only its name. At least on 5.x it works that way, I haven’t tried 4.x.

    Also, users might want to reinstall some of the packages uninstalled during the update process, so they should take note of what they remove.

    Regards,

  • george

    many many thanks, this project with a little tweaking made it possible for to install centos 5.4 and BlueOnyx on to my Cobalt RaQ550
    I intend to publish my method and will use some of this post and I will give credit to you
    once again many many thanks

7 Trackbacks / Pingbacks for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Site Links

A few links to navigate our site quicker...