Kernel Configuration and Build
Kernel configuration and build
In Last chapter we have got overview of Linux kernel Architecture and basic subsystems of Linux kernel. Now question arise from where to get the kernel and how to build it.
Download Linux Kernel :-
Linux kernel is open source and maintained by Linux kernel community . Every member of this community keep on working on enhancement of Kernel. This community maintain kernel repository on https://www.kernel.org/ . Every contributor of Linux kernel updates there changes on this mainline kernel so that other can get the update kernel. We can get Latest kernel from this site anytime without paying any charge for it.
Download kernel from:
From Kernel.org we get tar file of Linux kernel. So after downloading Linux kernel first job we need to do it untar the Kernel by following command
tar -xvf kernel_name.tar.xz
configure Linux kernel:-
Kernel which we get from Kernel.org is generic kernel which we can build and flash on different hardware platform . But before building Linux kernel we need to customize the kernel or we can say we need to do some platform specific changes to port our Linux kernel on out hardware platform.
For configuring the kernel go into root directory of Kernel’s untar folder and use one of the following way of configuring kernel.
Linux kernel provides us various way of configuring the Kernel. Following are some method to configure the kernel
1) make config
2) make menuconfig
make config is a character based questions answers session method in which kernel start asking character based question like whether to enable a particular setting or setting or not. We have to answer according to our requirement.
2) make menuconfig
It’s a graphical view of configuring kernel. when we run above command we get a GUI on which we can see multiple kernel settings. For having this GUI we should have ncurses library installed in our system . If we don’t have this installed in our system we might come across following error
Solution to fix this Error:
download and install following library to fix this issue
- $ sudo apt-get update
- $ sudo apt-get install libncurses5-dev
after doing above step make menu config will run successfully and below screen appear.
3) make defconfig
When we download kernel form kernel.org , kernel comes with default configuration which is set by kernel maintainer. To create this default configuration give below command
$ make defconfig
Build Linux Kernel
As now we have done the basic setting required for building kernel. Now final step is to build the kernel. Below are the steps to build linux kernel
1) Go to root directory of Untar folder
2) Give Make command
If our PC has multi core then we can use below command to improve the speed of kernel build.
here specify number of cores available present plus 1. by using this command we are forcing to use all the available cores for building the Kernel.
Excellent blog post. I definitely appreciate this site.