Linux Tactic

Upgrading Your Debian 9 Stretch Kernel: A Step-by-Step Guide

Upgrading the Kernel of Debian 9 Stretch

If you’re a Linux user, you’re aware that the kernel is the core of the operating system. Upgrading the kernel can improve system performance, security, and add new features.

Debian 9 Stretch uses Kernel version 4.9.0-3-amd64 as the default. However, sometimes, you may want to use a newer kernel to take advantage of its latest features.

This article will guide you through the process of upgrading the kernel of Debian 9 Stretch.

Checking the Installed Kernel Version

Before upgrading your kernel, you must first check the current version running on your system. It’s recommended to write the old kernel’s version for future reference.

To check for the installed kernel version, open a terminal and execute the following command:

`uname -r`

This command outputs the current running kernel version. In this case, the current running kernel version is 4.9.0-3-amd64.

Downloading the Kernel

Once you confirm that you’re running an older kernel, it’s time to download the latest kernel source code. You can download the kernel from the official Linux kernel website.

It’s best to download the stable release or the longterm release. The mainline release can be a bit unstable.

Always download the kernel that corresponds to your Debian version. In this case, we’re working with Debian 9, so we’ll download the kernel 4.14.7 source file.

The official Linux kernel website compresses the source file into a tar.xz archive.

Installing Required Tools

Before compiling the kernel, first, install the required packages for kernel compilation. You can install them using the following command:

`sudo apt-get install build-essential libncurses5-dev fakeroot`

The above command installs the packages required for kernel compilation, including the compiler and dependencies.

Compiling the Kernel

Once you’ve installed the required tools, begin the kernel compilation process.

Extracting and Navigating to Kernel Source Directory

Start by navigating to the Downloads directory where you downloaded the tar.xz archive. Extract the archive using the following command:

`tar -xf linux-4.14.7.tar.xz`

This command extracts the source directory named `linux-4.14.7` in the Downloads directory.

Navigate to the source directory using the following command:

`cd linux-4.14.7`

Copying the Boot Configuration

Copying the boot configuration from the current kernel to the new kernel ensures it boots correctly. Execute the following command in the terminal.

`cp /boot/config-4.9.0-3-amd64 .config`

The above command copies the boot configuration file of the current kernel to the new kernel configuration file.

Converting Old Configuration File to a New One

Next, convert the old configuration to a new one using the following command:

`make menuconfig`

This command opens a window that allows you to modify the kernel configuration. You can use this window to add or remove kernel features and functions.

After completing your changes, save and exit the window.

Starting the Kernel Compilation Process

Start the kernel compilation process using the following command:

`make deb-pkg`

This command will start the kernel compilation process and create the Debian package files.

Generating Debian Package Files

Once the kernel compilation process is complete, you can find the Debian package files (.deb files) in the parent of the source directory. You can know the parent directory by executing the following command:

`ls ..`

If you can see the files, you’ve successfully created the Debian package files.

Updating the Kernel and Checking the Version

Finally, update the kernel to the newer version by installing the kernel using the Debian package files. Install it using the following commands:


sudo dpkg -i ../linux-image-4.14.7_4.14.7-1_amd64.deb

sudo dpkg -i ../linux-headers-4.14.7_4.14.7-1_amd64.deb


The above commands install the kernel image and headers.

After installing, reboot your system with the following command:

`sudo reboot`

Once the system reboots, check if the new kernel is successfully installed by executing the following command:

`uname -r`

The output should show the new kernel’s version.

Preparing the System for Kernel Compilation

Preparing the system for kernel compilation requires installing the necessary packages required for compiling the kernel. If you’re upgrading the kernel, you already have the packages installed.

However, if you’re installing the packages for the first time, execute the following command:

`sudo apt-get install build-essential libncurses5-dev fakeroot`

This command installs the compiler, make, and various other dependent packages essential for kernel compilation.

Final Thoughts

Upgrading the kernel on Debian 9 Stretch helps you keep up with the latest features, improves your system’s performance and security. The procedure may seem complex, but it isn’t that difficult if you follow these steps correctly.

As a Linux user, it’s essential to keep up with the latest updates and upgrade your kernel for maximum performance.

Additional Information

In upgrading your kernel on Debian 9 Stretch, it’s important to choose between stable, longterm, and mainline releases. This decision depends on the required level of stability and the type of computer system you’re working with.

Additionally, adequate disk space is essential for kernel compilation. This section will explore these factors in more detail.

Importance of Choosing Between Stable, Longterm, and Mainline Releases

When it comes to upgrading your kernel, you may have noticed that Linux offers three types of releases: stable, longterm, and mainline.

Stable releases offer the most reliable and stable versions of the Linux kernel, with security updates and bug fixes that ensure the system runs optimally.

As such, stable releases are suitable for production computer systems that require maximum stability. However, it’s worth noting that stable releases don’t necessarily have the latest features.

This is because the Linux community prioritizes stability over regularly updated features. Longterm releases offer a compromise between features and stability.

Longterm releases, unlike stable releases, have a more extended update cycle and provide security updates for a longer period. Longterm releases are ideal for users who want the latest features without sacrificing stability.

This option is suitable for developers or users who want more control over their computer system. Mainline releases are the newest, most up-to-date kernel releases, which contain the latest features.

However, they are not as stable as stable or longterm releases. Therefore, installing mainline releases can result in bugs and crashes, and instability .

As such, mainline releases are not suitable for production computer systems. However, they are excellent for users who want to test the latest features or run on personal machines where downtime is acceptable.

When upgrading your kernel, ensure you understand the different release types and choose the one best suited to your system’s needs.

Importance of Free Disk Space for Kernel Compilation

Kernel compilation can be resource-intensive, which requires enough disk space. One of the most significant issues you may encounter when compiling the kernel is running out of disk space.

When compiling the kernel, large temporary files are temporarily stored that can take up a lot of disk space. Therefore, it’s crucial to free up disk space before starting the kernel compilation process.

It’s also important to note that besides program files, the kernel requires additional space for swap and virtual memory, which the kernel uses as RAM. Therefore, ensure that your computer system has enough virtual memory as it can also impact the kernel compilation process.

A good practice to ensure sufficient disk space is to clean up temporary files, logs, and system caches. Files and directories that can be safely deleted include /tmp, /var/tmp, logs in /var/log, and application caches in /var/cache.

To delete temporary files and system caches, run the following command:

`sudo apt-get clean && sudo apt-get autoclean && sudo apt-get autoremove`

The above command clears the cache and removes packages that aren’t necessary. In conclusion, ensuring adequate disk space is essential for a successful kernel compilation process.

Take the time to free up disk space by cleaning temporary files and system caches, and ensure sufficient virtual memory allocated to your computer system before starting the kernel compilation process. In this article, we explored the process of upgrading the kernel of Debian 9 Stretch.

Checking the installed kernel version, downloading the kernel, installing required tools, compiling the kernel, and updating the kernel were the main steps discussed in detail. Additionally, we discussed the importance of choosing between stable, longterm, and mainline releases and the importance of having sufficient disk space for kernel compilation.

The takeaway is that upgrading the kernel on Debian 9 Stretch is critical to keep up with the latest features, improve system performance and security. Properly choosing the type of kernel release and freeing up adequate disk space is essential for a successful kernel compilation process.

As a Linux user, staying up-to-date with the latest updates and upgrades is crucial for the best performance and system stability.

Popular Posts