phoenixnap.com Open in urlscan Pro
2606:4700:10::ac43:eba  Public Scan

URL: https://phoenixnap.com/kb/build-linux-kernel
Submission: On February 17 via api from US — Scanned from DE

Form analysis 3 forms found in the DOM

GET https://phoenixnap.com/kb/

<form role="search" method="get" id="searchform" class="searchform" action="https://phoenixnap.com/kb/">
  <div> <label class="screen-reader-text" for="s">Search for:</label> <input type="text" value="" name="s" id="s"> <input type="submit" id="searchsubmit" value="Search"> </div>
</form>

GET https://phoenixnap.com/kb/

<form class="searchform-wrapper-modal" id="searchform" method="get" action="https://phoenixnap.com/kb/">
  <input type="text" class="search-field-modal" name="s" placeholder="Search..." value="" autofocus="">
  <input type="submit" id="submit-button-modal" class="submit-button-modal" value="Search">
  <div id="innericon-modal" class="innericon-modal">
    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="22px" height="28px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
      <path id="magnifier-2-icon"
        d="M460.355,421.59L353.844,315.078c20.041-27.553,31.885-61.437,31.885-98.037                    C385.729,124.934,310.793,50,218.686,50C126.58,50,51.645,124.934,51.645,217.041c0,92.106,74.936,167.041,167.041,167.041                    c34.912,0,67.352-10.773,94.184-29.158L419.945,462L460.355,421.59z M100.631,217.041c0-65.096,52.959-118.056,118.055-118.056                    c65.098,0,118.057,52.959,118.057,118.056c0,65.096-52.959,118.056-118.057,118.056C153.59,335.097,100.631,282.137,100.631,217.041                    z">
      </path>
    </svg>
  </div>
</form>

GET https://phoenixnap.com/kb/

<form class="searchform-wrapper-modal" id="searchform" method="get" action="https://phoenixnap.com/kb/">
  <input type="text" class="search-field-modal" name="s" placeholder="Search..." value="">
  <button type="submit" id="submit-button" class="submit-button-modal" value="">
    <div id="innericon" class="innericon-modal">
      <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="22px" height="28px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
        <path id="magnifier-2-icon"
          d="M460.355,421.59L353.844,315.078c20.041-27.553,31.885-61.437,31.885-98.037                    C385.729,124.934,310.793,50,218.686,50C126.58,50,51.645,124.934,51.645,217.041c0,92.106,74.936,167.041,167.041,167.041                    c34.912,0,67.352-10.773,94.184-29.158L419.945,462L460.355,421.59z M100.631,217.041c0-65.096,52.959-118.056,118.055-118.056                    c65.098,0,118.057,52.959,118.057,118.056c0,65.096-52.959,118.056-118.057,118.056C153.59,335.097,100.631,282.137,100.631,217.041                    z">
        </path>
      </svg>
    </div>
  </button>
</form>

