0% found this document useful (0 votes)
407 views

Kernel Configuration Compilation and Installation

This document provides instructions for configuring, compiling, and installing a custom Linux kernel from source on a FOSS Lab server. It outlines downloading the kernel source, ensuring necessary tools are installed, cleaning old sources, configuring and building the kernel, installing it and modules, updating the boot loader configuration, and rebooting into the new kernel. Key steps include using make xconfig or menuconfig to configure, make all to build, make modules_install and make install to deploy, and verifying the new kernel version is booted.

Uploaded by

ddivaa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
407 views

Kernel Configuration Compilation and Installation

This document provides instructions for configuring, compiling, and installing a custom Linux kernel from source on a FOSS Lab server. It outlines downloading the kernel source, ensuring necessary tools are installed, cleaning old sources, configuring and building the kernel, installing it and modules, updating the boot loader configuration, and rebooting into the new kernel. Key steps include using make xconfig or menuconfig to configure, make all to build, make modules_install and make install to deploy, and verifying the new kernel version is booted.

Uploaded by

ddivaa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CS2406-Lab Manual - NRCFOSS/AU-KBC Centre, Anna University Chennai

14: Kernel configuration, compilation and installation


Aim:
To learn how to configure, compile and install Linux kernel from source.

Introduction:
The Linux kernel in the distributions are configured to work correctly in a wide variety of hardware and there is usually no need to use any other kernel. A user may want to rebuild the kernel for various reasons. The main reason was once to optimize the kernel to the environment (hardware and usage patterns). With modern hardware there is rarely a need to recompile unless there is a particular feature of a new kernel that is required. The performance gains are probably not noticeable unless specific benchmarks are being run.

Description:
Students will compile a custom kernel using the new kernel source available in the FOSS Lab server. The students should be able to boot the system using the newly compiled kernel.

Pre-requisites:
The latest kernel source from the FOSS Lab server. It is located in http://<fosslab-server ip>/content/packages/Linux_Kernel/v2.6/linux-2.6.39.2.tar.bz2

The exercise:
All actions are performed as root.
> su #

We need to ensure that all tools required for compiling the kernel are installed. 1

CS2406-Lab Manual - NRCFOSS/AU-KBC Centre, Anna University Chennai

# yum install kernel-devel

This command will ensure that all packages required to compile the current running kernel will be installed. We will be using the same tools to compile the newer custom kernel. Remove traces of old kernel source if they exist. Be very carefull with the rm command as you can completely trash the system if you are careless.
# rm -rf /usr/src/linux/ # rm -rf /usr/src/linux-2.6/

The kernel source is usually kept under /usr/src. Copy the downloaded kernel source to /usr/src.
# # # # cp linux-2.6.39.2.tar.bz2 /usr/src cd /usr/src/ tar -xjvf linux-2.6.39.2.tar.bz2 cd linux-2.6.39.2

We now create two symlinks to the kernel tree.


# ln -s /usr/src/linux-2.6.39.2 # ln -s /usr/src/linux-2.6.39.2 /usr/src/linux /usr/src/linux-2.6

Now we clean out all previous configurations and reset the source directory to a pristine state. The main reason for doing this is that some files do not automatically get rebuilt, which can lead to failed builds, or at worst, a buggy kernel
# make mrproper

Now we configure the kernel. The build system is intelligent enough to take most of the current configuration from the currently running kernel. There are thousands of options and usually the current options will be suitable to create a working kernel. We can experiment with modifying the kernel options after compiling the kernel successfully with the default configuration.
# make xconfig (or) # make menuconfig

CS2406-Lab Manual - NRCFOSS/AU-KBC Centre, Anna University Chennai

Save and exit the tool. Now we are ready to build the kernel.
# make clean # make all

This can take up anywhere from 10 minutes to upto 2 hours depending on the hardware. Once the compilation is completed we can install the kernel and its modules.
# make modules_install # make install

The newly created kernel will be in /boot Now we need to check that the install process has configured the boot loader to point to the new kernel.
# vi /boot/grub/menu.lst

CS2406-Lab Manual - NRCFOSS/AU-KBC Centre, Anna University Chennai The new kernel will have an entry at the top of the kernel list. It can be identified by the kernel version number. Change the lines containing default, timeout to the values shown and comment out the hiddenmenu entry.
default=0 timeout=5 #hiddenmenu

Now reboot the computer and the computer will boot into the new kernel. If it fails, reboot the machine and select the previously running kernel to boot successfully and redo the exercise carefully. To check the version of the running kernel, use the uname command.
# uname -r 2.6.39.2

Now the process can be repeated with different kernel configuration options.

References:
1. http://kernelnewbies.org/FAQ/KernelCompilation - Kernel Compilation FAQ 2. http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html - Kernel build HOWTO

You might also like