UbuntuUbuntu Based

How To Install DKMS on Ubuntu 24.04 LTS

Install DKMS on Ubuntu 24.04

Ubuntu 24.04 LTS, the latest long-term support release, brings a host of improvements and new features to the popular Linux distribution. One essential tool for many Ubuntu users is DKMS (Dynamic Kernel Module Support), a framework that simplifies the management and updating of kernel modules. In this comprehensive guide, we’ll walk you through the process of installing DKMS on Ubuntu 24.04 LTS, explore its benefits, and provide detailed instructions for various scenarios.

Understanding DKMS: Purpose and Benefits

DKMS, short for Dynamic Kernel Module Support, is a framework designed to streamline the process of managing out-of-tree kernel modules. These are modules that are not included in the main Linux kernel source tree. DKMS offers several key advantages:

  • Automatic module rebuilding: When a new kernel is installed, DKMS automatically rebuilds and installs the necessary modules.
  • Simplified updates: Users can update individual kernel modules without changing the entire kernel.
  • Organized management: DKMS provides a structured framework for maintaining and tracking kernel modules.
  • Compatibility assurance: It helps ensure that modules remain compatible across kernel updates.

For Ubuntu 24.04 LTS users, DKMS is particularly valuable as it helps maintain system stability and functionality, especially when using proprietary drivers or custom kernel modules.

Prerequisites for Installing DKMS

Before we dive into the installation process, let’s ensure you have everything needed to successfully install DKMS on your Ubuntu 24.04 LTS system:

  • A system running Ubuntu 24.04 LTS
  • Administrative (sudo) privileges on your account
  • An active internet connection for downloading packages
  • Basic familiarity with the terminal

With these prerequisites in place, you’re ready to proceed with the installation of DKMS.

Installation Methods for DKMS

There are two primary methods to install DKMS on Ubuntu 24.04 LTS: the standard installation using apt, and manual package installation. We’ll cover both approaches to give you flexibility based on your specific needs.

Standard Installation Using apt

The simplest and most straightforward method to install DKMS is using Ubuntu’s package manager, apt. Follow these steps:

  1. Open a terminal window (you can use the keyboard shortcut Ctrl+Alt+T).
  2. Update your package list to ensure you’re getting the latest version:
    sudo apt update
  3. Install DKMS using the following command:
    sudo apt install dkms
  4. When prompted, enter your password and press Enter to confirm the installation.

This method will automatically handle any dependencies and install the latest version of DKMS available in the Ubuntu repositories.

Manual Package Installation

In some cases, you might need to install DKMS manually, perhaps due to network restrictions or specific version requirements. Here’s how to do it:

  1. First, download the DKMS package:
    sudo apt-get download dkms
  2. Once downloaded, install the package using dpkg:
    sudo dpkg -i dkms*.deb
  3. If there are any dependency issues, resolve them by running:
    sudo apt-get -f install

This manual method gives you more control over the installation process and can be useful in environments with limited internet access.

Secure Boot Configuration

If your system uses Secure Boot, you might encounter issues when installing or using DKMS. Secure Boot is a security standard developed by members of the PC industry to help ensure that your PC boots using only software that is trusted by the PC manufacturer. While it enhances security, it can sometimes interfere with custom kernel modules. Here are three methods to address Secure Boot-related issues:

Method 1: Creating a Machine-Owner Key

This method involves creating a new Machine-Owner Key (MOK) that allows you to sign kernel modules:

  1. When prompted during the installation of a DKMS module, choose to create a new MOK.
  2. Follow the on-screen instructions to set a password for the key.
  3. Reboot your system.
  4. During the boot process, you’ll be prompted to enroll the MOK. Select “Enroll MOK” and follow the prompts.
  5. Enter the password you set earlier to complete the process.

Method 2: Using mokutil

Alternatively, you can use the mokutil command to manage Secure Boot:

sudo mokutil --disable-validation

After running this command, reboot your system and follow the prompts to disable Secure Boot validation.

Method 3: BIOS Configuration

If the above methods don’t work, you may need to disable Secure Boot in your system’s BIOS:

  1. Restart your computer and enter the BIOS settings (usually by pressing F2, Del, or another key during boot).
  2. Navigate to the “Security” or “Boot” section.
  3. Find the “Secure Boot” option and disable it.
  4. Save changes and exit the BIOS.

Remember that disabling Secure Boot may have security implications, so only do this if absolutely necessary.

Post-Installation Setup

After successfully installing DKMS, it’s important to verify the installation and understand how to manage modules. This section will guide you through these post-installation steps.

Verification

To confirm that DKMS is installed and functioning correctly, use the following command:

dkms status

This command will display a list of all DKMS-managed modules, their versions, and their status. If you’ve just installed DKMS and haven’t added any modules yet, the output might be empty.

Module Management

DKMS provides several commands for managing kernel modules. Here are the key operations:

  • Adding a module:
    sudo dkms add module/version
  • Building a module:
    sudo dkms build module/version
  • Installing a module:
    sudo dkms install module/version
  • Removing a module:
    sudo dkms remove module/version --all

Replace “module” with the name of your module and “version” with its version number in these commands.

Common Use Cases

DKMS is particularly useful in several scenarios. Let’s explore two common use cases: installing AMD GPU drivers and managing custom kernel modules.

Installing AMD GPU Drivers

For users with AMD graphics cards, DKMS can simplify the process of installing and maintaining GPU drivers. Here’s how to install AMD GPU drivers using DKMS:

  1. First, ensure that your system is up to date:
    sudo apt update && sudo apt upgrade
  2. Install the AMDGPU DKMS package:
    sudo apt install amdgpu-dkms
  3. Reboot your system to apply the changes:
    sudo reboot

After the reboot, your system should be using the AMD GPU drivers, and DKMS will ensure that they remain compatible with future kernel updates.

Custom Module Installation

For more advanced users who need to install custom kernel modules, DKMS provides a structured approach:

  1. Prepare your module source code in a directory (usually under /usr/src/).
  2. Create a dkms.conf file in the source directory with the necessary configuration.
  3. Add the module to DKMS:
    sudo dkms add -m module_name -v module_version
  4. Build the module:
    sudo dkms build -m module_name -v module_version
  5. Install the module:
    sudo dkms install -m module_name -v module_version

This process ensures that your custom module is properly managed by DKMS and will be rebuilt automatically when needed.

Troubleshooting Common Issues

While DKMS generally works smoothly, you might encounter some issues. Here are some common problems and their solutions:

Dependency Resolution

If you encounter dependency issues during installation, try the following:

  1. Update your package list:
    sudo apt update
  2. Install any missing dependencies:
    sudo apt-get -f install
  3. Retry the DKMS installation.

Compilation Errors

If a module fails to compile, check the following:

  • Ensure you have the necessary build tools installed:
    sudo apt install build-essential linux-headers-$(uname -r)
  • Check the DKMS log for specific error messages:
    sudo cat /var/lib/dkms/module_name/module_version/build/make.log

Secure Boot Conflicts

If you’re experiencing issues related to Secure Boot:

  • Try the Secure Boot configuration methods mentioned earlier in this guide.
  • If problems persist, consider temporarily disabling Secure Boot for testing purposes.

Congratulations! You have successfully installed DKMS. Thanks for using this tutorial for installing the DKMS (Dynamic Kernel Module Support) on your Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official DKMS website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button