Text Content

 * Call
   * Support
   * Sales
 * Login
   * Bare Metal Cloud
   * Channel Partners
   * Billing Portal
 * Partners

 * PHOENIXNAP HOME
 * PRODUCTS
   * Colocation
     Premier Carrier Hotel
     * Colocation
       Overview
     * Data Center as a Service
       Solutions for Digital Transformation
     * Hardware as a Service
       Flexible Hardware Leasing
     * Meet-Me Room
       The Interconnectivity Hub
     * Schedule a Tour
       Guided Virtual Data Center Tour
     * Data Center Locations
       Global Data Center Footprint
   * Bare Metal Cloud
     API-Driven Dedicated Servers
     * Platform
       Overview
     * Rancher Deployment
       One-Click Kubernetes Deployment
     * Intel Xeon E-2300
       Entry-Level Servers
     * 4th Gen Intel Xeon Scalable CPUs
       Boost Data-Intensive Workloads
     * Alliances
       Technology Partnerships
     * Object Storage
       S3-Compatible Storage Solution
   * Dedicated Servers
     Single-Tenant Physical Machines
     * Dedicated Servers
       Overview
     * FlexServers
       Vertical CPU Scaling
     * Intel Xeon-E Servers
       Intel Xeon 2200 Microarchitecture
     * GPU Servers
       Servers with NVIDIA Tesla GPUs
     * Dedicated Servers vs. BMC
       Compare Popular Platforms
     * Promotions
       See Available Discounts
     * Buy Now
       See All Servers
   * Cloud
     Custom Cloud Solutions
     * Managed Private Cloud (MPC)
       Highly Customizable Cloud
     * Data Security Cloud
       Secure-By-Design Cloud
     * Hybrid Cloud
       Multi-Platform Environment
     * Edge Computing
       Globally Distributed Servers
     * Object Storage
       S3 API Compatible Storage Service
     * Bare Metal Cloud
       API-Driven Dedicated Servers
     * Alternative Cloud Provider
       Overcome Public Cloud Limitations
   * Backup & Restore
     Backup and DRaaS
     * Backup Solutions
       Veeam-Powered Services
     * Disaster Recovery
       VMware, Veeam, Zerto
     * Veeam Cloud Connect
       Backup and Replication
     * Managed Backup for Microsoft 365
       Veeam-Powered Service
   * Security
     Security Services
     * Data Security Cloud
       Secure-by-Design Cloud
     * Encryption Management Platform (EMP)
       Cryptographic Key Management
     * Confidential Computing
       Data-in-Use Encryption
     * Ransomware Protection
       Data Protection and Availability
     * DDoS Protection
       Network Security Features
 * CONTACT SUPPORT
 * NETWORK
   * Network Overview
     Global Network Footprint
   * Network Locations
     U.S., Europe, APAC, LATAM
   * Speed Test
     Download Speed Test
 * LEARN
   * Blog
     IT Tips and Tricks
   * Glossary
     IT Terms and Definitions
   * Resource Library
     Knowledge Resources
   * Events
     Let's Meet!
   * Newsroom
     Media Library
   * Developers
     Development Resources Portal
   * APIs
     Access Our Public APIs
   * GitHub
     Public Code Repositories
 * Search for:




HOW TO BUILD LINUX KERNEL FROM SCRATCH {STEP-BY-STEP GUIDE}

November 12, 2020
commandskernellinux



Home » SysAdmin » How to Build Linux Kernel From Scratch {Step-By-Step Guide}

Contents
 1. Building Linux Kernel
    1. Step 1: Download the Source Code
    2. Step 2: Extract the Source Code
    3. Step 3: Install Required Packages
    4. Step 4: Configure Kernel
    5. Step 5: Build the Kernel
    6. Step 6: Update the Bootloader (Optional)
    7. Step 7: Reboot and Verify Kernel Version

Contents
 1. Building Linux Kernel
    1. Step 1: Download the Source Code
    2. Step 2: Extract the Source Code
    3. Step 3: Install Required Packages
    4. Step 4: Configure Kernel
    5. Step 5: Build the Kernel
    6. Step 6: Update the Bootloader (Optional)
    7. Step 7: Reboot and Verify Kernel Version

Introduction

The Linux Kernel is the foundation of all the Linux distributions. The kernel is
responsible for communication between hardware and software and the allocation
of available resources.

All Linux distributions are based on a predefined kernel. But, if you want to
disable certain options and drivers or try experimental patches, you need to
compile your own Linux kernel.

In this step-by-step guide, you will learn how to build and compile a Linux
kernel from scratch.



Prerequisites

 * A system running Linux
 * Access to the terminal/command line
 * A user account with sudo/root privileges
 * 12GB of available space on the hard drive


BUILDING LINUX KERNEL

The process of building a Linux kernel can be performed in seven easy steps.
However, the procedure may require a significant amount of time to complete,
depending on the system speed.

Follow the steps below to build the latest Linux kernel.

