Kernel compilation


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Kernel compilation

  1. 1. OTP Training - Ganesh M C
  2. 2. Drivers and the kernel <ul><li>UNIX system has three layers: </li></ul><ul><ul><li>The hardware </li></ul></ul><ul><ul><li>The operating system kernel </li></ul></ul><ul><ul><li>The user-level programs </li></ul></ul><ul><li>Kernel </li></ul><ul><ul><li>Kernel hides the hardware, provides a abstract, high-level programming interface </li></ul></ul><ul><ul><ul><li>Process </li></ul></ul></ul><ul><ul><ul><li>Signal and semaphores </li></ul></ul></ul><ul><ul><ul><li>Virtual memory </li></ul></ul></ul><ul><ul><ul><li>The filesystem </li></ul></ul></ul><ul><ul><ul><li>Interprocess communication </li></ul></ul></ul><ul><ul><li>  Kernel contains device drivers that manage its interaction with specific pieces of hardware. </li></ul></ul><ul><ul><li>Size of kernel </li></ul></ul>
  3. 3. Why Configure the kernel <ul><li>Generic kernel </li></ul><ul><ul><li>Many device drivers </li></ul></ul><ul><ul><li>Optional packages </li></ul></ul><ul><li>Tailor the kernel for your need </li></ul><ul><ul><li>Less memory </li></ul></ul><ul><ul><li>Well-tuned configuration </li></ul></ul><ul><li>Add support for new types of device </li></ul><ul><ul><li>Some system is simple </li></ul></ul><ul><ul><li>Some may need to several steps. </li></ul></ul><ul><li>Read this: </li></ul><ul><ul><li>Building the kernel is not difficult; its just difficult to fix when you break it. </li></ul></ul><ul><ul><li>Get a good reference book for your OS </li></ul></ul>
  4. 4. Kernel Source Repository <ul><li> </li></ul><ul><ul><li>Is the place where you could get the kernel source </li></ul></ul><ul><ul><li>Compile it according to your need </li></ul></ul>
  5. 5. Packages required to start compilation <ul><li>apt-get install build-essential </li></ul><ul><li>apt-get install bin86 kernel-package </li></ul><ul><li>apt-get install module-init-tools initrd-tools </li></ul><ul><li>apt-get install fakeroot </li></ul><ul><li>apt-get install libncurses5-dev </li></ul>
  6. 6. Kernel Compilation <ul><li>Decide where to build your kernel </li></ul><ul><ul><li>Good place is $HOME </li></ul></ul><ul><li>Deciding on a kernel version </li></ul><ul><ul><li>For any kernel version x.y.z, </li></ul></ul><ul><ul><li>* x - This is the major revision number </li></ul></ul><ul><ul><li>* y - This is the minor revision number, where: </li></ul></ul><ul><ul><li>Even numbers indicate &quot;stable&quot; kernel releases </li></ul></ul><ul><ul><li>Odd numbers indicate &quot;development&quot; or &quot;beta&quot; kernel releases which may be less stable. </li></ul></ul><ul><ul><li>* z - This is the patch level of the kernel </li></ul></ul>
  7. 7. <ul><li>Downloading the maintainer-specific patch. </li></ul><ul><li>Unpacking the kernel source </li></ul><ul><ul><ul><li>bash$ cd $HOME </li></ul></ul></ul><ul><ul><ul><li>bash$ tar zxvf linux-x.y.z.tar.gz </li></ul></ul></ul><ul><ul><ul><li>bash$ cd linux-x.y.z </li></ul></ul></ul><ul><ul><ul><li>bash$ zcat ../patch-x.y.z-vrs1.gz | patch -p1 </li></ul></ul></ul><ul><li>For Cross compilation </li></ul><ul><ul><ul><ul><li>linux/README and linux/Documentation/arm/README before proceeding. Both these files provide further useful information which may be specific to your kernel version. </li></ul></ul></ul></ul>
  8. 8. Configuration of the kernel build environment <ul><li>To use the default configuration present in kernel source </li></ul><ul><ul><ul><ul><li>bash$ make <machinename>_defconfig </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><li>Copies the config of /linux-2.6-2.6.32/arch/x86/configs/i386_defconfig to .config </li></ul></ul></ul></ul></ul></ul><ul><ul><ul><ul><li>In this case no need to run oldconfig </li></ul></ul></ul></ul><ul><li>To do manual configuration run the command </li></ul><ul><ul><ul><ul><li>$make menuconfig </li></ul></ul></ul></ul>
  9. 9. Example for configuration <ul><li>Selecting necessary file systems </li></ul><ul><ul><li>File systems ---> </li></ul></ul><ul><ul><li>Pseudo Filesystems ---> </li></ul></ul><ul><ul><li>[*] /proc file system support </li></ul></ul><ul><ul><li>[*] Virtual memory file system support (former shm fs) </li></ul></ul><ul><ul><li>(Select one or more of the following options as needed by your system) </li></ul></ul><ul><ul><li>Reiser, ext3, ext4, jfs, etc., </li></ul></ul>
  10. 10. Selecting PPPoE necessary drivers <ul><li>Device Drivers ---> Networking Support ---> <*> PPP (point-to-point protocol) support </li></ul><ul><li><*> PPP support for async serial ports </li></ul><ul><li><*> PPP support for sync tty ports </li></ul>
  11. 11. Activating SMP support <ul><li>Processor type and features ---> [*] Symmetric multi-processing support </li></ul><ul><li>Like that we can do for the following options </li></ul><ul><ul><li>Activating USB Support for Input Devices </li></ul></ul><ul><ul><li>Enabling PCMCIA support </li></ul></ul>
  12. 12. Manual Installation <ul><li>Compiling the kernel </li></ul><ul><ul><ul><li>Make </li></ul></ul></ul><ul><ul><ul><li>Make modules_install </li></ul></ul></ul><ul><li>Installing the kernel </li></ul><ul><ul><ul><li>cp arch/i386/boot/bzImage /boot/vmlinuz </li></ul></ul></ul><ul><ul><ul><li>Generate the initrd by using the tool mkinitrd </li></ul></ul></ul><ul><ul><ul><ul><li>mkinitramfs -k -o /boot/initrd.img-KVN KVN </li></ul></ul></ul></ul><ul><li>Edit the grub.cfg & boot the kernel </li></ul>
  13. 13. To get the kernel in DEB <ul><li>make-kpkg --initrd --revision=boss4.0 kernel_image kernel_headers --us –uc </li></ul><ul><ul><ul><ul><li>--append-to-version </li></ul></ul></ul></ul><ul><ul><ul><ul><li>--revision </li></ul></ul></ul></ul>
  14. 14. SELinux <ul><li>Configure </li></ul><ul><li>Compile as like normal kernel </li></ul><ul><li>Edit the /etc/init.d/rc </li></ul><ul><li>Add the parameter selinux=1 to kernel line of grub </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.