Go back to previous page
Go back to home page

How to make and install a new kernel

 under Ubuntu









s


Install the required packages for Kernel compilation
Configure the Kernel
Build the Kernel
Install the new Kernel
Links
About the author

Install the required packages for Kernel compilation

Check that kernel-package is installed to be able to build the Linux kernel related Debian packages:

$ dpkg -l | grep kernel-package
ii  kernel-package          11.001     A utility for building Linux kernel related Debian pac

If the previous command does not show the installation, get the package:

$ sudo apt-get install kernel-package

???? Install qt3 to be able to "make xconfig"

Configure the Kernel

Make a backup of the source directory to be able to go back to a clean version if one of the following actions fail.

Go into the source directory:

$ cd /usr/src/linux-source-2.6.22

If it is needed to configure the new kernel from the current kernel configuration, copy the configuration into the source directory:

$ sudo cp /boot/config-`uname -r` .config

Optionally, add the patches and any other modifications into the source tree.

Then, configure the kernel:

$ sudo make oldconfig

$ sudo make menuconfig

Or if libqt3 is installed:

$ sudo make xconfig

This brings up the kernel configuration menu. Go to "Load an Alternate Configuration File" and choose the .config file just modified:

??? screen shot of menu ???

Build the Kernel

Run a make-kpkg clean after configuring the kernel using make (x|menu)?config, since  that  creates  the  file include/linux/version.h without the append_to_version data. This file won’t be updated by the make-kpkg run (make-kpkg creates version.h if it doesn’t exist, but doesn’t touch if exists), so the final kernel will not have the append_to_version data in its version number and it shall look for the modules and symbols in all the wrong places. So, clean up the subtree:

$ sudo make-kpkg clean

Launch the build of the kernel with make-kpkg command.
The --initrd option will build a kernel loading with an initial ramdisk.
The --append-to-version option specifies an extra version number. Here we choose -tipc.
The kernel_image target produces a Debian package of the Linux kernel source image and any modules configured in the kernel configuration file .config.
The kernel_headers target produces a Debian package containing the header files included in the Linux kernel.

$ sudo make-kpkg --initrd --append-to-version=-tipc kernel_image kernel_headers modules_image

After --append-to-version, you can write any string that helps you identify the kernel, but it must begin with a minus (-) and must not contain whitespace.

The compilation ends with two debian packages in /usr/src:

$ ls -l /usr/src
[...]
-rw-r--r--  1 root src    8593764 2008-02-01 17:03 linux-headers-2.6.22.9-tipc_2.6.22.9-tipc-10.00.Custom_i386.deb
-rw-r--r--  1 root src  215398422 2008-02-01 16:57 linux-image-2.6.22.9-tipc_2.6.22.9-tipc-10.00.Custom_i386.deb
[...]

Install the new Kernel

Install the packages:

$ cd /usr/src
$ sudo dpkg -i linux-headers-2.6.22.9-tipc_2.6.22.9-tipc-10.00.Custom_i386.deb
$ sudo dpkg -i linux-image-2.6.22.9-tipc_2.6.22.9-tipc-10.00.Custom_i386.deb

Verify the installation:

$ dpkg -l | grep linux-image
[...]
ii  linux-image-2.6.22.9-tipc                  2.6.22.9-tipc-10.00.Custom                Linux kernel binary image for version 2.6.22.9-tipc

[...]

Two stanzas have been added to /boot/grub/menu.lst:

$ cat /boot/grub/menu.lst
[...]
title           Ubuntu 7.10, kernel 2.6.22.9-tipc
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.22.9-tipc root=UUID=40e71a91-f1fc-4e08-a8ac-ddf0497dbc44 ro quiet splash
initrd          /boot/initrd.img-2.6.22.9-tipc
quiet

title           Ubuntu 7.10, kernel 2.6.22.9-tipc (recovery mode)
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.22.9-tipc root=UUID=40e71a91-f1fc-4e08-a8ac-ddf0497dbc44 ro single
initrd          /boot/initrd.img-2.6.22.9-tipc
[...]

The system is ready to be rebooted. After restart, it is possible to check the current installed kernel with:

$ uname -r

If the system doesn't start, restart it and select another kernel by typing ESC upon this messages:

press ESC to enter the GRUB menu:

Go to this page if you want to uninstalled your newly created kernel.

Links

About the author

The author is an engineer in computer sciences located in France. He can be contacted here or you can have a look at his WEB home page.




Go back to previous page
Go back to home page