Wednesday, November 29, 2006

Upgrade RedHat 6.2 Make Easy

I am a faithful Redhat 6.2 user up now 2006. Yes I know this version is antiuence and has long been outdated. However it is the most stable Linux version ever created. The kernel is 2.2.19 fully patched. Over the years since 2002, I have been wanting to upgrade the kernel to 2.4, this TODO list wasn't get executed due to extremely tie schedule I have with other commitments.

A week ago, I intend to use my pendrive on a Linux box equipped with the antiuence OS, I was so confident that it will be mounted successfully because the OS contains the USB patch. The pendrive was detected as SCSI device but when I run "mount /dev/sda1 /mnt/pendrive", the computer hangged! Eeerrrrr... I spent the whole night trying to get it to work but to no avail. I was so frustrated, I told myself look; it is time to move forward with a newer kernel i.e. 2.6.

It is a blessing in disguise, though I have not been doing anything for the upgrade all theses years, the kernel development by the Internet community goes on. I feel that I am kind of lucky to skip the entire 2.4 tree and jump straight to 2.6. Suddenly I am like a head of many people aound the globe who are still using 2.4, hehe!

All the time I thought upgrading the kernel and the operating environment is a pain and difficult; not until I experience it. It is not that hard though. A little bit regret of not willing to spend the time in those early day when kernel 2.4 was emerged (almost the same time in year 2002/2003).

Well, story a side, now let get our hand dirty to learn the trick.


Preparation
In order to compile kernel 2.6 source, it is required that you upgrade the operating environment to glibc-2.2.x. and the gcc compiler must be version 3 and above, otherwise no go. I search through RedHat CDs, the closer RPMs I can used is from RedHat 8.0. Formally RedHat kept all CD files in http://ftp.redhat.com/, but it was later transfered to http://download.fedoralegacy.org/ in year 2005.

Get the glibc version 2.2 with the following RPMs:




Obtain gcc version 3 with the RPMs below:







Procedure



Start up the RedHat 6.2 Linux box. At the root prompt run wget to downloaded all the necessary RPM files into /usr/local/src. Once it is done change to the directory with cd command. Run this command:



rpm -Uvh --nodeps gcc* cpp* libstd* glib*



The command must in one line and all the RPM files must be pass in as parameter in one go, you are not suppose to break it into multiple rpm commands. The dependency issue will confuse you.



Beside glibc and gcc, you need to also upgrade some utilities:





  1. sed-4.0.5-1.src.rpm from Redhat-9 Sources to resolve error: Unknown option to 's'


  2. binutils-2.15.94.0.2.2-2.1.src.rpm from Fedora Core 4 Upgrades Sources to resolve error: Writing section .bss to huge (ie negative)


  3. Upgrade rpm packages rpm-4.0.4-7x.i386.rpm, rpm-build-4.0.4-7x.i386.rpm, rpm-devel-4.0.4-7x.i386.rpm, rpm-perl-4.0.4-7x.i386.rpm, and rpm-python-4.0.4-7x.i386.rpm from fedoralegacy/redhat/7.2/updates mirror site. Run "rpm -Uvh rpm-*" in one pass to upgrade it.


  4. module-init-tools-3.1-0.pre5.3.4.src.rpm from Updates for Redhat-EL 4AS Sources


Upon upgrading the operating environment, compiler, and the utility programs mentioned above you can begin to build the new kernel. Observe these steps:





  1. Download kernel-2.6.18.src.rpm from rpmfind.net


  2. rpm -i kernel-2.6.18.src.rpm # only interest in the sample "config" files


  3. cd /usr/src


  4. wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.gz # latest kernel at this point of writing


  5. tar xzf linux-2.6.18.tar.gz


  6. ln -s linux-2.6.18 linux


  7. cd linux/include


  8. ln -s asm asm-i386; ln -s asm-generic /usr/include


  9. cd ..


  10. cp /usr/src/redhat/SOURCES/kernel-2.6.18-i686.config .config # .config is with a leading dot


  11. make menuconfig # one you in blue screen, just exit and save


  12. make


  13. make install


If you want to use netfilter for NAT, you need to enable IPv4 connection tracking (Networking/Networking options/Network packet filtering framework/IP: Netfilter configuration/IPv4 connection tracking support) and you then should get the "Full NAT" configuration option.



There is a new module utility associated with kernel 2.6 called module-init-tools. Download module-init-tools-3.1-3.src.rpm from Fedora Core 4 Sources. Take the following step to compile and install:





  1. rpm -i module-init-tools-3.1-3.src.rpm


  2. cd ../SPECS


  3. vi module-init-tools.spec # Modify the following lines:


  4. # Line 15: delete "docbook-utils"


  5. # Line 28: right under %build add a line "ln -s /bin/true /bin/docbook2man" to fool module-init-tools-3.1/Makefile.in


  6. # Line 29 and 36: delete "-DCONFIG_NO_BACKWARDS_COMPAT=1"


  7. # Line 55: add a "i386-init-tools-" in front of lsmod -> "i386-init-tools-lsmod"


  8. # Line 57: replace with "install -m 755 insmod-static $RPM_BUILD_ROOT/sbin/i386-redhat-linux-insmod.static"


  9. # Line 76: at %post append a script to do "Makefile.in: make moveold" and create links to i386-redhat-linux-*


  10. # Optional: Appending "i386-redhat-linux-" is a common problem with some build files that think you're crosscompiling, and when you really are, this is in fact a feature :-/The workaround is to pass an extra argument to configure as follows :
    %configure --program-prefix=%{?_program_prefix:%{_program_prefix}


  11. rpm -bb module-init-tools.spec


  12. # You may now install module-init-tools


  13. rpm -i --force /usr/src/redhat/RPMS/i386/module-init-tools-3.1-3.i386.rpm


  14. I have copied module-init-tools.spec to development source/patch/modules-init-tools folder.


After installing the new kernel and rebooted, you will realize that modules are not loaded at all. In order to autoload kernel modules you need to modify /etc/rc.d/rc.sysinit to use kallsyms. At line 233 copy and paste ksyms line and replace it with "elif" and "kallsyms". Since kernel 2.6 uses modprobe.conf, you may run "generate-modprobe.conf /etc/modprobe.conf" or alternatively just copy modules.conf to modprobe.conf (it works for me.)



Done, that's it! No sweat isn't it.



Please note that you need a proper operating environment to compile new kernel. Once you have a new kernel binary you may install to another RedHat 6.2 machine. The machine need not have new glibc or the upgraded utility to run the kernel. The kernel is independant to the operatng environment.





Conclusion



Numerous try and error have been performed; much patience, endurance, and energy have been put in over sleepless nights. All the hard work has been digested and I have slimlined the proceduce for you. From time to time I will refine this article when needed. I hope this article will provide help and shed light to people who want to upgrade (NOT migrade) RedHat 6.2 to latest 2.6 kernel.






No comments: