GIDForums  

Go Back   GIDForums > Computer Forums > Computer Software Forum - Linux
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-Feb-2004, 19:59
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light

Linux Kernel Upgrade Mini Howto


Linux Kernel Upgrade


PLEASE NOTE THAT UPGRADING YOUR KERNEL CAN DISABLE YOUR CURRENT STABLE LINUX INSTALLATION IF NOT DONE PROPERLY. PLEASE READ THIS ENTIRE DOCUMENT BEFORE PROCEEDING. ALSO, YOU DO THIS AT YOUR OWN RISK. I TAKE ABSOLUTELY NO RESPONSIBILITY FOR ANY DAMAGES OR PROBLEMS THAT THESE INSTRUCTIONS MAY CAUSE

Introduction
This is meant to be a beginner level document on how to upgrade the kernel in a linux operating system. The kernel is the backbone of the Gnu/Linux system and is being worked on continuously. It basically does the background tasks that most people are not aware of. Upgrading your kernel is not paramount to upgrading your entire distribution. It is not going to add any eye-candy or new programs.

Why should you upgrade
Updating a kernel takes a good amount of time. You don't get any new utilities or programs and most of the time, the ordinary user will never notice the difference. So why should you upgrade your kernel? I have compiled the following list of why you should upgrade your kernel.
  • Drivers - If you have newer hardware or devices, chances are pretty good that there is updated support for them in the newer kernels. This link shows the changelog from kernel 2.6.1 to 2.6.2. This is not light reading, however, it gives every change made and also where the change came from. Not to far from the top is this entry that explains a driver update:
    Quote:
    Originally Posted by Changelog-2.6.2
    <greg@kroah.com>
    USB: add legotower driver to main usb makefile
  • Performance - Alot of times there is some general code clean up and algorithm fixes that will increase the performance of various parts of the kernel.
  • Features - Linux lags behind Windows for support of the newer hardware features. All of the PC hardware is created around the Windows API and therefore the Linux maintaners have to write alot of the features from scratch. Currently, the APCI features are being heavily worked on and improved.
  • Bug fixes - As long as linux is being updated there is always going to be bug fixes. By scanning through the change log above, you can see numerous entries for bug fixes.
  • Fun - Seriously. Have you ever taken a road-trip? Sometimes getting there is as much fun as the destination. Well, in this sense Linux is the ultimate road-trip. It is not terribly difficult to install and customize a new kernel and it is good background for how an operating system works. Besides that, don't you want to fully utilize your processing power?

Why shouldn't you upgrade
There are probably as many reasons not to upgrade as there are to upgrade. I have listed several below.
  • Server Installation - Yes, you do want to upgrade your servers, but not at every change of the kernel. Generally servers are basic machines that don't need all the upgrades and improvements of each and every kernel upgrade. Also, when upgrading a server it is a good idea to use a kernel that has been in service for a while (see next item).
  • Production Installations - Any computer that is used for important data or critical applications should not be updated to the most current kernel. I can think of at least one time where a production kernel was released that had the potential to corrupt your entire file system. Once caught, this was quickly updated, but there were several very unhappy people. Upgrading to the newest kernel should never be done on a production machine.
  • Mass Desktop Installations - Installing the kernel can be fun and informative, but not for many installations. The installation process is lengthy and to be done correctly, the kernel compilation should be optimized for each workstation. Once again, there are reasons that you may want to upgrade your kernel, but not at each kernel step.

Downloading/Expanding the kernel source
The rest of this document, does not specifically indicate when you should do things as root or not. Keep in mind that downloading,configuring and building the kernel can all be done as a user. However, installation has to be done as root. The kernel source is located at the appropriately named www.kernel.org. This is a very simple and straightforward site. The first entry is the latest current stable kernel. As of the writing of this document, the latest stable kernel is 2.6.2. This is an example line of what you should see.
Code:
The latest stable version of the Linux kernel is: 2.6.2 2004-02-04 04:02 UTC F V VI C Changelog
The first link, under the tag of 2.6.2 is to download the patch from 2.6.1 to 2.6.2. If you keep current with the kernel, this is the one that you want to download. There are a lot of reasons to download the patch, the biggest being that it is a much smaller file. However, if you are like me (a bit behind), you will need the full version which is linked to the "F" symbol. The rest of this document covers a full install. Save this file to your hard drive. This is a rather large file (33Megs) and may take a little while to download.