Note: If the latest kernel version on the official website does not match the
one mentioned in the steps below, replace the version number in the commands
with the current latest version.


STEP 1: DOWNLOAD THE SOURCE CODE

1. Visit the official kernel website and download the latest kernel version. The
downloaded file contains a compressed source code.



2. Open the terminal and use the wget command to download the Linux kernel
source code:

wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.0.7.tar.xz

The output shows the “saved” message when the download completes.



Note: Learn what to do when you get wget: command not found error.


STEP 2: EXTRACT THE SOURCE CODE

When the file is ready, run the tar command to extract the source code:

tar xvf linux-6.0.7.tar.xz

The output displays the extracted kernel source code:




STEP 3: INSTALL REQUIRED PACKAGES

Install additional packages before building a kernel. To do so, 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:

PackagePackage descriptiongitTracks and makes a record of all changes during
development in the source code. It also allows reverting the
changes.fakerootCreates the fake root environment.build-essentialInstalls
development tools such as C, C++, gcc, and g++.ncurses-devProvides API for the
text-based terminals.xz-utilsProvides fast file compression and file
decompression.libssl-devSupports SSL and TSL that encrypt data and make the
internet connection secure.bc (Basic Calculator)Supports the interactive
execution of statements.flex (Fast Lexical Analyzer Generator)Generates lexical
analyzers that convert characters into tokens.libelf-devIssues a shared library
for managing ELF files (executable files, core dumps and object
code)bisonConverts grammar description to a C program.




STEP 4: CONFIGURE KERNEL

The Linux kernel source code comes with the default configuration. However, you
can adjust it to your needs. To do so, follow the steps below:

1. Navigate to the linux-6.0.7 directory using the cd command:

cd linux-6.0.7

2. Copy the existing Linux config 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

The command launches several scripts that open the configuration menu:



4. The configuration menu includes options such as firmware, file system,
network, and memory 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 are unsure what to change, leave the default settings.


STEP 5: BUILD THE KERNEL

1. Start building the kernel by running the following command:

make

The process of building and compiling the Linux kernel takes some time to
complete.

The terminal lists all Linux kernel components: memory management, hardware
device drivers, filesystem drivers, network drivers, and process management.



If you are compiling the kernel on Ubuntu, you may receive the following error
that interrupts the building process:

No rule to make target 'debian/canonical-certs.pem

Disable the conflicting security certificates by executing the two commands
below:

scripts/config --disable SYSTEM_TRUSTED_KEYS

scripts/config --disable SYSTEM_REVOCATION_KEYS

The commands return no output. Start the building process again with make, and
press Enter repeatedly to confirm the default options for the generation of new
certificates.

2. Install the required modules with this command:

sudo make modules_install



3. Finally, install the kernel by typing:

sudo make install 

The output shows done when finished:




STEP 6: UPDATE THE BOOTLOADER (OPTIONAL)

The GRUB bootloader is the first program that runs when the system powers on.

The make install command performs this process automatically, but you can also
do it manually.

1. Update the initramfs to the installed kernel version:

sudo update-initramfs -c -k 6.0.7

2. Update the GRUB bootloader with this command:

sudo update-grub

The terminal prints out the process and confirmation message:




STEP 7: REBOOT AND VERIFY KERNEL VERSION

When you complete the steps above, reboot the machine.

When the system boots up, verify the kernel version using the uname command:

uname -mrs

The terminal prints out the current Linux kernel version.



Conclusion

In this step-by-step guide, you learned how to build a Linux kernel from scratch
and install the required packages.

If you follow the instructions carefully, the process will complete successfully
on your Linux machine.

The Linux kernel has a modular design. Functionality is extendible with modules
or drivers. Learn how to use the modprobe command to add or remove modules on
Linux.

Next, learn how to update the Linux kernel in Ubuntu.

Was this article helpful?
YesNo

