The Linux 2.6 Kernel Trilogy Ends: Go Configure - Page 2

By Carla Schroder | Posted Mar 24, 2004
Page 2 of 2   |  Back to Page 1
Print ArticleEmail Article
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
Continued From Page 1

Building The Kernel And Modules
Once you've finished and saved your configuration, 2.6 builds the kernel and modules all in one step:

$ make

On a slow system, this will take awhile. Go take a nice walk. Then come back and gaze upon your new kernel image, it should be ~/src/arch/i386/boot/bzImage (or whatever your architecture is).

You can have several versions of gcc installed, and select the one you want to use this way:

$ make CC=gcc-2.95

To view a whole raft of "make" targets, run make help first. When it's done, modules must be installed by the superuser:

# make modules_install

You will find your shiny new modules in /lib/modules/2.6.3.

Copy Kernel Image To /boot
Now your nice new kernel image must be moved to /boot, naming it whatever you like, I'll call mine bzImage-2.6.3-testkernel. The kernel name doesn't matter, as long as you tell your bootloader what it is.

# cp ~/src/arch/i386/boot/bzImage /boot/bzImage-2.6.3-testkernel

It is OK to stick with tradition, and call it vmlinuz-something, if you like. Now copy the new System.map:

# cp ~/src/System.map System.map-2.6.3-testkernel

And create a soft link in /boot:

$ ln -s /boot/System.map-2.6.3-testkernel /boot/System.map

Use ln -sf if necessary, to overwrite the existing link.

Configure Bootloaders
Finally, tell GRUB or LILO about your new kernel. Your GRUB config will look like this, using, of course, the appropriate values for your system.

title     Kernel 2.6.3, test kernel
root      (hd0,5)
kernel      /boot/bzImage-2.6.3-testkernel root=/dev/hda6 ro
savedefault
boot

LILO looks like this:

image=/boot/bzImage-2.6.3-testkernel
    label=Kernel 2.6.3, test kernel
    root=/dev/hda6
    read-only

And remember to re-run LILO:

$ /sbin/lilo

Now you can reboot, select the new kernel, and start testing it. If it doesn't work, simply reboot to your stock kernel.

Applying A Kernel Patch
When it's time to upgrade to 2.6.4, you don't need to download the whole works. All that's necessary is to apply a patch, or perhaps several patches, then rebuild the kernel using make oldconfig, instead of make xconfig. Be sure to save a copy of your current .config file as .config.bak, or make mrproper will overwrite it. Download the patch to ~/src, then unpack and apply the patch:

$ bzip2 -dc ../patch-2.6.4-test1.bz2 | patch -p1

If there is more than one patch, apply them in order. Clean up the source tree, then build the new kernel:

$ make mrproper
$ make oldconfig

Then install the new kernel, and you're in business.

Kernel Building As an Ordinary User
Many docs tell you to unpack sources into /usr/src/, and do the configuration and build process as root. Don't do that. All you're doing is building a usable kernel image, which does not require root privileges. Remember the cardinal Unix rule: Use the least possible privileges for any job, it's safer. All you need superuser powers for are running make modules_install, copying the new kernel image to the boot directory, and editing the bootloader.

Resources
This is the most comprehensive kernel-building how-to I've ever seen, with an extensive section on configuration. It was sent to me by an awesome reader — thanks! Note that there is a section on 2.6 at the end: Compiling a Custom Linux Kernel
See also the extensive documentation in your kernel sources, under ../Documentation


» See All Articles by CrossNodes contributor Carla Schroder

Comment and Contribute
(Maximum characters: 1200). You have
characters left.
Get the Latest Scoop with Enterprise Networking Planet Newsletter