View Feed
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12758 Members
Join this group to post and comment.
Jasim Chouhan
Jasim Chouhan • Nov 5, 2015

What tools are essential for building a new linux kernel?

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
Abhishek Rawal
Abhishek Rawal • Nov 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 The Linux Kernel Archives and download the tarball of the kernel version you want. Here, I will use latest stable 4.3
wget -c
4) Verify kernel sig from Linux kernel releases PGP signatures [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 

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
 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 GCC patch for CPU optimization, you'll see performance improvement with your new optimized kernel.

If you're stuck somewhere, feel free to ask queries. Cheers.
Jasim Chouhan
Jasim Chouhan • Nov 6, 2015
Thank you Abhishiek, you give me a lot of about linux kernel and now i am confident ,thanks again

Share this content on your social channels -