Today I’m going to show you in this article How to Build Linux Kernel From Scratch step-by-step, but Before start lets introduce Linux, Linux Kernel is a free open-source solid, secure, performing operating system kernel project created by Linus Torvald in 1991 for his personal computer after Linux kernel Adopted by GNU Project for create a new free open source (as a free swap) operating system against UNIX proprietary operating system. It has generated plenty of working frameworks, a collection of packages (called distribution OS) simply called Linux.
Today we learn, How to Build Linux Kernel From Scratch Step by Step
Requirements for Build Linux Kernel From Scratch ;
- A Computer running Linux (Ubuntu, Fedora, OpenSUSE, etc.)
- A user account with sudo/root privileges
- 15GB of available space on the hard drive
- internet connection and enough free time.
Building and Modifying Linux Kernel ;
we are going to walk behind some easy and some bit technical steps to build the kernel and compile, these processes need a lot of time to finish depending on your system performance and speed of compilation.
Note: If the version on the kernel website does not match the one from the steps below, use these commands and replace the kernel version number.
Step 1: Download the Source Code for www.Kernel.org ;
Step 2: Open Download folder and Extract Linux-x.xx.tar.xz ;
Step 3: Install Required Packages ;
Install required additional packages for building and compiling a Linux kernel. Run this command:
sudo apt-get install git fakeroot build-essential
ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison
The command we used above installs the following packages:
Package | Package description |
git | Tracks and makes a record of all changes during development in the source code. It also allows reverting the changes. |
fakeroot | Packaging tool that makes the fake root environment for building kernel. |
build-essential | Installs development tools such as C, C++, gcc, and g++. |
ncurses-dev | Programming library that provides API for the text-based terminals. |
xz-utils | Provides fast file compression and decompression. |
libssl-dev | Supports SSL and TSL that encrypt data and make the internet connection secure. |
bc (Basic Calculator) | A mathematical scripting language that supports the interactive execution of statements. |
flex (Fast Lexical Analyzer Generator) | Generates lexical analyzers that convert characters into tokens. |
libelf-dev | Issues a shared library for managing ELF files (executable files, core dumps and object code) |
bison | GNU parser generator that converts grammar description to a C program. |
How to Install Mesa Drivers on Ubuntu 20.04 LTS
Step 4: Configure Kernel ;
1. Navigate to the linux-5.9.6. directory using the cd
command:
cd linux-5.9.6
Or Navigate Trough File Manager;
2. Copy the existing configuration file using the cp
command:
cp -v /boot/config-$(uname -r) .config
3. To make changes to the configuration file, run the make
command:
make menuconfig
4. The configuration menu includes options such as firmware, file system, network adapters, and memory settings, drivers settings. Use the arrows to make a selection or choose HELP to learn more about the options. When you finish making the changes, select SAVE, and then exit the menu.
Note: Changing settings for some options can lead to a non-functional kernel. If you don’t know what to exact change, leave the default settings as it is.
How to Install Mate Desktop on Ubuntu Linux
Step 5: Build the Kernel
1. Start building the kernel by running the following command it takes long time to compile so wait till complete process :
2. Install the required modules with this command:
sudo make modules_install
3. Finally, install the kernel by typing:
sudo make install
And Finally You Have to Successfully Done to build your custom kernel from scratch.
Conclusion
In these how-tos tutorial guide, we learned how to build a Linux kernel from scratch and install the required packages.
If you follow the instructions and images carefully, the process will complete successfully on your Linux machine. error or any querries use comment section.
Nice Article, Im always searching for these and finally found correct informatic article about building and recompiling Linux kernel, thank you