Kernel Kernel-Modules DKMS – Command to Rebuild All DKMS Modules for All Installed Kernels

dkmskernelkernel-modules

Occasionally, my system gets into a state where some kernels are missing a module or two, because DKMS somehow forgot to compile those modules for that kernel. Rather than spend time diagnosing the problem, it would be nice if there was a single command I could run that woudl just rebuild every dkms-controlled module for every installed kernel. Is there such a command?

Best Answer

I figured out a shell one-liner to do it:

ls /var/lib/initramfs-tools | \
    sudo xargs -n1 /usr/lib/dkms/dkms_autoinstaller start

This works because the names of the directories in /var/lib/initramfs-tools are exactly the kernel version names that you need to pass to dkms_autoinstaller to tell it to rebuild all modules for those kernel versions. Note that if you have uninstalled some old kernels, their directories might still be lying around and cause some errors to be reported, but this isn't a problem because dkms_autoinstaller will just do nothing for those kernel versions that aren't installed.