RECOMPILING THE LINUX KERNEL By Ed, updated 12-10-00 www.narced.com/linux Here are the basic instructions for recompiling the Linux kernel (2.2.x). As of this writing, the latest stable kernel is 2.2.13. For in depth instructions, see the bottom of this file. Here are the quick commands: cp //linux-2.2.x.tar.gz /usr/src rm -r linux tar -xzvf linux-2.2.x.tar.gz cd linux make mrproper #You only need to run this command if you ran 'make' once before make menuconfig #If you have 'ncurses' installed; Otherwise, 'make config' make dep make modules make modules_install [Go to A or B from here. A is the easy way; B is for when you need to customize something or you're compiling a kernel for another machine.] make install [go to C] make zImage cd arch/i386/boot/ cp zImage /boot mv zImage vmlinuz-2.2.x-some-name ln -s vmlinuz vmlinuz-2.2.x-some-name [go to C] lilo reboot! ------------------------------ Here are the long instructions: First Step, go to http://ftp.us.kernel.org/pub/linux/kernel/ and download linux-2.2.x.tar.gz. Save this file into /usr/src. Delete/move the current 'linux' directory/sym link inside of /usr/src. Untar your downloaded kernel file by typing: tar -xzvf linux-2.2.x.tar.gz This will create a new 'linux' directory in /usr/src. Type: cd linux (your current directory should be /usr/src/linux) Type: make mrproper This command will clean up and leftover files from a previous kernel compilation. This command is not necessary if you just untarred the kernel file. Type: make config This will ask you a ton of yes/no/module questions. Yes will put support for whatever it is directly into the kernel. Be careful not to say yes to stuff you don't need - this can create security holes or a kernel that is too big. Module will include the option separately. You may have to use 'insmod' to load these modules at or after boottime. --After you finish answering all of the questions, a .config file is created inside of the /usr/src/linux directory. Make a backup copy of this if you want. Also, if you run make config again with that .config gile in place, it will use your answers as the default. (For example, when you run make config for the first time, it asks you if you want support for symmetric multiprocessing in your kernel. The default is Yes - although most people don't need it. If you answer no, and then run make config again, the default will have been changed to No based on your saved .config file.) Type: make dep This will create module dependencies and stuff like that. Type: make modules Type: make modules_install The first command will compile the modules, the second will copy them into the correct directories. Now, you have a choice on how to compile your kernel. The easy way is to type: make install. This will compile the kernel and copy it to the / or the /boot directory. The intelligent way to compile the kernel is to first type: make zImage. This will create a zImage file (the kernel) in the /usr/src/linux/arch/i386/boot/ directory. Copy the zImage file to the /boot directory (RedHat and Caldera) or the / directory (Slackware). [Note: The directory you copy it into doesn't really matter b/c this is controlled by the /etc/lilo.conf file. Putting everything in /boot is more organized and cleaner - also, you can set the permissions of /boot to be 700, but you can't quite do that with / .] cd into / or /boot Rename the zImage file to vmlinuz-something-meaningful. (Example: mv zImage vmlinuz-2.2.x-printer+sound) Create a symbolic link of vmlinuz pointing to your kernel with the ln command: ln -s source destination ln -s vmlinuz vmlinuz-2.2.x-printer+sound Edit the /etc/lilo.conf file, and look for the line that looks like: image=/boot/vmlinuz Make sure the path is correct, and then reinstall lilo by typing: lilo REBOOT! Congrats, you now have a new kernel. It would probably be smart to have a boot disk handy, in case something gets screwed up. Stuff Happens.