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.
Open the sources.lst file in
/etc/apt/
:vim /etc/apt/sources.lst
Uncomment
deb-src
URIs manually or by substitution —:%s/# deb-src/deb-src/g
Resynchronize the package index files:
apt-get update
- Install dependencies
- Install additional dependencies:
apt-get install -y make gcc libncurses5-dev dpkg-dev build-essential bison flex libssl-dev libelf-dev
- Install additional dependencies:
- Download the Kernel source tree to /usr/src
- Switch to the
/usr/src
directory:cd /usr/src/
- Download the kernel source tree:
apt-get install -y linux-source kernel-package
- Select the following option:
keep the local versions currently installed
- Switch to the
- Update the kernel configuration
- 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]/
- Get the necessary packages
apt-get build-dep -y linux-source mkdir debian/stamps
- Update the kernel configuration with the
make menuconfig
command:cp /boot/config-$(uname -r) .config yes '' | make oldconfig make menuconfig
- Navigate with your arrow keys and use enter to go to
Device Drivers
>Block devices
- Using the “n” key, exclude the following two drivers –
DRBD Distributed Replicated Block Device support
andPacket writing on CD/DVD media (DEPRECATED)
- Exit the menu and save your configuration changes.
- Prepare to compile the Kernel:
make clean
- Switch to the kernel source tree directory and extract the archive:
- Compile the kernel image (this step can take 15-20 minutes to complete)
- Create the compressed kernel image by calling the bzImage target:
make bzImage
Note: This can take 15-20 minutes to complete
- Create the compressed kernel image by calling the bzImage target: