Upgrade RHEL5 to RHEL6

By: | Comments: 19 Comments

Posted in categories: Computer Tips, Work related

Redhat always recommends to reinstall from scratch for a major version upgrade of its RHEL system.

However, if you have a highly customized system with plenty third party softwares and non-standard settings, even if you have a full record of all customer settings, it will still be a big job, days, and aftermath to have everything set back properly.  If it is a mission critical system, the price might be too high to pay.

Then if you just try to upgrade it using the “upgradeany” option available in the new OS installation, you are guaranteed to fail.  Is there a way to do this?

The answer is yes.  However, it is not straight forward.  Still a full day job.  But definitely it is do-able.  I did it successfully.

First of all, step zero, it is highly recommended that you dd your system hd to a spare, and tested it working.  This is the last resort in case anything went out of control and leave you a unusable system.  This is an a few tens of bucks work.  Do not omit it.

Step 1:Preparation

1.1)

$ rpm -qa –queryformat “%{NAME}\n” | sort > /root/all_old_packages

This will give you a list of all packages you have in the current system.  Save it somewhere, your jump drive, a CD-R, for future use.

1.2) uninstall selinux.  Skip this if you are not currently using selinux.

If you do not do so, you may have flawed/mixed policies in the upgraded version and may take you big to debug.

1.3) Edit /etc/inittab, to set default runlevel down from 5 to 3.

This will prevent the upgraded system to boot up to graphical interface, which might not work just after you upgraded the version.  We will leave X upgrading to later.

1.4) Edit /etc/fstab, to comment all network file systems imported from NFS or others.

This will prevent the upgraded system from hanging due to not working network settings.   We will reenable those after we are sure that the network is working.

1.5)

$ rm -rf /usr/share/doc/HTML/*/docs/common

The RHEL6 will use links instead of directories for those.  Without doing so, the upgradeany will fail.

1.6) (optional) copy the DVD image of your RHEL6 installation DVD to /, if you are not installing from NFS.

Step 2: Upgrade

2.0)It is not necessary to update your existing system to all newest packages.  This might increase the chances of adverse incidents.

2.1)Boot into the RHEL6 installation DVD with upgradeany option.  Then choose to upgrade existing system.

If you do not have a DVD, you may boot into the installation CD and use NFS to reach the DVD image that is mounted in another linux box.

Let it run.  If you are lucky it will run until the reboot stage.  If it hangs in the middle, it will means that it failed to place some file at somewhere.  Do not panic.  You may now try press Ctrl-Alt-F1 through F6 to find out the broken point, and use the shell in Ctrl-Alt-F2 to hand remove the files that blocks the installation.  Then try again this step.  Usually after a few tries, the upgradeany will be able to finish and allows you to reboot.

Do not reboot.  It won’t work.

2.2)Now press Ctrl-Alt-F2 to switch to the shell.

Mount the the installation DVD image or NFS volume to /mnt/source,

2.3)

$cd /mnt/source/packages

$rpm -Uvh kernel-2.6.32-71.el6.x86_64.rpm  –replacepkgs

2.4)

$rpm -qa –root /mnt/sysimage > /mnt/sysimage/root/all-new-packages

$cd /mnt/source/packages

$ls > /mnt/sysimage/root/all-available-packages

$cd /mnt/sysimage/root/

$ cat all-available-packages all-new-packages | sort > package-comparasion

Then you should look into the file package-comparasion and search for el5

2.5)For each el5 package that has a el5 version number that is higher than the el6 version number, do

$ rpm -ivh –force <package_file_name> –root /mnt/sysimage

$ rpm -e <the_respective_el5_package_name> –root /mnt/sysimage

For my system, I found the following:

dmidecode, python-dmidecode, device-mapper,  subversion, systemtap, device-mapper-event, device-mapper-event-libs, systemtap-runtime

are critical.  Others do not have to be done now.

2.6) For some reason RHEL6 switched eth0 and eth1 identification in my system.  You’d like to check about this.

2.7) Check that /etc/inittab and runlevel id:3

2.8) Change boot kernel from el5 to el6 in /mnt/sysimage/boot/grub/grub.conf

2.9) Reboot.  Remember to take out the installation DVD.

Step 3: Fix packages

3.0)If you still cannot boot, you will need to go back to step 2 and proceed until you have the shell by pressing Ctrl-Alt-F2.  Do not let it replace any package, and seek for more critical packages to replace in the way showed in step 2.5).

3.1)You will boot into a text interface.  Log in as root.  Fix network configuration if you cannot connect to internet.

3.2)

$ yum remove redhat-release-5Server redhat-lsb-4.0-x.x.x.el5.i386 redhat-release-notes-5Server-xx.x86_64 redhat-lsb-4.0-x.x.x.el5.x86_64

This will remove the EL5 signature from your system.

3.3) Register RHEL6 to your registration provider, either Redhat or your group-license agent.

3.4) replace EPEL repo to el6 version.  Also replace your other third party repos here.

3.5) for all packages you found in /root/package-comparasion that have a smaller el6 version number than el5, do

$ yum downgrade <package-name>

3.6)

$ package-cleanup –oldkernels

This will remove the old kernels

$ package-cleanup –dupes > dups
$ grep -v el6 dups > /root/dups.list
$ for pkg in `cat /root/dups.list` ; do yum remove ${pkg} ; done
answer y if OK

3.7)

$yum -y upgrade

This will upgrade your packages that was not available in the DVD to their most current version.

3.8) Mostly step 3.7) will fail for the first a few tries.  Do not worry.  You can figure which package hindered the above process, then use either method

$ rpm -ivh –force <package_file_name> ;rpm -e <the_respective_el5_package_name>

or

$ yum downgrade <package-name>

to fix them, until you can run through step 3.7).  You may have to run step 3.9) before step 3.7) can run through.

3.9)

$ package-cleanup –problems

and fix the problems found.  This may

3.10)

$ rpm -qa | grep el6 | sort > /root/non-el6-packages

You may want to check this list for the packages you believe to be useless to you upgraded system.

3.11)Now you can set back runlevel to 5 and enable commented items in /etc/fstab, and reboot.

Step 4: Finalization

4.1) Your system should be able to boot into graphical interface and function normally – mostly.  If not, go back to eliminate more non-el6 packages and try again.

4.2) reinstall selinux, if you like to use it, set it to permissive, and reboot.  It will take a good while to relabel all files in your system.

4.3) If you have any filesystem that was ext3, and you’d like to upgrade them to ext4, do it now:

$ umount /dev/your_dev
$ tune2fs -O extents,uninit_bg,dir_index /dev/your_dev
$ fsck -Cy /dev/your_dev
Edit /etc/fstab, replace ext3 to ext4
mount it

4.4)

$ rpm -qa –queryformat “%{NAME}\n” | sort > /root/all_current_packages

$ diff /root/all-current-packages /root/all-old-packages > /root/package-difference

You may use this file to debug

4.5) Leave the system run for days, and inspect selinux denials.  When you are confident,

$ setenforce 1

Step 5: Cheer and relax.  You have successfully upgraded you system.

19 Comments

Leave a Reply