Thursday, January 27, 2011

Compiling Kernel Source

Exercise 2

As the kernel source is modified to add a new system call in Exercise1, then we need to compile it to generate a new kernel image and this new image is used at the next boot of the system.

(Mainline kernel is called as vanilla kernel)
Note: I am assuming that you are in source directory, at /usr/lib/linux-2.6.32

Step1: Assign kernel version tag.
 
To do so open the Makefile at the path /usr/lib/linux-2.6.32/Makefile and at the top of the file you will find the field EXTRAVERSION, edit as follows

$ Vim Makefile

Modify: EXTRAVERSION = mytest
*save the above changes to file.

Step2: Choose kernel configuration.
 
To do so type that following command. This will generate a configuration file “.config”. Any file that starts with “.” is a hidden file, to list the hidden files use option 'a' with 'ls' command.
$ make menuconfig (this pumps kernel info onto console, wait until prompt returns)

Note: refer to man pages on make, type “make help” at your terminal.

Step3: Compile the source to create kernel image (raw) and modules.

$ make
This takes around 30 min on a normal desktop, to speed up, create threads if yours is a multicore machine. To do so type the following command, here 4 is the no of threads.

$ make -j4

Step4: Install the modules on file system
 
To do so type the following command.
$ make modules_install
This copies the modules into disk space and adds folder at /lib/modules/[name]

Step5: Update bootloader and boot folder with new kernel information.

To do so type the following command.
$ make install
Grub contains the list of kernel images, one among them is chosen at boot time.


Please leave comment :-)                                                  Queries are at free of cost

1 comment:

  1. Thank you, I have been looking for information about this subject for ages and yours is the best I've found so far.
    Commodity Tips

    ReplyDelete