Kernel Upgrading, The SAFE Way by Victor Rehorst This document will guide you through upgrading your Linux kernel without putting your system at risk. ---------------------------------------------------------------------- The reasons for upgrading your Linux kernel are many: maybe there's support for that new SuperUltraWhizzBang 9000 device you just bought, or upgraded support for your OldClunkyGarbageDrive, or maybe even speed optimizations, or just because someone told you that the new development kernel is the best thing since sliced bread. At any rate, you're here because you want to upgrade your kernel, and you don't want to fry anything in the process. First things first: We're not going to use any kind of package management here. You may be saying "but RPM's cool!" Well, that may be true, but most of the time RPM won't let you have two different versions of the kernel source installed at the same time. That's exactly what we'll be doing. You may even be saying "but DEB's cool!" If you're running Debian, what the heck are you doing here?!? SETTING UP Let's take a common scenario: You're currently running a kernel in the "stable" group, that is, kernels whos second revision numbers are even (such as 2.0.35) and you want to try out one of those "groovy" development kernels, which have odd-numbered second revision numbers (like 2.1.127). Great. First thing to do is figure out how you're kernel source is set up. In a terminal, cd over to /usr/src and do a long directory listing (ls -l). You should see something like: lrwxrwxrwx 1 root root 14 Nov 5 20:59 linux -> linux-2.0.35/ drwxr-xr-x 15 root root 1024 Nov 4 23:57 linux-2.0.35 The second line there is the directory where your kernel sources are installed. It is almost always in the form 'linux-x.x.xx' where the x's are your version number. The first line is a symbolic link to the source directory. That means that if you were to type 'cd /usr/src/linux' you would end up in the directory /usr/src/linux-2.0.35 instead. OK, now that we've verified that you've got some kernel source installed, and that it's linked properly, we can go and download the new kernel source. The definitive kernel source site is: http://www.kernel.org All of the kernel sources are released here first. There are some common mirrors, although they are usually a little behind the latest releases. The most common mirrors are: http://metalab.unc.edu/pub/Linux/kernel/ Download the full kernel source in tar.gz format. If you're doing this over a modem connection, maybe you could mix a coffee or six while you're waiting. The kernel sources (as of 2.1.131) are around 13MB in size. DOIN' IT RIGHT OK great, we've got the new source tarball all ready. Move it to the /usr/src directory. We need to make a directory for the new source /before/ we extract it. Why, you ask? Well, that's because when you extract the source, it will go into the linux/ directory. Remember that symbolic link up there? Well, this is one of its many uses. If we just extracted the new source without making a new directory and changing the sym link, we would be overwriting our old source, which we don't want to do because the new one won't work yet. So, make a new directory with a name like 'linux-x.x.xxx' or something. It's a good idea to incorporate the version number somewhere in the name. Next, remove the old link (no, you won't delete the directory that it's linked to) with a command like 'rm linux' and make a new one with a command like 'ln -s linux-x.x.xxx linux'. Great. Now type 'tar zxvf linux-x.x.xxx.tar.gz' to extract it, replacing the x's with the actual version number that you downloaded. Done? Great. Now if you do 'ls -l' you'll see something like this: lrwxrwxrwx 1 root root 14 Nov 5 20:59 linux -> linux-2.1.131/ drwxr-xr-x 15 root root 1024 Nov 4 23:57 linux-2.0.35 drwxr-xr-x 15 root root 1024 Dec 3 21:32 linux-2.1.131 See? You've got a new directory with the nice new kernel source in it, just begging to be compiled. So let's do it! Enter the new source directory. If you're running X Windows, type 'make xconfig' to get a nice graphical config tool. If you're not, just type 'make menuconfig' to get a not-so-nice-but- still-neat text menu config tool. The first thing you'll say is "Damn, there's a TON of options!" Well, yeah. There's lots. Good thing the menu system has help options built-in so that you can make the right decisions. Generally, you should go through every single section and examine every single option and decide if you need to compile it or not. That being said, there are some sections that you can skip outright if you KNOW you don't have any of that type of hardware. Things like ISDN and SCSI support, and a few others. Now that the coffee pot's empty, and all of the correct options are set (you think) pick 'Save Configuration and Exit' from the main menu. That will save all of the options you just set and dump you back to the prompt. You're ready to begin compiling your kernel! To start off, run the command "make dep; make clean" which will set up the kernel source for compiling. Now we want to compile our kernel. Since we're not sure if it's going to work the first time, we're going to put the kernel on a floppy disk, so that if it doesn't work properly, we can easily boot our old kernel and not give us a big headache. So grab a blank, formatted floppy disk, shove it in your drive (it should be your /dev/fd0, aka A: drive) and run 'make bzdisk'. We're off to the races! Depending on the speed of your system, you can either fix a light snack while waiting for the kernel to compile, or go to sleep. (On my old 386/25, my kernel took 13 hours to compile. On my P166MMX with 96MB of RAM, it takes around 20-25 minutes.) When it's done, restart your system and leave the floppy in the drive. The kernel should boot off the floppy drive. Sit and watch it, and try to see any weird error messages. If you get something like 'KERNEL PANIC' then something has gone terribly horribly wrong and you should boot without the floppy. (I told you we'd be doing it the safe way!) If everything boots fine, login and make sure all your devices are working (ie. try mounting all of your drives, use the network, start X, play sounds, etc.) If there's something that doesn't work properly, check your kernel configuration and make sure you compiled it into the kernel, and if you did forget something, add it, save the configuration, run 'make dep; make clean' and then 'make bzdisk'. If, after running with your new kernel for a few days, you're satisfied with it and want to make it your permanent kernel, go back to the /usr/src/linux directory. To complile the kernel and reconfigure LILO in one fell swoop, type 'make zlilo' at the prompt. This time, the compilation should go by very quickly; since you haven't changed the kernel configuration, there's nothing to recompile. The new kernel will automatically be copied to the right place on your hard drive and LILO will be run to recognize it. Hey, that's all there is to it! Pretty easy, eh? Now, if you ever run across someone who's afraid to upgrade their kernel, you can teach them! (Or at least give them this URL.) Victor Rehorst Last Modified Fri Dec 4 00:32:24 EST 1998