Thursday 3 September 2015

How to Compile the Linux Kernel

The Linux kernel is the heart of any Linux system. It handles user input/output, hardware, and controlling the power in the computer. While the kernel that comes with your Linux distribution is usually sufficient, this allows you to make your owns specialized kernel!
Ad

Steps

  1. Compile the Linux Kernel Step 1.jpg


    Download the latest version of the Linux kernel from http://www.kernel.org.
    Ad
  2. Compile the Linux Kernel Step 2.jpg
    2
    Be sure to download the full source by clicking on the "F" where it says "The latest stable version is..." otherwise you'll just download the patch, which is used when your current kernel is a patch number lower. An example of this would be 3.4.4.1>>3.4.4.2
  3. Compile the Linux Kernel Step 3.jpg
    3
    Make sure you have downloaded the complete source code, and not a patch or change log.
  4. Compile the Linux Kernel Step 4.jpg
    4
    Once downloaded, open a terminal.
  5. Compile the Linux Kernel Step 5.jpg
    5
    Now we need to extract the kernel. Use these commands.
    • tar xjvf kernel (Here -j option is for bz2 compression)
  6. Compile the Linux Kernel Step 6.jpg
    6
    Once extracted, move into the directory (in the terminal) that was created.
  7. Compile the Linux Kernel Step 7.jpg
    7
    Configure the kernel. There are 4 common ways to do this.
    • Make old configuration -- asks you questions on what the kernel should support one by one, very time consuming.
    • Make menuconfig -- creates a menu where you can browse options on what the kernel supports. Requires curses library, but that is likely already on your computer.
    • Make qconfig/xconfig/gconfig -- same as menuconfig, except that now the configuration menu is graphics based."qconfig" Requires the QT library.
    • Use configuration of current kernel. Run this from your kernel source folder "cp /boot/config-`uname -r` .config". This saves a lot of time, but you may want to change version number of the to be compiled kernel to avoid replacing your current kernel. "General setup" --> "Local version - append to kernel release". Example if the kernel version number is 3.13.0, you can example write there 3.13.0.RC1.
  8. Compile the Linux Kernel Step 8.jpg
    8
    Once the configuration window is opened, you will see that a specific type of configuration is already selected like support for essential drivers like Broadcom wireless support/EXT4 filesystem etc. Further, you may customize the options like adding support for your specific type of device/controller/driver like you may add support for NTFS file system from "Filesystem >> DOS/FAT/NT/ >> select NTFS file system support, thereby taking full advantage of custom kernel.
  9. Compile the Linux Kernel Step 9.jpg
    9
    NOTE: While configuring the kernel, you will see a section known as kernel hacking(by hacking we mean exploring into it), where different types of options are given for hacking into kernel and learning it. If you want to use it then you may add further options, otherwise you may disable the option "kernel debugging", as it makes the kernel a lot heavier and and may be improper to use in the production environment.
  10. Compile the Linux Kernel Step 10.jpg
    10
    Once configured, it is time to compile and install the kernel. You can run needed commands in one line by separating them with double ampersands (&&) as written below. This may take a long time.
    • make && make modules_install && make install
    • You may want to use -j option with make. This allows to fork additional processes for compiling kernel, syntax would be "make -j 3". 3 here represents the number of processes to be created.
  11. Compile the Linux Kernel Step 11.jpg
    11
    So the kernel is installed, but you need to make it bootable.
  12. Compile the Linux Kernel Step 12.jpg
    12
    Go to boot.
  13. Compile the Linux Kernel Step 13.jpg
    13
    Run this command "mkinitrd -o initrd.img-<kernelversion> <kernelversion>" (For Redhat based distros, you need not create initrd, as it is created by default) remembering to replace <kernelverison> with the version number of the kernel you build.
  14. Compile the Linux Kernel Step 14.jpg
    14
    Point the boot loader at the new kernel so it can be started. Use the tool that came with your distro to configure your bootloader. Add a new entry for the new kernel.
  15. Compile the Linux Kernel Step 15.jpg
    Edit step
    15
    Reboot and enjoy your customized kernel!
     
    -by http://www.wikihow.com

1 comment:

  1. This amazing appears to be altogether recommended. Each smallish data are intended and also massive amount back ground awareness. I prefer this unique very much. Minimalist Logo

    ReplyDelete

Thank You!!!

create and activate a Python virtual environment on macOS and Windows

create and activate a Python virtual environment on macOS and Windows: Prerequisites: Python 3: Ensure you have Python 3 installed. You ca...