Share on X (Twitter) Share on Facebook Share on LinkedIn Share on Email
Goran Jevtic
Goran combines his leadership skills and passion for research, writing, and
technology as a Technical Writing Team Lead at phoenixNAP. Working with multiple
departments and on various projects, he has developed an extraordinary
understanding of cloud and virtualization technology trends and best practices.
Next you should read
SysAdmin Web Servers
How to Remove Old Kernels on Ubuntu 16.04, 18.04, & 19.04
March 11, 2020

--------------------------------------------------------------------------------

There are several methods to remove old or unused kernels. It's also considered
good system hygiene practice...
Read more
SysAdmin Web Servers
How to Upgrade Linux Kernel in CentOS 7
October 8, 2019

--------------------------------------------------------------------------------

The Linux kernel is the underlying software architecture of each Linux
distribution. It provides and defines...
Read more
DevOps and Development SysAdmin
How to Uninstall or Remove Software Packages From Ubuntu
September 4, 2019

--------------------------------------------------------------------------------

This guide will walk you through several methods for removing old software from
Ubuntu...
Read more
Security SysAdmin
How to Check Kernel Version in Linux in Command Line
June 25, 2019

--------------------------------------------------------------------------------

The Linux kernel is much like the central brain of the operating system.
Although it is open-source, meaning...
Read more

RECENT POSTS
 * docker commit Explained {With Examples}
 * How to Use wget Command With Examples
 * How to Fix "Access denied for user root@localhost" MySQL Error
 * How to Migrate CentOS to AlmaLinux
 * How to Extract or Unzip .tar.gz Files in Linux

CATEGORIES
 * SysAdmin
 * Virtualization
 * DevOps and Development
 * Security
 * Backup and Recovery
 * Bare Metal Servers
 * Web Servers
 * Networking
 * Databases

COLOCATION
 * Phoenix
 * Ashburn
 * Amsterdam
 * Atlanta
 * Belgrade
 * Singapore

PROMOTIONS
SERVERS
 * Dedicated Servers
 * Database Servers
 * Virtualization Servers
 * High Performance Computing (HPC) Servers
 * Dedicated Streaming Servers
 * Dedicated Game Servers
 * Dedicated Storage Servers
 * SQL Server Hosting
 * Dedicated Servers in Amsterdam
 * Cloud Servers in Europe
 * Big Memory Infrastructure

BUY NOW
CLOUD SERVICES
 * Data Security Cloud
 * VPDC
 * Managed Private Cloud
 * Object Storage

SERVERS
 * Disaster Recovery
 * Web Hosting Reseller
 * SaaS Hosting

INDUSTRIES
 * Web Hosting Providers
 * Legal
 * MSPs & VARs
 * Media Hosting
 * Online Gaming
 * SaaS Hosting Solutions
 * Ecommerce Hosting Solutions

COMPLIANCE
 * HIPAA Ready Hosting
 * PCI Compliant Hosting

NEEDS
 * Disaster Recovery Solutions
 * High Availability Solutions
 * Cloud Evaluation

COMPANY
 * About Us
 * GitHub
 * Blog
 * RFP Template
 * Careers

CONNECT
 * Events
 * Press
 * Contact Us

 * PhoenixNAP Home
 * Blog
 * Resources
 * Glossary
 * GitHub
 * RFP Template


 *  Live Chat
 *  Get a Quote
 *  Support | 1-855-330-1509
 *  Sales | 1-877-588-5918


 * Contact Us
 * Legal
 * Privacy Policy
 * Terms of Use
 * DMCA
 * GDPR
 * Sitemap

Privacy Center Do not sell or share my personal information
 * Contact Us
 * Legal
 * Privacy Policy
 * Terms of Use
 * DMCA
 * GDPR
 * Sitemap

©2024 Copyright phoenixNAP | Global IT Services. All Rights Reserved.
Live Chat ↗


searchtwitterfacebooklinkedinchevron-circle-upyoutube-playinstagram