Compiling a Linux Kernel (Ubuntu)

45 minutes
  • 5 Learning Objectives

About this Hands-on Lab

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.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Enable source URIs for apt repositories.
  1. Open the sources.lst file in /etc/apt/:

    vim /etc/apt/sources.lst
  2. Uncomment deb-src URIs manually or by substitution — :%s/# deb-src/deb-src/g

  3. Resynchronize the package index files:

    apt-get update
Install dependencies
  1. Install additional dependencies:
    apt-get install -y make gcc libncurses5-dev dpkg-dev
  2. Build dependencies for the kernel image:
    apt-get build-dep -y linux-image-$(uname -r)
Download the Kernel source tree to /usr/src
  1. Switch to the /usr/src directory:
    cd /usr/src/
  2. Download the kernel source tree:
    apt-get source linux-image-$(uname -r)
Update the kernel configuration
  1. Switch to the kernel source tree directory:
    cd /usr/src/linux-aws-[kernel_version]/
  2. Update the kernel configuration with the make menuconfig command:
    make menuconfig
  3. Navigate with your arrow keys and use enter to go to Device Drivers > Block devices
  4. Using the “n” key, exclude the following two drivers – DRBD Distributed Replicated Block Device support and Packet writing on CD/DVD media (DEPRECATED)
  5. Exit the menu and save your configuration changes.
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

Additional Resources

As one of the lead Linux administrators on your team, you are tasked with compiling a new kernel image that will be used for all of the servers in your data center. In order to accomplish this, you will need to enable the deb-src URIs to allow the kernel source to be downloaded. Once the kernel source has been downloaded (ensure that it is downloaded to the /usr/src directory for consistency), you will need to install any dependencies that are necessary for configuring and compiling the kernel. The Distributed Replicated Block Device (DRBD) support should be excluded since your company will no longer be using this utility. In addition to DRBD, the Packet writing on CD/DVD media should also be excluded, given that it is now deprecated. Once these configuration changes have been made, compile a new compressed kernel image using the bzImage target.

Note: All tasks should be performed as the root user.

What are Hands-on Labs

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.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!