Recompiling the Linux Kernel - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Recompiling the Linux Kernel

Description:

e.g. : File-system, Sound driver, video. Communication Using Message Passing ... Crash in any region can bring down the whole system. e.g. : DOS. Linux ( The Kernel ) ... – PowerPoint PPT presentation

Number of Views:119
Avg rating:3.0/5.0
Slides: 17
Provided by: foss
Category:

less

Transcript and Presenter's Notes

Title: Recompiling the Linux Kernel


1
Recompiling the Linux Kernel
  • by
  • Mahendra M
  • Mahendra_M_at_infosys.com
  • http//www.infosys.com/

2
Traditional Kernel Architectures
  • Micro Kernels
  • Macro Kernels
  • Modular

3
Micro Kernel Architecture
  • A Core Kernel
  • All functionalities in User Space
  • e.g. File-system, Sound driver, video
  • Communication Using Message Passing
  • Fast in Theory Experimental Setups
  • Practically Slow Less Efficient
  • A crash in a subsystem doesnt bring down the
    whole system
  • e.g. Minix, QNX, GNU/Hurd (??)

4
Macro Kernel Architecture
  • A single monolithic kernel
  • Everything in Kernel Space
  • Communication using function calls
  • Practically fast
  • Easy to implement
  • Crash in any region can bring down the whole
    system
  • e.g. DOS

5
Linux ( The Kernel )
  • Modular, Monolithic Kernel
  • Modules can be compiled and dynamically linked
    into kernel address space.
  • Useful for device drivers that need not always be
    resident until needed.
  • Keeps core kernel "footprint" small.
  • Can be used to "extend" functionality of kernel
    too!
  • Modules are loaded into kernel address space and
    unresolved symbols in the module are linked to
    the symbol table of running kernel.

6
Linux ( The Kernel ) contd...
  • Advantages
  • Footprint of running kernel is small
  • Unused modules are flushed out. Increases
    efficiency
  • Flexibility - Dynamically add new features
  • Disadvantages
  • A faulty module can bring down the system
  • Slight overhead in loading the modules
  • Advantages outweigh Disadvantages
  • Murphys law If it aint broken, dont fix it

7
Precautions
  • Compulsory non-modular cases
  • Hard Disk support
  • will prevent loading of any module, since the
    hard-disk cannot be probed to access modules
  • Filesystem of root partition
  • Diskless clients ethernet drivers / NFS root
    filesystem
  • will prevent booting up of the system, since the
    kernel image cannot be obtained over the network.
  • Maybe even TCP/IP support.

8
Module Handling Tools
  • insmod - link a module into the running kernel by
    resolving all symbols from the kernels exported
    symbol table.
  • -root option for enhanced security
  • depmod - creates module dependency file -
    modules.dep
  • modprobe - loads all relevant modules from above
  • rmmod - removes unused modules
  • kmod - kernel thread
  • replacement for kerneld ( does not remove modules
    )
  • kmod calls modprobe
  • together they can loop (if modules.dep is
    absent). Handled by a compile time option.
  • "kmod runaway modprobe loop assumed and stopped
  • eg modprobe started with syslog option. (
    needs unix sockets )

9
Steps in loading a module
  • Kernel notices a feature request not resident in
    the kernel
  • Sends a message to kmod with a symbolic
    description of the feature
  • kmod asks modprobe to load a module
  • modprobe looks into its internal alias
    translation table for a match
  • insmod is asked to insert all modules needed
  • configured accroding to the options in
    /etc/modules.conf
  • kernel uses the freshly installed feature as if
    it was configured as a resident part

10
Recompiling the kernel
  • Why recompile ?
  • Feel like owning a custom made BMW.
  • Highly optimized than kernels in distros ( eg
    i386 compilation )
  • Reduce kernel footprint.
  • Increase efficiency. Higher performance
  • Notice If you get it correct first time,
    contact Torvalds.
  • Notes .

11
Notes
  • "Processor type" is set higher than 386 -
  • Will not work on a 386
  • A kernel with math-emulation compiled in will
    still use the coprocessor if one is present
  • The math emulation will just never get used in
    that case.
  • Having unnecessary drivers will make the kernel
    bigger
  • Can lead to problems
  • It is YOUR call.
  • Enable Magic System Request Key Hacks
  • Have FUN !!!

12
The Five steps to Freedom
  • make config ( or gconfig/menuconfig )
  • select resident modular parts
  • make dep
  • make bzImage
  • build the actual image
  • make modules
  • builds all modules
  • make module_install
  • installs the modules in /lib/modules/2.6./

13
Compilation
  • Dependence on gcc
  • Work in progress
  • -j option for make
  • -jN ( N Num of Processors 1 )
  • EXTRAVERSION
  • To protect your working modules/kernel
  • Dont change VERSION, PATCHLEVEL or SUBLEVEL
  • Applications may refer to these

14
Finally
  • Extensive Documentation
  • The Kernel Source Tree
  • Demo . . .

15
Links
  • http//infylug/kernel
  • http//kernel.org
  • http//www.kernelnewbies.org
  • http//www.sudolinux.com/kernel_links.htm
  • Lots of Kernel related links
  • http//www.digitalhermit.com/linux/kernel.html
  • Excellent Document on Recompiling the kernel
  • http//www.linux.it/kerneldocs/kconf/
  • Reconfiguring the Linux Kernel

16
Thankyou
Write a Comment
User Comments (0)
About PowerShow.com