From this point forward, I have to make several assumptions about file locations and your particular distribution. This document follows a typical slackware installation which is a fairly standard installation. Please contact me with any variations.
  1. Copy the source tar ball to the /usr/src directory. This is where the source for your old kernel should be installed.
  2. Extract the files, using tar jxvf linux-2.6.2.tar.bz2, assuming bz2 compression. This is the default compression. Adjust for gz2 by substiting a 'z' for the 'j' and changing the filename.
  3. Copy the config file of your previous kernel into the new directory by using cp /usr/src/linux/.config /usr/src/linux-2.6.2/. This will base the configuration of your new kernel on your old kernel.

Configuring your new kernel
This is the most critical part. As long as you can base the new kernel install on the old configuration this is not too bad. Follow these steps to configure your kernel.
  1. Change to the source directory for your new kernel using cd /usr/src/linux-2.6.2.
  2. Set the new kernel configuration based upon your existing kernel by typing make oldconfig. This will run a console based program that will ask questions only for the new stuff that is included in the kernel. This will look something like:
    Code:
    ACPI Support (ACPI) [Y/n/?] (NEW) y AC Adapter (ACPI_AC) [M/n/y/?] (NEW) m Battery (ACPI_BATTERY) [M/n/y/?] (NEW) Button (ACPI_BUTTON) [M/n/y/?] (NEW) Fan (ACPI_FAN) [M/n/y/?] (NEW) Processor (ACPI_PROCESSOR) [M/n/y/?] (NEW) Thermal Zone (ACPI_THERMAL) [M/n/?] (NEW) ASUS/Medion Laptop Extras (ACPI_ASUS) [M/n/y/?] (NEW)
    You can respond with "<y>yes","<n>no", or "<m>module." Also by hitting the question mark you can find out more information about the option. The default option for each question is in capitol letters. To accept the default, just hit enter. In most cases you will want to accept the default option unless you absolutely are confident in what you are doing. Also, note that some options will be listed as experimental. Use thes at your own risk.
  3. Please note that the number of new items may be quite large. In my case, I went from a 2.4.21 kernel to a 2.6.2 kernel and there was probably at least 100 new items that I had to respond to.
  4. Most people may want to skip this step. To look at the full configuration for the kernel, use make xconfig. You must be running XFree86 in order to do this. For those new to the 2.6 kernel version, xconfig has been greatly improved over the somewhat archaic 2.4 format. This is the power of the linux kernel. You can make a kernel that is specific for your computer. I usually try to streamline my kernel for quicker booting and less overhead. Your kernel will compile without this step, so if you are uncomfortable here, just continue.

Compiling the kernel
Okay, the kernel should be configured and now comes the processor overload time. Follow this list to compile your kernel
  1. To compile the main part of the kernel issue this command: make bzImage. This will take a little while, after all you are compiling an O/S. Please note, that doing it this way will NOT overwrite your current kernel which is a good thing. It is much better to test a kernel before actually using it. The last line should look something like:
    Code:
    Kernel: arch/i386/boot/bzImage is ready
    If you get anything different, something is broken. The usual problems have to do with older versions of gcc. Note down where the bzImage file is located as we will need to "install" it in a minute.
  2. To compile the modules, issue this command: make modules. Once again, this will not overwrite anything and will take a few minutes to compile.
  3. Now it is time to install the modules. This will not overwrite anything, unless you are testing different configurations of the same kernel. If you are are and don't want to overwrite your modules, make a backup copy of the module directory, by typing something like:
    Code:
    cp /lib/modules/2.6.2 /lib/modules/2.6.2.backup -R
    Once you are sure that you want to proceed with your module installation, type in make modules_install. This should happen fairly quickly.

