Vanilla Kernel HowTo – Version 2.6


I don’t know about other distros, but I am pretty sure this is a method of installing a new 2.6 kernel that will work on just about any distro.

But, I am not sure, so YMMV.

I make it a point to boot into init level 3 (edit /etc/inittab), since I will have to recompile my nvidia module before getting xorg running. This keeps xorg from freaking out on reboot.

The steps I take are such:

  1. Download the latest stable kernel from The Linux Kernel Archive . You can also search here for older releases.
  2. Open a shell or change to a console prompt (CTRL+ALT+F1).
  3. df -h” :: In a shell, make sure there is plenty of space in the root partition (just a sanity check).
  4. mv /path/to/linux-2.6.19.tar.bz2 /usr/src && cd /usr/src” :: Log into a shell as root and move the downloaded kernel file to /usr/src, then go there.
  5. tar xvfj linux-2.6.xx.tar.bz2” :: Extract the contents of the kernel tarball, including it’s directory path info.
  6. ls -l” :: If you list the /usr/src directory, you may have some directories already there, along with the kernel file you just moved and the directory to which you just extracted it.
  7. rm -f linux && ln -s linux-2.6.xx linux && ls -l” :: If there is a linux link (it will probably point to an older linux-2.6.xx directory), delete it, relink it to the new kernel version directory, and verify such.
  8. cd linux” :: Change to the new kernel directory.
  9. make oldconfig” :: This creats a baseline .config file with the kernel build options selected from your running kernel. Saves time and helps insure that the new kernel will have the same success on your platform as the old kernel. Just accept all the defaults to keep changes to a minimum – you can tweak later after you are sure the new kernel work properly.
  10. make && make modules && make modules_install && make install” :: This does all the work – from start to finish, it takes that .config file you made and creates a new kernel off of it, all the modules selected, and installs both, right down to setting up the bootloader (lilo I am sure of, grub I assume so). For lilo, it also runs lilo afterwards.

Now, afterwards, I like to edit my /etc/lilo.conf (I use vi cuz I am used to it, but whatever floats your boat). I will make the new entry default and ensure it is named in the same manner as my other kernel entries. I really like being able to have different kernel versions to choose from, even though I do not use this unless I get into trouble. I run lilo after saving my changes and exiting vi.

Then I reboot. Usually, there are no problems, and I finish up by recompiling my nvidia module and reconfiguring vmware server (“vmware-config.pl”), and typing “X” to test xorg. If all is well, CTRL+ALT+BACKSPACE kills X, and I type “init 5” to start xorg (GDM and KDE). I also save off /usr/src/linux/.config to a config backup folder (on the /home partition) as hostname-2.6.xx.config.

Note 1: The stuff in /usr/src is just for building – if you need space and do not need the kernel headers for compiling software against, you can delete the /usr/src/linux and /usr/src/linux-2.6.xx directories to clear up a few hundred meg on your root partition. The real stuff is under /boot and /lib/modules.

Note 2: If you screw up and something doesn’t work right, or you want to tweak the kernel after a good reboot, go back to /usr/src/linux and “make menuconfig“. You can use other make config options as well for GUI support, but I like menuconfig, since you do not need X or a mouse running to use it. Once done, either repeat step 10, or save the new .config file off, “make mrproper” to clean everything up and return the directory to the same state it was in just after extracting it in step 5 and copy back the modified .config file. Then repeat step 10. What you have to lose is the potential to omit hardware drivers by accident, rendering your computer, say, soundless, for example. What you have to gain is a smaller, lighter, cleaner kernel, that may well run your system faster and improve stability.

Note 3: I have found that if you only add modules and do not go with the “make mrproper” method, the build time is dramitically shortened, as basically only the new items will be compiled. Nice touch.

Note 4: If you tweak your kernel, make sure that in the Filesystems area, you leave ext2 as compiled into the kernel. Regardless of what you use (I use Reiserfs), ext2 appears to be vital to the kernel and should not be a module, much less excluded. The file system you use can be a module, however, which leads me to believe that ext2 plays a role in the kernel boot sequence. In the past, excluding it or making it load as a module has always resulted in a kernel panic on the 2.6 kernel. I haven’t tried it lately, but I also figure that it is probably not a battle worth fighting. My kernels are already down to around 1.3 meg, down from the 1.7+ meg for stock Mandriva 2.6 kernels…. I also make sure LVM and RAID are compiled into the kernel, not as modules, however, for systems I build which use them.

Hope this helps someone else. Compiling a new kernel is not really that tough to do, and can show you a lot about what is going on under the hood.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: