1 / 16

Recompiling the Linux Kernel

by Mahendra M Mahendra_M@infosys.com http://www.infosys.com/. Recompiling the Linux Kernel. Traditional Kernel Architectures. Micro Kernels Macro Kernels Modular. Micro Kernel Architecture. A Core Kernel All functionalities in User Space e.g. : File-system, Sound driver, video

marc
Download Presentation

Recompiling the Linux Kernel

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. by Mahendra M Mahendra_M@infosys.com http://www.infosys.com/ Recompiling the Linux Kernel

  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 doesn’t 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 • Murphy’s law : If it ain’t broken, don’t 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 kernel’s 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 it’s 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 • Don’t 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

More Related