Installing the kernel
Okay, the kernel is built and now we want to test it out. The following assumes that you are using lilo as a boot loader. If not, you will need to modify this for the appropriate boot loader.
  1. First of all, find out where your current kernel resides. Common places are /vmlinuz or /boot/vmlinuz. Do NOT overwrite this file (yet). Instead make a new file name or location for this kernel. Also, the name of this file has to be 8 or less charecters with no extension. For this example, I would enter the following command:
    Code:
    cp /usr/src/linux-2.6.2/arch/i386/boot/bzImage /boot/vmlinuz6
  2. This step is based upon using the lilo boot loader. If you use a different loader, you will need to modify these steps. Now, we need to change the /etc/lilo.conf file. This is the configuration file for lilo and is fairly straight forward. In this file you should find an entry similar to this:
    Code:
    # Linux bootable partition config begins image = /vmlinuz root = /dev/hda5 label = Linux read-only
    This loads the current kernel. This file should be modified to add an entry for the new kernel so that it looks like this (comments added by me and are not necessary).
    Code:
    # Linux bootable partition config begins image = /vmlinuz root = /dev/hda5 label = Linux read-only image = /boot/vmlinuz6 #The location of the new kernel root = /dev/hda5 #This should be the same for all of your linux kernels label = Linux2.6.2 #The lable that shows up in the boot menu (keep it short & no spaces) read-only #This is very necessary.
  3. Now run the command lilo. If everything went well, it will print out a list of the boot menu options with your new boot option included. It should look something like:
    Code:
    Added WinXP * Added Linux Added Linux2.6.2 <--Here is the new one! Added Linux-OLD Added L2.4.20-old
  4. Keep in mind that any special drivers that you may have compiled for you old kernel will need to be recompiled for your new kernel. For example, on my configuration, I had to re-compile a special driver for the NVidia graphics card.
  5. If you are upgrading from a 2.4.* kernel to a 2.6.* kernel, you must follow the directions given below in Crossing the Threshold

Housekeeping
Once you have installed your new kernel and you are convinced that it works, you may want to do a little house-keeping. I would only do this once you are comfortable with your new kernel.
  1. Update your lilo to put the new kernel as the first kernel. It is probably a good idea to always keep at least one backup kernel.
  2. Link /usr/src/linux to your new kernel by using
    Code:
    rm /usr/src/linux ln -s /usr/src/linux-2.6.2 /usr/src/linux
  3. Delete any kernel source trees that you are not using, keeping in mind point #1 above. Also, I try to remove any tarballs after I am sure that things are working properly.


Crossing the threshold (Going from 2.4.x to 2.6.x)
The following items are only necessary if you are upgrading from a kernel version of 2.4.x to version 2.6.x.
  1. Version 2.6.x uses different module loader utilities. Modules will not load in 2.6 unless you upgrade this.
  2. Download the new module utilities from here. As of the writing of this document, the latest stable version is 0.9.14. Note do not use any version with the words pre in it as that is an alpha(unstable) version.
  3. Copy this to your working source folder and install using:
    Code:
    cd /usr/src tar jxvf module-init-tools-0.9.14.tar.bz2 cd module-init-tools-0.9.14 ./configure --prefix=/ make moveold make make install
    It is VERY important to do the make moveold as this will rename the other module utilities with a .old extension. This way your old kernel will still boot.
  4. Upgrade your old module configuration file using:
    Code:
    ./generate-modprobe.conf /etc/modprobe.conf
    Keep in mind that the location of the module configuration file has changed from module.conf to modprobe.conf.
  5. Run depmod for your new kernel, replacing the 2.6.2 with whatever version you have compiled
    Code:
    depmod 2.6.2

Additional notes
  • Users of nvidia drivers, will need to recompile the driver each time that you use a different kernel. That means that if I boot to a 2.4.x version after using my 2.6.x version, I will need to recompile the nvidia drivers. This isn't hard to do, but can get annoying. Also, everytime you recompile your kernel, you will need to remake these drivers
  • I found myself recompiling the kernel *several* times to get things working right. More than once, I forgot to run lilo. Just copying the new kernel image to the proper location is not enough.
  • My biggest heartache came from trying to get the alsa sound drivers set up. I had one small glitch in them that I could not figure out. I resorted back to the OSS drivers and don't have a problem.
  • I had a small problem with my hotplug devices, namely my wireless network card. The card services were starting prior to the modules for my pcmcia device being loaded. I just changed the script to start the card services later in the boot sequence.

That's it! Simple, huh. Is the transition from the 2.4 kernel to the 2.6 kernel worth it? Definitely if you don't mind taking a little time to get it working. It is especially worth it if you do any video/audio editting or viewing. The preemption option in the kernel adds a vast improvement. If you run a server or a critical production machine and nothing is wrong with it, I wouldn't rush to do this.

As always, feedback is not only welcome, but encouraged.
  #2  
Old 16-Feb-2004, 20:09
Div's Avatar
Div Div is offline
Moderator
 
Join Date: May 2002
Posts: 996
Div has a spectacular aura aboutDiv has a spectacular aura about
Good stuff...I'll bookmark this for future reference.
__________________
Web Hosting Tips | Career Advice
  #3  
Old 18-Feb-2004, 09:55
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Quote:
Originally Posted by dsmith
My biggest heartache came from trying to get the alsa sound drivers set up. I had one small glitch in them that I could not figure out. I resorted back to the OSS drivers and don't have a problem.

