Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Compiling a Linux Kernel (Ubuntu)

For most Linux administrators, updating a kernel is done through the package manager for the Linux distribution that is being used. However, there can be situations where a particular kernel version or specific kernel configurations are needed. In this lab, you will be tasked with downloading the full kernel source tree, updating the kernel configuration to certain specifications, and then compiling a new kernel image.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Published
Clock icon Apr 03, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Enable source URIs for apt repositories.

    1. Open the sources.lst file in /etc/apt/:
    vim /etc/apt/sources.lst
    
    1. Uncomment deb-src URIs manually or by substitution — :%s/# deb-src/deb-src/g

    2. Resynchronize the package index files:

    apt-get update
    
  2. Challenge

    Install dependencies

    1. Install additional dependencies:
    apt-get install -y make gcc libncurses5-dev dpkg-dev build-essential bison flex libssl-dev libelf-dev
    
  3. Challenge

    Download the Kernel source tree to /usr/src

    1. Switch to the /usr/src directory:
    cd /usr/src/
    
    1. Download the kernel source tree:
    apt-get install -y linux-source kernel-package
    
    1. Select the following option:
    keep the local versions currently installed
    
  4. Challenge

    Update the kernel configuration

    1. Switch to the kernel source tree directory and extract the archive:
    cd /usr/src/linux-source-[kernel_version]
    tar jxvf linux-source-[kernel_version].tar.bz2
    mv linux-source-[kernel_version]/* .
    rm -rf ./linux-source-[kernel_version]/
    
    1. Get the necessary packages
    apt-get build-dep -y linux-source
    mkdir debian/stamps
    
    1. Update the kernel configuration with the make menuconfig command:
    cp /boot/config-$(uname -r) .config
    yes '' | make oldconfig
    make menuconfig
    
    1. Navigate with your arrow keys and use enter to go to Device Drivers > Block devices
    2. Using the “n” key, exclude the following two drivers - DRBD Distributed Replicated Block Device support and Packet writing on CD/DVD media (DEPRECATED)
    3. Exit the menu and save your configuration changes.
    4. Prepare to compile the Kernel:
    make clean
    
  5. Challenge

    Compile the kernel image (this step can take 15-20 minutes to complete)

    1. Create the compressed kernel image by calling the bzImage target:
    make bzImage
    

    Note: This can take 15-20 minutes to complete

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans