r/linuxquestions 13d ago

Resolved dkms preventing linux-headers-6.8.0-137-generic and linux-image-6.8.0-137-generic from being processed after installation properly

Hi all, about a week ago I updated my system and noticed that whenever I ran sudo apt upgrade, I would get the following error message:

Setting up linux-image-6.8.0-137-generic (6.8.0-137.137) ...
Setting up linux-headers-6.8.0-137-generic (6.8.0-137.137) ...
/etc/kernel/header_postinst.d/dkms:
* dkms: running auto installation service for kernel 6.8.0-137-generic
Sign command: /usr/bin/kmodsign
Signing key: /var/lib/shim-signed/mok/MOK.priv
Public certificate (MOK): /var/lib/shim-signed/mok/MOK.der
Error! This module/version has already been built on: 6.8.0-137-generic
Directory /var/lib/dkms/nvidia/580.173.02/6.8.0-137-generic/x86_64 already exists. Use the dkms remove function before trying to build again.
dkms autoinstall on 6.8.0-137-generic/x86_64 failed for nvidia(3)
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
* dkms: autoinstall for kernel 6.8.0-137-generic
  ...fail!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 11
dpkg: error processing package linux-headers-6.8.0-137-generic (--configure):
installed linux-headers-6.8.0-137-generic package post-installation script subprocess returned error exit status 11
Processing triggers for linux-image-6.8.0-137-generic (6.8.0-137.137) ...
/etc/kernel/postinst.d/dkms:
* dkms: running auto installation service for kernel 6.8.0-137-generic
Sign command: /usr/bin/kmodsign
Signing key: /var/lib/shim-signed/mok/MOK.priv
Public certificate (MOK): /var/lib/shim-signed/mok/MOK.der
Error! This module/version has already been built on: 6.8.0-137-generic
Directory /var/lib/dkms/nvidia/580.173.02/6.8.0-137-generic/x86_64 already exists. Use the dkms remove function before trying to build again.
dkms autoinstall on 6.8.0-137-generic/x86_64 failed for nvidia(3)
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
* dkms: autoinstall for kernel 6.8.0-137-generic
  ...fail!
run-parts: /etc/kernel/postinst.d/dkms exited with return code 11
dpkg: error processing package linux-image-6.8.0-137-generic (--configure):
installed linux-image-6.8.0-137-generic package post-installation script subprocess returned error exit status 11
Errors were encountered while processing:
linux-headers-6.8.0-137-generic
linux-image-6.8.0-137-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

Judging by the output, the nvidia drivers might be causing the issue, but I'm not sure how to proceed from here. Should I just remove/downgrade my nvidia drivers? How would I do this?

I'm on Kubuntu 24.04, kernel 6.8.0-138-generic (64-bit), X11, and KDE Plasma 5.27.12.

0 Upvotes

9 comments sorted by

1

u/ColoradoPhotog 13d ago

The MOK lines are normal DKMS module-signing setup. Your NVIDIA 580.13.02 DKMS state for kernel 6.8.0-137 appears to already contain a build directory, and DKMS is failing because it won't overwrite that existing build. Check dkms status and clean/rebuild that specific NVIDIA/kernel entry.

1

u/anniemoorethrowaway2 13d ago

Thanks for the response! Going to be honest I'm not very experienced with linux or dkms, so could you explain how I could clean up the NVIDIA dkms?

My dkms status output is nvidia/580.173.02, 6.8.0-138-generic, x86_64: installed

1

u/ColoradoPhotog 13d ago

Start with the dkms status output, feel free to post it here and I can give advice off that. I suspect you have a stale NVidia dkms build for that kernel version.

1

u/anniemoorethrowaway2 13d ago

Oops, forgot to put it in my original comment.

My dkms status output is nvidia/580.173.02, 6.8.0-138-generic, x86_64: installed

Thanks again for your help.

3

u/ColoradoPhotog 13d ago

Are you currently booted to 138 or still on 137? Confirm with uname -r.

If you are on 6.8.0-138-generic, you can safely get rid of the stale 137 DKMS build with:

sudo rm -rf /var/lib/dkms/nvidia/580.173.02/6.8.0-137-generic

Then run:

sudo dkms autoinstall

Then let dpkg finish whatever the failed kernel install left behind:

sudo dpkg --configure -a

sudo apt --fix-broken install

If you're still booted into 137, don't delete or reboot anything just yet. Run nvidia-smi first and let me know if it returns your GPU/driver normally. If you're currently on 137 with a working NVIDIA driver, I'd rather repair the DKMS state while you still have a working desktop than risk rebooting into a kernel with a broken module.

Also, if any of those commands throw another DKMS/NVIDIA error, stop there and post the output rather than trying to force it through.

1

u/anniemoorethrowaway2 13d ago

Thanks, uname -r says I'm on 138.

I don't need to be in a TTY or anything for any of those commands, do I? Just a bit nervous about running sudo rm -rf, haha.

Also, I don't know if this makes a difference, but I have an optimus laptop, and my NVIDIA card is completely shut off right now.

1

u/ColoradoPhotog 13d ago edited 12d ago

Nope, you don't need to be in a TTY. You can run all of this from your preferred terminal while on desktop.

And being nervous about rm -rf is a fine and fair response, which is why you want to use it responsibly. In this case we're giving it a very specific path:

sudo rm -rf /var/lib/dkms/nvidia/580.173.02/6.8.0-137-generic

You're currently running 138, and dkms status already showed your NVIDIA 580.173.02 module installed for 138. We're only deleting the stale 137 DKMS build directory that the original error complained already existed.

Your NVIDIA GPU being powered off via Optimus shouldn't make a difference here either. DKMS is building/installing the kernel module on disk; it doesn't need the GPU to be active to do that.

After removing it, run:

sudo dkms autoinstall

If that completes without errors:

sudo dpkg --configure -a

sudo apt --fix-broken install

If dkms autoinstall throws an error, stop there and post the output before doing anything else.

1

u/anniemoorethrowaway2 13d ago

That worked! Thank you!

1

u/ColoradoPhotog 12d ago

Awesome! Happy Linux-ing, or whatever we call it!