UPDATE
Okay, I finally got alsa to work and it actually wasn't too bad. I installed the newest available drivers from www.alsa-project.org along with the associated lib and util packages. The thing that finally got it going was running ./snddevice under the driver source package. This sets up all of the necessary alsa /dev entries. If anyone is interested in using the alsa drivers and struggling with it, let me know, because I *may* be able to help.

The alsa drivers are so much more robust than the OSS drivers. The pain to set them up is worth it in my estimation.
  #4  
Old 05-Apr-2004, 23:10
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Linux Kernel Patch Mini-Howto


PLEASE NOTE THAT UPGRADING YOUR KERNEL CAN DISABLE YOUR CURRENT LINUX CONFIGURATION IF NOT DONE PROPERLY. PLEASE READ THIS ENTIRE DOCUMENT BEFORE PROCEEDING. ALSO, YOU DO THIS AT YOUR OWN RISK. I TAKE ABSOLUTELY NO RESPONSIBILITY FOR ANY DAMAGES OR PROBLEMS THAT THESE INSTRUCTIONS MAY CAUSE

Introduction
This document is a continuation of the kernel upgrade document. However, this part will cover updating your kernel with patches instead of the whole thing. I have been meaning to keep up with the patches for the kernel, so that I will be up to date with all of the changes and only have to apply one patch. However, the patches have been coming so fast that I am already three behind. This will cover the upgrade from 2.6.2 to the just barely released 2.6.5.


Downloading the patches
The rest of this document, does not specifically indicate when you should do things as root or not. Keep in mind that downloading,configuring and building the kernel can all be done as a user. However, installation has to be done as root.

First of all navigate to the linux kernel source site. From here you can download the most current patch. However, if you are like me, you may need several patches to get up to speed. If that is the case, click on the link to navigate to the ftp download site. From there go into the linux/kernel directory and select your prefered branch (v2.6 in my case). Download the necessary patch files. These start with patch as opposed to linux. They are also about 5% the size of the full kernel. In my case, I needed to download patch-2.6.3, patch-2.6.4 and patch 2.6.5.

Applying Kernel patches
If I haven't already mentioned this somewhere, it is worth mentioning here. The site http://www.tldp.org is invaluable to me. If you really want to work linux and get to know it, bookmark that site somewhere. The HOWTO's in particular are a life safer.

Okay, on to patching the kernel.
  • The first thing to do is copy the patches into the appropriate folder. The "appropriate folder" is the parent folder for the linux source. This is commonly /usr/src. For this example it is /usr/src/linux-2.6.2.
  • Now, we need to extract the patch files. This is done with the bunzip2 command.
    Code:
    bunzip2 patch-2.6.3.bz2 bunzip2 patch-2.6.4.bz2 bunzip2 patch-2.6.5.bz2
    NOTE: Substitute gunzip and .gz respectively for bunzip2 and .bz if you downloaded the gzipped files.
  • You should now have the extracted files under the /usr/src directory. Verify by listing the files. Now the patches need to be applied in order inside the kernel source directory that is to be updated. Substitute the appropriate commands for your installation.
    Code:
    cd linux-2.6.2 patch -p1 <../patch-2.6.3 patch -p1 <../patch-2.6.4 patch -p1 <../patch-2.6.5
  • One thing that I like to do, is change the name of the kernel source directory so that I know what version of the kernel is under that source tree. In my case I would issue the command:
    Code:
    mv /usr/src/linux-2.6.2 /usr/src/linux-2.6.5


Configuring the kernel
This is where the patching of the kernel is much much easier than the full install. You can use your existing configuration file and be prompted only on the stuff that is new from this configuration file. This is done using the make oldconfig command.
Code:
cd /usr/src/linux-2.6.5 make oldconfig
This is a console program that will prompt you only for features that are brand new in the patches. Unless you are specifically looking for something that is new, you can use the default on most of these (N).
If you want to reconfigure your kernel further, use make xconfig after you use the make oldconfig command.


Compiling the kernel
This is basically identical to the full kernel install instructions that I gave above.
  1. To compile the main part of the kernel issue this command: make bzImage. This will take a little while, after all you are compiling an O/S. Please note, that doing it this way will NOT overwrite your current kernel which is a good thing. It is much better to test a kernel before actually using it. The last line should look something like:
    Code:
    Kernel: arch/i386/boot/bzImage is ready
    If you get anything different, something is broken. The usual problems have to do with older versions of gcc. Note down where the bzImage file is located as we will need to "install" it in a minute.
  2. To compile the modules, issue this command: make modules. Once again, this will not overwrite anything and will take a few minutes to compile.
  3. Now it is time to install the modules. This will not overwrite anything, unless you are testing different configurations of the same kernel. If you are are and don't want to overwrite your modules, make a backup copy of the module directory, by typing something like:
    Code:
    cp /lib/modules/2.6.2 /lib/modules/2.6.2.backup
    Once you are sure that you want to proceed with your module installation, type in make modules_install. This should happen fairly quickly.

