![]() |
|
|||||||
|
Compiling Your Own KernelCompiling custom kernels for my Linux systems was something which I put off for quite a while, since it seemed quite a major operation. Once I decided to take the plunge and go for it, I realised it's not too hard at all. As long as you have a bootable floppy or CD to boot from if your new kernel doesn't work, you'll be OK. For this simple guide, I'll assume that you use LILO as your boot manager. Obtaining Kernel SourcesBefore you can start compiling your own kernel, you'll need to go and grab the source code for the kernel version you want from the Linux Kernel Archives (you may want to select a local mirror from the mirrors page to get a faster download). Unless you have a specific requirement for a particular version, I'd suggest grabbing the latest stable version - at the time of writing, the current stable version is 2.6.7. On the Linux Kernel Archives homepage, you'll see 'The latest stable version of the Linux kernel is: ' followed by the version number. On the same line there'll be a link 'F' - this is the link to the full kernel source. Once you have the kernel sources, save the archive (for example, linux-2.6.7.tar.bz2) to a convenient location. I'll assume that you save it to your home directory. Now, open a console, and type su to become root. Now, move the kernel sources to /usr/src and decompress them: mv /path/to/downloaded/archive.tar.bz2 /usr/src cd /usr/src bzcat ./linux-2.6.7.tar.bz2 | tar xvf Now, you need to create a symlink, after deleting the current one (if it exists): rm linux ln -s linux-2.6.7 linux Configuring your new kernelNow, you need to configure your new kernel, deciding what features you'd like to have built-in to your kernel, which features you'd like as loadable modules, and which features you don't need. In order to produce a nice, fast, stable kernel for your system, try to include only the features you need - leave out drivers for hardware that's not in your system, and leave off any other features you won't be using. For a server, that often means you can remove any soundcard support (ALSA etc), USB, FireWire etc. To start making your selections, make menuconfig is the easiest way to go, since it lets you choose your options from a menu. Simply: cd linux make menuconfig Compiling the kernelOnce you've configured the kernel the way you want it in the step above, it's time to build it. Once you've exited from the make menuconfig above, you'll be asked to save the config - say yes. Now, you'll want to compile the kernel itself, and compile all the modules you've chosen, so do the following: make bzImage && make modules && make modules_install Installing the new kernelYou'll now want to put your new kernel in /boot for it to be used the next time your system is started. To move the kernel and associated System.map, simply: mv arch/i386/boot/bzImage /boot/vmlinuz mv System.map /boot/System.map Alternatively, your can leave your existing kernel in place, in case you've made a mistake or your new kernel won't boot. If you want to do that, rename the existing vmlinuz and System.map files in /boot, then edit /etc/lilo.conf to modify the old entry and duplicate it for the new kernel. However, if you're intending to replace your old kernel, as long as you have a bootable CD or floppy which you know you can boot your system from, you can simply replace the old files. Finally, to ensure LILO is updated, type lilo. Your new kernel should now be installed - when you reboot your machine, if all went well it should boot up using your new kernel.
Random Quote:
(Psst... My goldfish is the Devil, pass it on!)
(see more) |
|
||||||