This node to help CaptainSpam; it may also work for you, but no guarantees

Download the latest kernel sources from ftp.kernel.org, or a mirror.

I do the next step in /tmp
gunzip and tar -x it, if you got the tar.gz

Then move the directory to /usr/src/linux-XX.YY.ZZ where the XX.YY.ZZ is the version number and revision number.
At this point you should move the existing /usr/src/linux symlink.
cd /usr/src/linux
You have 4 options:
1) make oldconfig; if you have previously compiled your kernel;
2) make config; step by step through each question, may be unfriendly;
3) make menuconfig; what i usually choose; a menu system for configuration of options;
4) make xconfig; (i think... i don't use it);

go for make menuconfig

Tweak till your heart is content. Then make dep.
If you use lilo, make lilo. If the kernel is too large, make bzlilo. Then rerun lilo.

If you don't use lilo, then make zImage. If the kernel is too large, make bzImage.

If you compiled anything as a module, then make modules followed by make modules_install

If you're running Debian, you can simplify this a bit by installing kernel-package (apt-get update, apt-get install kernel-package). Do what idoru says up to and including make menuconfig, and then

make-kpkg --revision=Whatever.1.0 kernel-image
(The 1.0 in the revision name appears to prevent dselect from trying to replace your kernel package.)

/vmlinuz is going to become a link to your new kernel. Edit /etc/lilo.conf accordingly.

cd /usr/src
dpkg -i kernel-image*.deb
reboot
(The reboot is to start running your new kernel.)


Before I do any of this I like to backup my /boot partition. It may come in handy, I've wished I'd done it:

tar -cf /home/boot.backup.tar /boot

Use -cvf if you want to see what is going on.

Most people follow idoru's advice, then type:

su
make install

Note that all of the make steps except make install can be done as a regular, non-root user. Thy shall not take root's name in vain.

Now go edit your /etc/lilo.conf file.

When that's done and you've got a dead chicken to waive over your computer, reboot and during the startup process, you'll see

LILO boot:

Hit tab for options, and type in the option for your new kernel. If everything works now, rejoice. If you see a lot of kernel panics, or Nothing Happens., take notes on what did happen (and see /var/log/boot.log), and reboot with your old kernel. Go back to make menuconfig and try again. STFW to find out what happened.

Some quick things I would like to add, from my own experience:

  • You may want to backup the existing file called System.map in /boot and replace it with the new one that will be generated after the compile. It will reside in the root of the kernel tree (/usr/src/linux).
  • Also, it doesn't really seem explicity mentioned here, but if you are editing your lilo.conf manually, make very sure that you left atleast one old, working image configured. This will assist you greatly if your new kernel spontaneously combusts when you reboot.
  • One other thing that does not seem explicitly mentioned. When using make bzImage (the most common method, I believe), the actual kernel image itself will be in the /usr/src/linux/arch/i386/boot directory for intel machines. It will be called bzImage.

(I have put the text through the official text formatter now! Hopefully this will work for everyone.)

This is a summary I've used before of my own creation. I've added some snippets from the above posts. Please post additions, subtractions, thoughts, improvements. Thanks.

Download the latest kernel sources from ftp.kernel.org, or a mirror.

I do the next step in /tmp - gunzip and tar -zxvf it, if you got the tar.gz

rename your old source tree untar new tree make sure the symbolic link of /usr/src/linux points to new kernel that you just untarred

cd usrsrc rm linux ln -s /usr/src/linux-2.2.NEW /usr/src/linux
(where /usr/src/linux-2.2.NEW is the new kernel directory)

This will leave the old stuff as a backup and out of your way and now the directory of /usr/src/linux points to the right place.

These next two symbolic links are necessary (or at least I was told this from the newsgroups - a long time ago - seems better to do this than not and err on the side of caution. If we don't need them anymore, someone please tell for sure - thanks).

ln -sf /usr/src/linux/include/linux /usr/include/linux

(this creates symbolic links to current installed libraries from new kernel src)

ln -sf /usr/src/linux/include/asm /usr/include/asm

(this create symbolic links to current installed libraries from new kernel src)

And if you have SCSI drives do this to link to the new scsi source.

ln -sf /usr/src/linux/include/scsi /usr/include/scsi

Now use the following to commands to setup and compile your new kernel and modules.

make mrproper
make menuconfig or xconfig or oldconfig
make dep
make clean
make bzImage
make modules
make modules_install

Copy and rename kernel to boot directory The newly compiled kernel is called "bzImage" and will be located in:

/usr/src/linux/arch/i386/boot

Better be more precise here, especially if you have more than one kernel in your /boot directory. If you had vmlinuz as a symbolic link to your old kernel, then "rm -rf vmlinuz".

Now copy or move over the new kernel and rename it vmlinuz-2.2.-x. Then "ln -s vmlinuz-2.2.x vmlinuz" will set you straight with using the new kernel.

Edit lilo.conf

Just make sure that you are pointing to the right kernel in your first lilo boot block stanza.

Run "zlilo" to set the new kernel Or just run /sbin/lilo.

Other symbolic links to change afterwards:

The new system Map found in: /usr/src/linux

Best to "rm -rf System.map" in your /boot directory, then move over the new System.map from the source tree (/usr/src/linux) to the /boot directory. Once it is there, "mv System.map System.map-2.2.x" and then "ln -s System.map-2.2.x System.map". It may seem anal to use symbolic links but this avoids the possibility of nuking the real file rather than the link. That should do it. Reboot and see if things look OK.

Advice provided by: jbowling(at)direct(dot)ca and others at linux.sources.kernel

Log in or register to write something here or to contact authors.