How to Completely Disable the ‘kmod’ (Kernel Module Loader) Service in Ubuntu Server

The kmod.service (Kernel Module Loader) in Ubuntu Server is a systemd unit responsible for loading static kernel modules (drivers) specified in /etc/modules or /etc/modules-load.d/ during the boot process. In a dynamic, general-purpose server, this is critical for initializing specific hardware drivers or filesystem support before user-space applications load. However, in highly specialized, monolithic environments—such as custom-compiled kernels where all necessary drivers are built directly into the kernel image (vmlinuz) rather than loaded dynamically as .ko files, or in strictly locked-down environments where dynamic module loading is forbidden for security reasons—the kmod initialization service is entirely redundant.

This guide explains how to completely disable the kmod.service in Ubuntu Server.

Stop and Mask the Kernel Module Loader

To ensure the systemd initialization sequence completely bypasses the attempt to parse module configuration files and invoke modprobe, we must disable the service and aggressively mask it.

  1. Log into your Ubuntu Server via SSH using an account with sudo privileges.
  2. First, ensure the service is stopped (though it typically runs once at boot and exits):
    sudo systemctl stop kmod.service
  3. Next, disable the service to prevent it from loading normally:
    sudo systemctl disable kmod.service
  4. To guarantee that it cannot be triggered by systemd dependencies or manual hardware initialization scripts, mask it entirely:
    sudo systemctl mask kmod.service

Verify the Boot Optimization

By masking the service, you have effectively symlinked its unit file to /dev/null. The server will no longer execute the userspace modprobe loop during early boot to load static modules.

To verify the lockdown is successful, run the following command to check the status of the daemon:

systemctl status kmod.service

The output will clearly state that the service is masked. Note that this does not prevent udev from dynamically loading modules when new hardware is hot-plugged (unless you have also explicitly locked down module loading via sysctl kernel.modules_disabled=1), but it successfully eliminates the static /etc/modules loading phase during boot, optimizing your custom architecture.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.