CrazyEngineers
  • What tools are essential for building a new linux kernel?

    Jasim Chouhan

    Jasim Chouhan

    @jasim-g7mjUs
    Updated: Oct 27, 2024
    Views: 1.4K
    Hello friends
    can i make my own linux kernel for my acadmic project, if yes then what tools are i need and your suggestions.
    Thank you
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Abhishek Rawal

    MemberNov 5, 2015

    1) Linux desktop
    2) Dependencies as follows :
    xmlto, kmod, bc, inetutils, docbook-xsl, coreutils, linux-firmware, mkinitcpio, modeprobed-db, make, base-devel, libncurses, libncurses-devel
    3) Go to <a href="https://www.kernel.org/" target="_blank" rel="nofollow noopener noreferrer">The Linux Kernel Archives</a> and download the tarball of the kernel version you want. Here, I will use latest stable 4.3
    wget -c #-Link-Snipped-#
    4) Verify kernel sig from <a href="https://www.kernel.org/signature.html#using-gnupg-to-verify-kernel-signatures" target="_blank" rel="nofollow noopener noreferrer">Linux kernel releases PGP signatures</a> [Optional but smart thing to do]
    5) mkdir -p mykernel
    6) cp linux-4.3.tar.xz ~/mykernel/
    7) tar -xvJf linux-4.3.tar.xz
    8) cd linux-4.3
    9) make mrproper (to verify kernel tree is clean or not)

    This was all basic and simple task, crucial part is build configuration. However, since you're new into this, I won't recommend configuring trimmed version of linux kernel as per your system. Rather than you can use .config from your running kernel.

    zcat /proc/config.gz > running.config
    Actually, if you wanna try making your own config simply cd into kernel directory and type :
    make nconfig
    (Modern approach)
     make menu-config 
    (Traditional)

    Now configure it as per your requirement, remember this will generate new .config.

    The compilation time varies from 10 minutes to hours, depending on the system on which you're compiling and the make flags you're using. You can even move directory to tmpfs to reduce compiling time.

    Now, run
     make 
     sudo make modules_install 
    You'll able to see compiled modules in /lib/modules/yourkernel directory

    Now, copy the kernel to /boot directory and make initial RAM disk
    mkinitcpio -k skynetkernel -c /etc/mkinitcpio.conf -g /boot/initramfs-skynetkernel.img
    Note : You can change 'skynetkernel' to anything you want. I love cybernetic organism so I use skynet.

    Joke apart, now update the grub and reboot and see if your own compiled linux is working properly or not.
    When you use prebuilt kernel's .config, it actually works out of box, but that's not why we compile kernel, do we ?
    Making your own .config according to your hardware and purging the unnecessary modules will make slimmed down version of kernel will make an impact.

    On side note,apply this <a href="https://github.com/graysky2/kernel_gcc_patch" target="_blank" rel="nofollow noopener noreferrer">GitHub - graysky2/kernel_gcc_patch: legacy name with info to new name</a>, you'll see performance improvement with your new optimized kernel.

    If you're stuck somewhere, feel free to ask queries. Cheers.
    Are you sure? This action cannot be undone.
    Cancel
  • Jasim Chouhan

    MemberNov 5, 2015

    Thank you Abhishiek, you give me a lot of about linux kernel and now i am confident ,thanks again
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register