Installing the kernel
Once again, these instructions are basically copied from the full kernel install post. It is still important to test the new kernel before you delete the other one. The following assumes that you are using lilo as a boot loader. If not, you will need to modify this for the appropriate boot loader.
  1. First of all, find out where your current kernel resides. Common places are /vmlinuz or /boot/vmlinuz. Do NOT overwrite this file (yet). Instead make a new file name or location for this kernel. Also, the name of this file has to be 8 or less charecters with no extension. For this example, I would enter the following command:
    Code:
    cp /usr/src/linux-2.6.5/arch/i386/boot/bzImage /boot/vmlin65
  2. Now, we need to change the /etc/lilo.conf file. This is the configuration file for lilo and is fairly straight forward. In this file you should find an entry similar to this:
    Code:
    # Linux bootable partition config begins image = /vmlinuz root = /dev/hda5 label = Linux read-only
    This loads the current kernel. This file should be modified to add an entry for the new kernel so that it looks like this (comments added by me and are not necessary).
    Code:
    # Linux bootable partition config begins image = /vmlinuz root = /dev/hda5 label = Linux read-only image = /boot/vmlin65 #The location of the new kernel root = /dev/hda5 #This should be the same for all of your linux kernels label = Linux2.6.5 #The lable that shows up in the boot menu (keep it short & no spaces) read-only #This is very necessary.
  3. Now run the command lilo. If everything went well, it will print out a list of the boot menu options with your new boot option included. It should look something like:
    Code:
    Added WinXP * Added Linux2.6.5 <--Here is the new one! Added Linux2.6.2
  4. Keep in mind that any special drivers that you may have compiled for you old kernel will need to be recompiled for your new kernel. For example, on my configuration, I had to re-compile a special driver for the broadcom ethernet card as well as the NVidia4 graphics card.

Housekeeping
Once you have installed your new kernel and you are convinced that it works, you may want to do a little house-keeping. I would only do this once you are comfortable with your new kernel.
  1. Update your lilo to put the new kernel as the first kernel. It is probably a good idea to always keep at least one backup kernel.
  2. Link /usr/src/linux to your new kernel by using
    Code:
    rm /usr/src/linux ln -s /usr/src/linux-2.6.5 /usr/src/linux
  3. Delete any kernel source trees that you are not using, keeping in mind point #1 above. Also, I try to remove any tarballs after I am sure that things are working properly.
  4. Also, all of the modules are installed under the /lib/modules/x.y.z, where the x.y.z represents your kernel. This is easily deleted by using:
    Code:
    rm /lib/modules/2.6.5 -R


Additional notes
  • Users of nvidia drivers, will need to recompile the driver each time that you use a different kernel. That means that if I boot to a 2.4.x version after using my 2.6.x version, I will need to recompile the nvidia drivers. This isn't hard to do, but can get annoying. Also, everytime you recompile your kernel, you will need to remake these drivers. I found the following switches very useful.
    Code:
    nvidia-installer -n -f -k 2.6.5
    2.6.5 refers to the version of the kernel that you want to install for. This way, you can compile the nvidia module for the kernel that you just installed while running in a different kernel.
  • I found myself recompiling the kernel *several* times to get things working right. More than once, I forgot to run lilo. Just copying the new kernel image to the proper location is not enough.
  • Once again, sound was an issue. My recommendation is to only use the sound core as a module in the kernel and not to include either the OSS or the ALSA drivers. Then go to the Alsa web site, download the software and install them exactly as documented at the site for your particular card.

I hope that someone will get some use out of this. As always, feedback is not only welcome, but encouraged.
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to boot Linux in text mode with GRUB Loader JdS Computer Software Forum - Linux 8 11-Jul-2006 05:41
Mozilla Thunderbird dsmith Computer Software Forum - Linux 9 01-Mar-2005 12:56
Linux Font Improvement Mini-howto dsmith Computer Software Forum - Linux 1 20-Feb-2005 07:37
Changing monitors on a Linux machine JdS Computer Software Forum - Linux 10 23-Dec-2004 10:49

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:22.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.