July 21, 2014
 
 
RSSRSS feed

Building Your Own Linux Kernel, part 1 - page 2

Configure and Build

  • September 24, 2009
  • By Akkana Peck

Configure and build

Once you have a .config file in place from an older kernel, you need to update it for anything that's changed in the latest version.

The next article will discuss details of kernel configuration, but for now, run make oldconfig. It will keep the existing options, and prompt you about anything that's new. That's still a lot of obscure questions, though! Don't panic if you don't understand the questions. That's normal. Just keep hitting return to accept the default values.

Once you finally make it through make oldconfig, you're ready to build. That part is easy:


$ make -j4 && sudo make modules_install
Adjust the -j4 according to the number of processors you have; see the Linux Planet article on multi-core machines for more details.

Install and boot

When the build finishes, your new kernel will be in arch/i386/boot/bzImage. As root, copy it into /boot, but give it a suitable filename:

$ sudo cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.31

With the new kernel in place, you need to add it to the list grub shows you at boot time. (If you use a boot loader other than grub, you're on your own.)

Grub's list of kernels is normally in /boot/grub/menu.lst. Edit that file, skip past pages of comments and look for the first "boot stanza", which will look something like this:

title           Ubuntu jaunty, kernel 2.6.28-11-generic
root            (hd0,3)
kernel          /boot/vmlinuz-2.6.28-11-generic root=UUID=c8253db2-ac0b-4664-9e3c-837ce469a95d ro quiet splash
initrd          /boot/initrd.img-2.6.28-11-generic

Make a copy of that. The copy can go either before or after the original. If you put your new one first, it will become the default boot line the next time you boot. If not, you'll have to use the arrow key to choose it in the grub menu (Figure 2).

figure 2
figure 2

Replace the title with anything you want, and the filename in the kernel line with your new kernel. So your new boot stanza might look like this (changed sections in bold):

title           Ubuntu jaunty with my new 2.6.31 kernel
root            (hd0,3)
kernel          /boot/vmlinuz-2.6.31 root=UUID=c8253db2-ac0b-4664-9e3c-837ce469a95d ro quiet splash
initrd          /boot/initrd.img-2.6.28-11-generic

You may notice that the initrd line still refers to the old kernel version, 2.6.28-11. That's okay -- the initrd is used only while booting. You'll see in a future article how to make your own initrd, and what details like the "AUTOMAGIC KERNELS LIST" in menu.lst means, as well as how to make custom kernel configurations that will make your kernel both smaller and more efficient.

But for now, try booting into your new kernel!

Akkana Peck is a freelance programmer whose credits include a tour as a Mozilla developer. She's also the author of Beginning GIMP: From Novice to Professional.

Sitemap | Contact Us