0% found this document useful (0 votes)
8 views9 pages

Kernel Recompilation Guide and Steps

This document provides instructions for recompiling the Linux kernel. It explains reasons for recompiling such as optimizing for applications, removing unnecessary capabilities, or adding new features. It also outlines the steps to recompile, which include installing necessary packages, obtaining kernel sources, configuring options, compiling the kernel and modules, and installing the new kernel image and initrd. Recompiling allows customizing and optimizing the kernel for specific system needs.

Uploaded by

maruthi11115294
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 PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

Kernel Recompilation Guide and Steps

This document provides instructions for recompiling the Linux kernel. It explains reasons for recompiling such as optimizing for applications, removing unnecessary capabilities, or adding new features. It also outlines the steps to recompile, which include installing necessary packages, obtaining kernel sources, configuring options, compiling the kernel and modules, and installing the new kernel image and initrd. Recompiling allows customizing and optimizing the kernel for specific system needs.

Uploaded by

maruthi11115294
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 PPT, PDF, TXT or read online on Scribd

Kernel Recompilation

M.B.M. Krishna
Why should I ?
 To optimize the system for a specific application.

 To remove not required capabilities for security or


speed reasons.

 To add more features required for us

 To reconfigure system related parameters like page


size etc

 To change kernel related parameters that are not


configurable using the proc file system

 To add your own code in the drivers or kernel.


So what do I require
?
 Most packages required for recompiling the kernel will usually
be installed by default (except for the actual source code)

 Kernel sources: glibc-kernheaders, kernel-source

 Compiler utilities: kgcc, gcc, dev86, cpp, make, binutils

 Libraries: glibc-devel, ncurses, ncurses-devel

 HOWTO: check rpms are present or not ??


Here are the source
files …
 All the sources files can be found in /usr/src/linux-(version)
 Version number can queried using “ uname –r ” (or) “ cat
/proc/version ”

 Version consists of 4 parts … 2.4.20-8smp


 MAJOR VERSION – 2
Major version is incremented when kernel undergoes a major design change

 PATCH LEVEL = 4
Patch Level indicates minor changes in the kernel code, even number
indicates a stable development branch and odd number is under
development and requires patches to improve the kernel

 MINOR VERSION = 20
Minor version increments on additional device or kernel module support

 EXTRA VERSION = -8smp


Extra Version distinguishes b/w various configurations for the same kernel
I will have a break ?

Hey its your time to


play with the source
code …
Its time to start …
 Change the extraversion in makefile to “mykernel” (say)

 First we have to clean up the kernel source tree to make it suitable


recompile again,
 make mrproper

 Now, you have to create a configuration template for your


architecture. Default configuration files for most machine
architectures are present in configs subdirectory. Copy the config
file corresponding to your machine architectures (say i686) to arch
 cp configs/[Link] arch/i386/defconfig

 make oldconfig

 Linux Kernel can be customised to have


 Compiling the component statically into the kernel
 Including the component as a dynamically loadable module
 Excluding the support from the kernel altogether
 make menuconfig

 Now create a dependencies file, containing all the
dependencies for selected modules in the menu
 make dep

 Build the compressed kernel image, arch/i386/boot/bzImage


will be created
 make bzImage

 Build the modules to be dynamically loaded and make them


installable whenever required,
 make modules

 make modules_install
Some Post works…
 In Redhat, all the post compilation work will be done using,
 make install

 For others, copy the kernel image to boot directory,


 cp arch/i386/boot/bzImage /boot/linux-2.4.20-mykernel

 Create an initial ramdisk image usning,


 mkinitrd /boot/[Link] 2.4.20-mykernel

 Edit /etc/[Link] to have a similar lines as it is for the


actual image,
 Title 2.4.20-mykernel
root(hd0,0)
kernel /linux-2.4.20-mykernel ro root=LABEL=/
initrd /[Link]
Summary
 Why Bit wise

 What Bit wise

 When Bitwise

 How Bitwise

Contact:
krishnambm@[Link]

You might also like