Leftovers from old kernels in /lib/modules - shouldn't they be removed?

Hello all,

searching for a fix for this error message DKMS ERROR: Missing 5.16.0-1-MANJARO kernel headers for module nvidia/515.48.07 , I encountered that there are a lot of subfolders in /lib/modules pertaining to kernels I already uninstalled long time ago.

Is it safe to remove them, and is there perhaps some general command or tool available to do that, similar to, for example, removing orphaned packages with pacman?

Thank you very much for all hints in advance and kind regards.

Hi @DAC324,

I just checked, and I don’t have anything there from kernels I don’t have installed. So I’d say it’s safe. But don’t take chances. Remove it, but keep a backup. From the terminal:

sudo mv /lib/modules/<directory> /lib/modules/backup.<directory>

Where <directory> is the name of the directory of modules that should be moved/removed.

You need to do this twice:

  • once for the *MANJARO directory; and
  • once for the extramodules-* directory.

For kernel 5.15, for example, it would be:

  • 5.15.46-1-MANJARO and
  • extramodules-5.15-MANJARO

Hope this helps!

Thanks a lot!
I have moved all those subfolders to an additional old folder, just in case. Let’s see if there are any adverse effects :slight_smile:

1 Like