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:
|Tracks and makes a record of all changes during development in the source code. It also allows reverting the changes.|
|Packaging tool that makes the fake root environment for building kernel.|
|Installs development tools such as C, C++, gcc, and g++.|
|Programming library that provides API for the text-based terminals.|
|Provides fast file compression and decompression.|
|Supports SSL and TSL that encrypt data and make the internet connection secure.|
|A mathematical scripting language that supports the interactive execution of statements.|
|Generates lexical analyzers that convert characters into tokens.|
|Issues a shared library for managing ELF files (executable files, core dumps and object code)|
|GNU parser generator that converts grammar description to a C program.|
Step 4: Configure Kernel ;
1. Navigate to the linux-5.9.6. directory using the
Or Navigate Trough File Manager;
2. Copy the existing configuration file using the
cp -v /boot/config-$(uname -r) .config
3. To make changes to the configuration file, run the
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.
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.
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.